[ https://issues.apache.org/jira/browse/CALCITE-6377?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
ASF GitHub Bot updated CALCITE-6377: ------------------------------------ Labels: pull-request-available (was: ) > Time expression causes IllegalStateException > -------------------------------------------- > > Key: CALCITE-6377 > URL: https://issues.apache.org/jira/browse/CALCITE-6377 > Project: Calcite > Issue Type: Bug > Components: core > Affects Versions: 1.36.0 > Reporter: Mihai Budiu > Priority: Minor > Labels: pull-request-available > > The following SqlOperatorTest causes an exception: > {code:java} > final SqlOperatorFixture f = fixture(); > f.checkScalar("time '12:03:01' + interval '25' day", > "12:03:01", "TIME(0) NOT NULL"); > {code} > The exception is: > {code} > Caused by: java.lang.IllegalStateException: Unable to implement > EnumerableCalc(expr#0=[{inputs}], expr#1=[12:03:01], > expr#2=[2160000000:INTERVAL DAY], expr#3=[+($t1, $t2)], EXPR$0=[$t3]): > rowcount = 1.0, cumulative cost = {2.0 rows, 6.0 cpu, 0.0 io}, id = 20 > EnumerableValues(tuples=[[{ 0 }]]): rowcount = 1.0, cumulative cost = {1.0 > rows, 1.0 cpu, 0.0 io}, id = 13 > at > org.apache.calcite.adapter.enumerable.EnumerableRelImplementor.implementRoot(EnumerableRelImplementor.java:117) > at > org.apache.calcite.adapter.enumerable.EnumerableInterpretable.toBindable(EnumerableInterpretable.java:112) > at > org.apache.calcite.prepare.CalcitePrepareImpl$CalcitePreparingStmt.implement(CalcitePrepareImpl.java:1171) > at org.apache.calcite.prepare.Prepare.prepareSql(Prepare.java:326) > at org.apache.calcite.prepare.Prepare.prepareSql(Prepare.java:220) > at > org.apache.calcite.prepare.CalcitePrepareImpl.prepare2_(CalcitePrepareImpl.java:666) > at > org.apache.calcite.prepare.CalcitePrepareImpl.prepare_(CalcitePrepareImpl.java:519) > ... > Suppressed: java.lang.ArithmeticException: Value 2160000000 out of range > at > org.apache.calcite.linq4j.tree.Primitive.checkRoundedRange(Primitive.java:383) > at > org.apache.calcite.linq4j.tree.Primitive.numberValue(Primitive.java:412) > at > org.apache.calcite.linq4j.tree.Expressions.constant(Expressions.java:575) > at > org.apache.calcite.linq4j.tree.OptimizeShuttle.visit(OptimizeShuttle.java:305) > at > org.apache.calcite.linq4j.tree.UnaryExpression.accept(UnaryExpression.java:39) > at > org.apache.calcite.linq4j.tree.BinaryExpression.accept(BinaryExpression.java:47) > {code} > This seems to happen because the implementation insists in evaluating the > expression by converting the 25 days interval to milliseconds, which > overflows. However, adding a days interval to a time should be a noop. > Replacing 'days' with 'months', for example, works fine. -- This message was sent by Atlassian Jira (v8.20.10#820010)