You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Julian Hyde (Jira)" <ji...@apache.org> on 2020/06/26 17:21:00 UTC
[jira] [Resolved] (CALCITE-3150) NullPointerException when UPPER is
repeated and combined with LIKE
[ https://issues.apache.org/jira/browse/CALCITE-3150?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Julian Hyde resolved CALCITE-3150.
----------------------------------
Fix Version/s: 1.24.0
Resolution: Duplicate
Duplicate of CALCITE-3224, now fixed.
> NullPointerException when UPPER is repeated and combined with LIKE
> ------------------------------------------------------------------
>
> Key: CALCITE-3150
> URL: https://issues.apache.org/jira/browse/CALCITE-3150
> Project: Calcite
> Issue Type: Bug
> Components: core
> Affects Versions: next
> Reporter: Mickaël Sauvée
> Assignee: Feng Zhu
> Priority: Major
> Labels: pull-request-available
> Fix For: 1.24.0
>
>
> Using a query using twice same UPPER with a LIKE, generated code do not protect UPPER call.
> If inout is null, then UPPER is call and generates a NPE.
> I've used the following test (in JdbcTest.java):
>
> {code:java}
> @Test
> public void testNPEInUpper() {
> CalciteAssert.hr()
> .query("select e.\"name\" from \"hr\".\"emps\" as e WHERE (UPPER(e.\"name\") LIKE 'B%' AND UPPER(e.\"name\") LIKE '%L')" )
> .returnsUnordered("name=Bill;");
> }
> {code}
> And modify data to hava NULL for a name:
>
>
> {code:java}
> public final Employee[] emps = {
> new Employee(100, 10, "Bill", 10000, 1000),
> new Employee(200, 20, "Eric", 8000, 500),
> new Employee(150, 10, null, 7000, null),
> new Employee(110, 10, "Theodore", 11500, 250),
> };
> {code}
> This generates this code:
>
>
> {code:java}
> /* 11 */ public boolean moveNext() {
> /* 12 */ while (inputEnumerator.moveNext()) {
> /* 13 */ final String inp2_ = ((org.apache.calcite.test.JdbcTest.Employee) inputEnumerator.current()).name;
> /* 14 */ final String v = org.apache.calcite.runtime.SqlFunctions.upper(inp2_);
> /* 15 */ if (inp2_ != null && org.apache.calcite.runtime.SqlFunctions.like(v, "B%") && (inp2_ != null && org.apache.calcite.runtime.SqlFunctions.like(v, "%L"))) {
> /* 16 */ return true;
> /* 17 */ }
> /* 18 */ }
> /* 19 */ return false;
> /* 20 */ }
> {code}
>
> The variable v is computed whenever inp2_ is null. My guess is that v should not be inlined, or the function upper org.apache.calcite.runtime.SqlFunctions.upper should support null as parameter (and return null).
--
This message was sent by Atlassian Jira
(v8.3.4#803005)