You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Haisheng Yuan (Jira)" <ji...@apache.org> on 2019/11/14 21:58:00 UTC

[jira] [Resolved] (CALCITE-3494) Support decimal type aggregate in Interpreter

     [ https://issues.apache.org/jira/browse/CALCITE-3494?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Haisheng Yuan resolved CALCITE-3494.
------------------------------------
    Fix Version/s: 1.22.0
       Resolution: Fixed

Fixed in https://github.com/apache/calcite/commit/1667c0df5e46d9d6c393c4f855a304e4d1cfa2de. Thanks for the PR, [~yanlin-Lynn]!

> Support decimal type aggregate in Interpreter
> ---------------------------------------------
>
>                 Key: CALCITE-3494
>                 URL: https://issues.apache.org/jira/browse/CALCITE-3494
>             Project: Calcite
>          Issue Type: Improvement
>            Reporter: Wang Yanlin
>            Assignee: Wang Yanlin
>            Priority: Minor
>              Labels: pull-request-available
>             Fix For: 1.22.0
>
>          Time Spent: 20m
>  Remaining Estimate: 0h
>
> Using decimal type aggregate in Interpreter cause exception.
> Add this case in *InterpreterTest* to reproduce.
> {code:java}
> @Test public void testDecimalType() throws Exception {
>     final String sql = "select x, min(y), max(y), sum(y)\n"
>         + "from (values ('a', 1.2), ('a', 2.3), ('a', 15)) as t(x, y)\n"
>         + "group by x";
>     sql(sql).returnsRows("[a, 1.2, 15.0, 18.5]");
>   }
> {code}
> The stack trace is like this
> {noformat}
> java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
> 	at org.apache.calcite.interpreter.AggregateNode$UdaAccumulator.send(AggregateNode.java:662)
> 	at org.apache.calcite.interpreter.AggregateNode$AccumulatorList.send(AggregateNode.java:398)
> 	at org.apache.calcite.interpreter.AggregateNode$Grouping.send(AggregateNode.java:366)
> 	at org.apache.calcite.interpreter.AggregateNode.run(AggregateNode.java:96)
> 	at org.apache.calcite.interpreter.Interpreter.start(Interpreter.java:130)
> 	at org.apache.calcite.interpreter.Interpreter.enumerator(Interpreter.java:107)
> 	at org.apache.calcite.linq4j.AbstractEnumerable.iterator(AbstractEnumerable.java:33)
> 	at org.apache.calcite.test.InterpreterTest.assertRows(InterpreterTest.java:173)
> 	at org.apache.calcite.test.InterpreterTest.access$100(InterpreterTest.java:51)
> 	at org.apache.calcite.test.InterpreterTest$Sql.returnsRows(InterpreterTest.java:122)
> 	at org.apache.calcite.test.InterpreterTest$Sql.returnsRows(InterpreterTest.java:105)
> 	at org.apache.calcite.test.InterpreterTest.testDecimalType(InterpreterTest.java:441)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> 	at java.lang.reflect.Method.invoke(Method.java:498)
> 	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
> 	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
> 	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
> 	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
> 	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
> 	at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
> 	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
> 	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
> 	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
> 	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
> 	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
> 	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
> 	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
> 	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
> 	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
> 	at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
> 	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
> 	at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
> 	at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
> 	at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
> Caused by: java.lang.reflect.InvocationTargetException
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> 	at java.lang.reflect.Method.invoke(Method.java:498)
> 	at org.apache.calcite.interpreter.AggregateNode$UdaAccumulator.send(AggregateNode.java:660)
> 	... 35 more
> Caused by: java.lang.ClassCastException: java.math.BigDecimal cannot be cast to java.lang.Long
> 	at org.apache.calcite.interpreter.AggregateNode$NumericComparison.add(AggregateNode.java:494)
> 	... 40 more
> {noformat}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)