You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@calcite.apache.org by "Guillaume Massé (Jira)" <ji...@apache.org> on 2023/11/03 03:32:00 UTC

[jira] [Created] (CALCITE-6088) SqlItemOperator fails in RelToSqlConverter

Guillaume Massé created CALCITE-6088:
----------------------------------------

             Summary: SqlItemOperator fails in RelToSqlConverter
                 Key: CALCITE-6088
                 URL: https://issues.apache.org/jira/browse/CALCITE-6088
             Project: Calcite
          Issue Type: Bug
          Components: core
    Affects Versions: 1.35.0
            Reporter: Guillaume Massé


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         default:           System.out.println();           System.out.println("kind: ");           System.out.println(referencedExpr.getKind());           sqlIdentifier = (SqlIdentifier) toSql(program, referencedExpr);         }

```

The rex kind is `ITEM`

 



--
This message was sent by Atlassian Jira
(v8.20.10#820010)