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

DATE_PART is not handled by the RexToLixTranslator

    XMLWordPrintableJSON

Details

    Description

      The following test, when added to SqlOperatorTest, causes a RuntimeException:

      @Test void testDatePart() {
          final SqlOperatorFixture f = fixture().withLibrary(SqlLibrary.POSTGRESQL)
              .withParserConfig(p -> p.withParserFactory(SqlBabelParserImpl.FACTORY));
          f.checkScalar("DATE_PART(second, TIME '10:10:10')",
              "10", "BIGINT NOT NULL");
        }
      

      Note that this needs https://github.com/apache/calcite/pull/3445 to execute correctly.

      The stack trace is:

      Suppressed: java.lang.RuntimeException: cannot translate call DATE_PART($t1, $t2)
      		at org.apache.calcite.adapter.enumerable.RexToLixTranslator.visitCall(RexToLixTranslator.java:1160)
      		at org.apache.calcite.adapter.enumerable.RexToLixTranslator.visitCall(RexToLixTranslator.java:101)
      		at org.apache.calcite.rex.RexCall.accept(RexCall.java:189)
      

      According to the documentation DATE_PART is just an alias for EXTRACT, which is (mostly) implemented, so this should work.

      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: