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

AssertionError during optimization of EXTRACT expression

    XMLWordPrintableJSON

Details

    Description

      The following test added to RelOptRules test causes an AssertionError:

        @Test void testExtractDayFromTime() {
          final String sql = "select EXTRACT(DAY FROM TIME'10:00:00')";
          sql(sql).withRule(CoreRules.PROJECT_REDUCE_EXPRESSIONS)
              .check();
        }
      

      The bottom of the stack trace is:

      java.lang.AssertionError: unexpected TIME
      	at org.apache.calcite.adapter.enumerable.RexImpTable$ExtractImplementor.implementSafe(RexImpTable.java:3056)
      	at org.apache.calcite.adapter.enumerable.RexImpTable$AbstractRexCallImplementor.genValueStatement(RexImpTable.java:3796)
      	at org.apache.calcite.adapter.enumerable.RexImpTable$AbstractRexCallImplementor.implement(RexImpTable.java:3758)
      	at org.apache.calcite.adapter.enumerable.RexToLixTranslator.visitCall(RexToLixTranslator.java:1184)
      	at org.apache.calcite.adapter.enumerable.RexToLixTranslator.visitCall(RexToLixTranslator.java:101)
      	at org.apache.calcite.rex.RexCall.accept(RexCall.java:189)
      

      This expression is indeed illegal. Perhaps validation should produce an error?

      Attachments

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved: