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

SqlItemOperator fails in RelToSqlConverter

    XMLWordPrintableJSON

Details

    Description

      We have an expression that looks like:

      foo[1].bar 

      When we run RelToSqlConverter we get the following strack trace: (Calcite 1.35.0)

       

      [info]   java.lang.ClassCastException: class org.apache.calcite.sql.SqlBasicCall cannot be cast to class org.apache.calcite.sql.SqlIdentifier (org.apache.calcite.sql.SqlBasicCall and org.apache.calcite.sql.SqlIdentifier are in unnamed module of loader sbt.internal.FlatLoader @3de98cb6)
      [info]   at org.apache.calcite.rel.rel2sql.SqlImplementor$Context.toSql(SqlImplementor.java:676)
      [info]   at org.apache.calcite.rel.rel2sql.RelToSqlConverter.visit(RelToSqlConverter.java:458)
      [info]   at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      [info]   at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
      [info]   at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      [info]   at java.base/java.lang.reflect.Method.invoke(Method.java:568)
      [info]   at org.apache.calcite.util.ReflectUtil$2.invoke(ReflectUtil.java:532)
      [info]   at org.apache.calcite.rel.rel2sql.RelToSqlConverter.dispatch(RelToSqlConverter.java:143)
      [info]   at org.apache.calcite.rel.rel2sql.RelToSqlConverter.visitInput(RelToSqlConverter.java:151)
      [info]   at org.apache.calcite.rel.rel2sql.SqlImplementor.visitInput(SqlImplementor.java:220) 

       

      This is because there is a missing case for the function

      public SqlNode toSql(@Nullable RexProgram program, RexNode rex) { 
      // ...
      
              switch (rex.getKind()){
              // ...
              case ITEM: // << missing
              // missing impl         
              default:
              sqlIdentifier = (SqlIdentifier) toSql(program, referencedExpr);
      }

       

      ```

      The rex kind is ITEM

       

      Attachments

        Issue Links

          Activity

            People

              jiajunbernoulli Jiajun Xie
              MasseGuillaume Guillaume Massé
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: