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

Handle SqlKind.DYNAMIC (parameters) in SqlImplementor

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 1.11.0, 1.12.0
    • Fix Version/s: 1.14.0
    • Component/s: None
    • Labels:
      None

      Description

      SqlImplementor.toSql's.toSql doesn't contain logic for converting SqlKind.DYNAMIC to the appropriate SqlNode. Using RelToSqlConverter on a RelNode tree containing RexDynamicParameters, results in the following stack trace:

      Caused by: java.lang.reflect.InvocationTargetException
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:498)
      	at org.apache.calcite.util.ReflectUtil$2.invoke(ReflectUtil.java:525)
      	... 33 more
      Caused by: java.lang.RuntimeException: While invoking method 'public org.apache.calcite.rel.rel2sql.SqlImplementor$Result org.apache.calcite.rel.rel2sql.RelToSqlConverter.visit(org.apache.calcite.rel.core.Filter)'
      	at org.apache.calcite.util.ReflectUtil$2.invoke(ReflectUtil.java:528)
      	at org.apache.calcite.rel.rel2sql.RelToSqlConverter.dispatch(RelToSqlConverter.java:93)
      	at org.apache.calcite.rel.rel2sql.RelToSqlConverter.visitChild(RelToSqlConverter.java:97)
      	at org.apache.calcite.rel.rel2sql.RelToSqlConverter.visit(RelToSqlConverter.java:157)
      	... 38 more
      Caused by: java.lang.reflect.InvocationTargetException
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:498)
      	at org.apache.calcite.util.ReflectUtil$2.invoke(ReflectUtil.java:525)
      	... 41 more
      Caused by: java.lang.ClassCastException: org.apache.calcite.rex.RexDynamicParam cannot be cast to org.apache.calcite.rex.RexCall
      	at org.apache.calcite.rel.rel2sql.SqlImplementor$Context.toSql(SqlImplementor.java:587)
      	at org.apache.calcite.rel.rel2sql.SqlImplementor$Context.toSql(SqlImplementor.java:742)
      	at org.apache.calcite.rel.rel2sql.SqlImplementor$Context.toSql(SqlImplementor.java:589)
      	at org.apache.calcite.rel.rel2sql.SqlImplementor$Context.toSql(SqlImplementor.java:742)
      	at org.apache.calcite.rel.rel2sql.SqlImplementor$Context.toSql(SqlImplementor.java:589)
      	at org.apache.calcite.rel.rel2sql.SqlImplementor$Context.toSql(SqlImplementor.java:742)
      	at org.apache.calcite.rel.rel2sql.SqlImplementor$Context.toSql(SqlImplementor.java:589)
      	at org.apache.calcite.rel.rel2sql.RelToSqlConverter.visit(RelToSqlConverter.java:150)
      	... 46 more
      

        Activity

        Hide
        michaelmior Michael Mior added a comment -

        Resolved in release 1.14.0 (2017-10-01)

        Show
        michaelmior Michael Mior added a comment - Resolved in release 1.14.0 (2017-10-01)
        Hide
        julianhyde Julian Hyde added a comment -
        Show
        julianhyde Julian Hyde added a comment - Fixed in http://git-wip-us.apache.org/repos/asf/calcite/commit/cdb30028 . Thanks for the PR, Dylan Adams !
        Hide
        julianhyde Julian Hyde added a comment -

        Reviewing now.

        Show
        julianhyde Julian Hyde added a comment - Reviewing now.
        Hide
        dadams Dylan Adams added a comment -
        Show
        dadams Dylan Adams added a comment - Pull request: https://github.com/apache/calcite/pull/486
        Hide
        julianhyde Julian Hyde added a comment -

        Can you please convert this to a pull request? Then I will review.

        Show
        julianhyde Julian Hyde added a comment - Can you please convert this to a pull request? Then I will review.
        Hide
        dadams Dylan Adams added a comment -

        Patch to resolve the issue.

        Add case for SqlKind.DYNAMIC to SqlImplementor's toSql method,
        converting the RexDynamicParam to SqlDynamicParam.

        Added supporting test case.

        Show
        dadams Dylan Adams added a comment - Patch to resolve the issue. Add case for SqlKind.DYNAMIC to SqlImplementor's toSql method, converting the RexDynamicParam to SqlDynamicParam. Added supporting test case.

          People

          • Assignee:
            julianhyde Julian Hyde
            Reporter:
            dadams Dylan Adams
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development