You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Leonid Chistov (Jira)" <ji...@apache.org> on 2023/11/13 09:57:00 UTC
[jira] [Created] (CALCITE-6114) RexExecutor fails on interval expressions with fractional second parts
Leonid Chistov created CALCITE-6114:
---------------------------------------
Summary: RexExecutor fails on interval expressions with fractional second parts
Key: CALCITE-6114
URL: https://issues.apache.org/jira/browse/CALCITE-6114
Project: Calcite
Issue Type: Bug
Affects Versions: 1.35.0
Reporter: Leonid Chistov
Consider query like:
{code:java}
select interval 1.234 second as inr
from "scott".emp {code}
When trying to run expression reduce step on that query, RexExecutor fails with following error:
{code:java}
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) {code}
The reason why expression reduction step is required for such expressions is that interval expressions are internally translated to multiplication expressions like:
{code:java}
*(1.234:decimal32(4, 3), 1000:interval_second(2, 6)) {code}
In order to reproduce the issue, one can add following test case to the "misc.iq" file and run CoreQuidemTest:
{code:java}
!ok
# Interval expressions
select interval 1.234 second as inr
from "scott".emp;
+-------+------+------------+---------------------+
| INR |
+-------+------+------------+---------------------+
| 1.234 |
+-------+------+------------+---------------------+
(1 rows) {code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)