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

IN clause in CASE in GROUP BY gives AssertionError

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.1.0-incubating, 0.9.1-incubating
    • Fix Version/s: 1.2.0-incubating
    • Component/s: None
    • Labels:
      None

      Description

      hi, i'm using the latest optiq-csv(which depends on calcite 0.9.1).
      I even tried changing 0.9.1 to 0.9.2 in optiq-csv's pom, but it will fail "mvn clean install"

      here's my problem:

      ==============================================
      select (CASE WHEN (GENDER = 'F') THEN 'woman' ELSE GENDER END), min(EMPID) from EMPS group by (CASE WHEN (GENDER = 'F') THEN 'woman' ELSE GENDER END)

      >>> this works

      select (CASE WHEN (GENDER IN ('M','F')) THEN 'known' ELSE GENDER END), min(EMPID) from EMPS group by (CASE WHEN (GENDER IN ('M','F')) THEN 'known' ELSE GENDER END)

      >>> this will not work with exception:
      java.lang.AssertionError: Internal error: while converting CASE WHEN `EMPS`.`GENDER` IN ('M', 'F') THEN 'known' ELSE `EMPS`.`GENDER` END
      at org.eigenbase.util.Util.newInternal(Util.java:753)
      at org.eigenbase.sql2rel.ReflectiveConvertletTable$1.convertCall(ReflectiveConvertletTable.java:92)
      at org.eigenbase.sql2rel.SqlNodeToRexConverterImpl.convertCall(SqlNodeToRexConverterImpl.java:51)
      at org.eigenbase.sql2rel.SqlToRelConverter$Blackboard.visit(SqlToRelConverter.java:4162)
      at org.eigenbase.sql2rel.SqlToRelConverter$Blackboard.visit(SqlToRelConverter.java:3610)
      at org.eigenbase.sql.SqlCall.accept(SqlCall.java:124)
      at org.eigenbase.sql2rel.SqlToRelConverter$Blackboard.convertExpression(SqlToRelConverter.java:4055)
      at org.eigenbase.sql2rel.SqlToRelConverter$AggConverter.addGroupExpr(SqlToRelConverter.java:4343)
      at org.eigenbase.sql2rel.SqlToRelConverter.createAggImpl(SqlToRelConverter.java:2433)
      at org.eigenbase.sql2rel.SqlToRelConverter.convertAgg(SqlToRelConverter.java:2384)
      at org.eigenbase.sql2rel.SqlToRelConverter.convertSelectImpl(SqlToRelConverter.java:491)
      at org.eigenbase.sql2rel.SqlToRelConverter.convertSelect(SqlToRelConverter.java:451)
      at org.eigenbase.sql2rel.SqlToRelConverter.convertQueryRecursive(SqlToRelConverter.java:2803)
      at org.eigenbase.sql2rel.SqlToRelConverter.convertQuery(SqlToRelConverter.java:409)
      at net.hydromatic.optiq.prepare.Prepare.prepareSql(Prepare.java:211)
      at net.hydromatic.optiq.prepare.Prepare.prepareSql(Prepare.java:178)
      at net.hydromatic.optiq.prepare.OptiqPrepareImpl.prepare2_(OptiqPrepareImpl.java:412)
      at net.hydromatic.optiq.prepare.OptiqPrepareImpl.prepare_(OptiqPrepareImpl.java:318)
      at net.hydromatic.optiq.prepare.OptiqPrepareImpl.prepareSql(OptiqPrepareImpl.java:287)
      at net.hydromatic.optiq.jdbc.OptiqConnectionImpl.parseQuery(OptiqConnectionImpl.java:170)
      at net.hydromatic.optiq.jdbc.MetaImpl.prepare(MetaImpl.java:617)
      at net.hydromatic.avatica.AvaticaStatement.execute(AvaticaStatement.java:67)
      at sqlline.Commands.execute(Commands.java:822)
      at sqlline.Commands.sql(Commands.java:732)
      at sqlline.SqlLine.dispatch(SqlLine.java:808)
      at sqlline.SqlLine.begin(SqlLine.java:681)
      at sqlline.SqlLine.start(SqlLine.java:398)
      at sqlline.SqlLine.main(SqlLine.java:292)
      Caused by: java.lang.reflect.InvocationTargetException
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:606)
      at org.eigenbase.sql2rel.ReflectiveConvertletTable$1.convertCall(ReflectiveConvertletTable.java:83)
      ... 26 more
      Caused by: java.lang.NullPointerException
      at org.eigenbase.sql2rel.SqlToRelConverter$Blackboard.convertExpression(SqlToRelConverter.java:4045)
      at org.eigenbase.sql2rel.StandardConvertletTable.convertCase(StandardConvertletTable.java:254)
      ... 31 more

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                julianhyde Julian Hyde
                Reporter:
                mahongbin hongbin ma
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: