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

AssertionError during constant reduction of SPLIT expression that returns NULL

    XMLWordPrintableJSON

Details

    Description

      The following test, when inserted in RelOptRulesTest, crashes at compilation time with an AssertionFailure:

      @Test public void testSplit() {
          final String query = "select split('1|2|3', NULL)";
          sql(query)
              .withFactory(
                  t -> t.withOperatorTable(opTab ->
                      SqlLibraryOperatorTableFactory.INSTANCE.getOperatorTable(
                          SqlLibrary.BIG_QUERY))) // needed for SPLIT function
              .withRule(CoreRules.PROJECT_REDUCE_EXPRESSIONS)
              .check();
      }
      

      The error message and stack trace look like this:

      java.lang.AssertionError: Cannot add expression of different type to set:
      set type is RecordType(CHAR(5) NOT NULL ARRAY NOT NULL EXPR$0) NOT NULL
      expression type is RecordType(CHAR(5) NOT NULL ARRAY EXPR$0) NOT NULL
      set is rel#4:LogicalProject.(input=HepRelVertex#3,exprs=[SPLIT('1|2|3', null:NULL)])
      expression is LogicalProject(EXPR$0=[null:CHAR(5) NOT NULL ARRAY])
        LogicalValues(tuples=[[{ 0 }]])
      Type mismatch:
      rowtype of original rel: RecordType(CHAR(5) NOT NULL ARRAY NOT NULL EXPR$0) NOT NULL
      rowtype of new rel: RecordType(CHAR(5) NOT NULL ARRAY EXPR$0) NOT NULL
      Difference:
      EXPR$0: CHAR(5) NOT NULL ARRAY NOT NULL -> CHAR(5) NOT NULL ARRAY
      
      	at org.apache.calcite.plan.RelOptUtil.verifyTypeEquivalence(RelOptUtil.java:394)
      	at org.apache.calcite.plan.hep.HepRuleCall.transformTo(HepRuleCall.java:60)
      

      Attachments

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved: