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

Optimization CoreRules.PROJECT_REDUCE_EXPRESSIONS crashes while optimizing ARRAY_CONCAT expression

    XMLWordPrintableJSON

Details

    Description

      The following RelOptRulesTest

       @Test void testArrayConcat() {
          final String sql = "select array_concat(ARRAY [1, 2], ARRAY [3, 4])";
          sql(sql).withFactory(
                  t -> t.withOperatorTable(
                      opTab -> SqlLibraryOperatorTableFactory.INSTANCE.getOperatorTable(
                          SqlLibrary.STANDARD, SqlLibrary.BIG_QUERY)))
              .withRule(CoreRules.PROJECT_REDUCE_EXPRESSIONS)
              .check();
        }
      

      crashes with the following stack trace:

      java.lang.RuntimeException: While compiling [ARRAY_CONCAT(ARRAY(1, 2), ARRAY(3, 4))]
      	at org.apache.calcite.rex.RexExecutable.compile(RexExecutable.java:73)
      	at org.apache.calcite.rex.RexExecutable.<init>(RexExecutable.java:53)
      	at org.apache.calcite.rex.RexExecutorImpl.reduce(RexExecutorImpl.java:145)
      	at org.apache.calcite.rel.rules.ReduceExpressionsRule.reduceExpressionsInternal(ReduceExpressionsRule.java:774)
      	at org.apache.calcite.rel.rules.ReduceExpressionsRule.reduceExpressions(ReduceExpressionsRule.java:714)
      

      It seems that the generated code passed to Janino is invalid:

      Line 10, Column 5: Assignment conversion not possible from type "java.util.ArrayList" to type "java.lang.Object[]"
      org.codehaus.commons.compiler.CompileException: Line 10, Column 5: Assignment conversion not possible from type "java.util.ArrayList" to type "java.lang.Object[]"

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              mbudiu Mihai Budiu
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: