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

Exception thrown when decorrelating query with TEMPORAL TABLE

    XMLWordPrintableJSON

    Details

      Description

      Repro:
      In SqlToRelConverterTest.java, add the following case:

      @Test public void testStreamLateralJoin() {
          final String sql = "select stream *\n"
              + "from orders\n"
              + "cross join lateral ("
              + "  select * from products_temporal for system_time as of orders.rowtime\n"
              + "  where orders.productid = products_temporal.productid)\n";
          sql(sql).ok();
        }
      

      We will see the exception:

      java.lang.RuntimeException: While invoking method 'public org.apache.calcite.sql2rel.RelDecorrelator$Frame org.apache.calcite.sql2rel.RelDecorrelator.decorrelateRel(org.apache.calcite.rel.RelNode)'
      
      	at org.apache.calcite.util.ReflectUtil$2.invoke(ReflectUtil.java:527)
      	at org.apache.calcite.sql2rel.RelDecorrelator.getInvoke(RelDecorrelator.java:613)
      	at org.apache.calcite.sql2rel.RelDecorrelator.decorrelate(RelDecorrelator.java:254)
      	at org.apache.calcite.sql2rel.RelDecorrelator.decorrelateQuery(RelDecorrelator.java:214)
      	at org.apache.calcite.sql2rel.SqlToRelConverter.decorrelateQuery(SqlToRelConverter.java:3073)
      	at org.apache.calcite.sql2rel.SqlToRelConverter.decorrelate(SqlToRelConverter.java:483)
      	at org.apache.calcite.test.SqlToRelTestBase$TesterImpl.convertSqlToRel(SqlToRelTestBase.java:616)
      	at org.apache.calcite.test.SqlToRelTestBase$TesterImpl.assertConvertsTo(SqlToRelTestBase.java:723)
      	at org.apache.calcite.test.SqlToRelConverterTest$Sql.convertsTo(SqlToRelConverterTest.java:3096)
      	at org.apache.calcite.test.SqlToRelConverterTest$Sql.ok(SqlToRelConverterTest.java:3088)
      .........
      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:524)
      	... 32 more
      Caused by: java.lang.RuntimeException: While invoking method 'public org.apache.calcite.sql2rel.RelDecorrelator$Frame org.apache.calcite.sql2rel.RelDecorrelator.decorrelateRel(org.apache.calcite.rel.logical.LogicalProject)'
      	at org.apache.calcite.util.ReflectUtil$2.invoke(ReflectUtil.java:527)
      	at org.apache.calcite.sql2rel.RelDecorrelator.getInvoke(RelDecorrelator.java:613)
      	at org.apache.calcite.sql2rel.RelDecorrelator.decorrelateRel(RelDecorrelator.java:369)
      

      Inside

      public Frame decorrelateRel(LogicalCorrelate rel)
      

      , assertion failure happened:

      assert rel.getRequiredColumns().cardinality()
              <= rightFrame.corDefOutputs.keySet().size();
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                hyuan Haisheng Yuan
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 1.5h
                  1.5h