Uploaded image for project: 'Calcite'
  1. Calcite
  2. CALCITE-980

Not (C='a' or C='b') as well as Not (C='a' and C='b') causes NPE

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.4.0-incubating
    • 1.6.0
    • None
    • None

    Description

      A where clause like Not (C='a' or C='b') causes NPE if C has NULL value.

      The generated code snippet looks like:

      /*  65 */           public boolean moveNext() {
      /*  66 */             while (inputEnumerator.moveNext()) {
      /*  67 */               final Object[] current = (Object[]) inputEnumerator.current();
      /*  68 */               final String inp21_ = current[21] == null ? (String) null : current[21].toString();
      /*  69 */               final Boolean v = inp21_ == null ? (Boolean) null : Boolean.valueOf(org.apache.calcite.runtime.SqlFunctions.eq(inp21_, "A"));
      /*  70 */               final Boolean v0 = inp21_ == null ? (Boolean) null : Boolean.valueOf(org.apache.calcite.runtime.SqlFunctions.eq(inp21_, "B"));
      /*  71 */               if (!(v == null ? (v0 == null || !v0 ? (Boolean) null : Boolean.TRUE) : v ? Boolean.TRUE : v0)) {
      /*  72 */                 return true;
      /*  73 */               }
      /*  74 */             }
      /*  75 */             return false;
      /*  76 */           }
      

      And NPE is thrown at line #71 if inp21_ is null.

      Stacktrace:

      Caused by: java.lang.NullPointerException
      	at Baz$1$1.moveNext(ANONYMOUS.java:71)
      	at org.apache.calcite.linq4j.EnumerableDefaults.groupBy_(EnumerableDefaults.java:737)
      	at org.apache.calcite.linq4j.EnumerableDefaults.groupBy(EnumerableDefaults.java:677)
      	at org.apache.calcite.linq4j.DefaultEnumerable.groupBy(DefaultEnumerable.java:301)
      	at Baz.bind(Baz.java:95)
      	at org.apache.calcite.jdbc.CalcitePrepare$CalciteSignature.enumerable(CalcitePrepare.java:281)
      	at org.apache.calcite.jdbc.CalciteConnectionImpl.enumerable(CalciteConnectionImpl.java:235)
      	at org.apache.calcite.jdbc.CalciteMetaImpl.createIterable(CalciteMetaImpl.java:533)
      	at org.apache.calcite.avatica.AvaticaResultSet.execute(AvaticaResultSet.java:184)
      	at org.apache.calcite.jdbc.CalciteResultSet.execute(CalciteResultSet.java:63)
      	at org.apache.calcite.jdbc.CalciteResultSet.execute(CalciteResultSet.java:42)
      	at org.apache.calcite.avatica.AvaticaConnection$1.execute(AvaticaConnection.java:473)
      	at org.apache.calcite.jdbc.CalciteMetaImpl.prepareAndExecute(CalciteMetaImpl.java:566)
      	at org.apache.calcite.avatica.AvaticaConnection.prepareAndExecuteInternal(AvaticaConnection.java:477)
      	at org.apache.calcite.avatica.AvaticaStatement.executeInternal(AvaticaStatement.java:109)
      	... 29 more
      

      Attachments

        Issue Links

          Activity

            People

              vladimirsitnikov Vladimir Sitnikov
              liyang.gmt8@gmail.com liyang
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: