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

RexExecutor fails on interval expressions with fractional second parts

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • 1.35.0
    • None
    • None
    • None

    Description

      Consider query like:

      select interval 1.234 second as inr
      from "scott".emp 

      When trying to run expression reduce step on that query, RexExecutor fails with following error:

      Exception in thread "main" java.lang.RuntimeException: while resolving method 'multiply[class java.math.BigDecimal, long]' in class class org.apache.calcite.runtime.SqlFunctions
          at org.apache.calcite.linq4j.tree.Types.lookupMethod(Types.java:318)
          at org.apache.calcite.linq4j.tree.Expressions.call(Expressions.java:449)
          at org.apache.calcite.adapter.enumerable.RexImpTable$BinaryImplementor.implementSafe(RexImpTable.java:2797)
          at org.apache.calcite.adapter.enumerable.RexImpTable$AbstractRexCallImplementor.genValueStatement(RexImpTable.java:3691)
          at org.apache.calcite.adapter.enumerable.RexImpTable$AbstractRexCallImplementor.implement(RexImpTable.java:3643)
          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)
          at org.apache.calcite.adapter.enumerable.RexToLixTranslator.visitLocalRef(RexToLixTranslator.java:1060)
          at org.apache.calcite.adapter.enumerable.RexToLixTranslator.visitLocalRef(RexToLixTranslator.java:101)
          at org.apache.calcite.rex.RexLocalRef.accept(RexLocalRef.java:77)
          at org.apache.calcite.adapter.enumerable.RexToLixTranslator.translate(RexToLixTranslator.java:253)
          at org.apache.calcite.adapter.enumerable.RexToLixTranslator.translate(RexToLixTranslator.java:247)
          at org.apache.calcite.adapter.enumerable.RexToLixTranslator.translateList(RexToLixTranslator.java:899)
          at org.apache.calcite.adapter.enumerable.RexToLixTranslator.translateProjects(RexToLixTranslator.java:201)
          at org.apache.calcite.adapter.enumerable.RexToLixTranslator.translateProjects(RexToLixTranslator.java:209) 

      The reason why expression reduction step is required for such expressions is that interval expressions are internally translated to multiplication expressions like:

      *(1.234:decimal32(4, 3), 1000:interval_second(2, 6)) 

      In order to reproduce the issue, one can add following test case to the "misc.iq" file and run CoreQuidemTest:

      !ok
      
      # Interval expressions
      select interval 1.234 second as inr
      from "scott".emp;
      +-------+------+------------+---------------------+
      | INR                                             |
      +-------+------+------------+---------------------+
      |  1.234                                          |
      +-------+------+------------+---------------------+
      (1 rows) 

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              lchistov1987 Leonid Chistov
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated: