[ https://issues.apache.org/jira/browse/CALCITE-1703?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15927956#comment-15927956 ]
Gangadhar Kairi edited comment on CALCITE-1703 at 3/16/17 2:20 PM: ------------------------------------------------------------------- I have fix working in my local, i shall create a pull request with patch. was (Author: gkairi): Since I have fix working in my local, i shall create a pull request with patch. > Query with BETWEEN or AGGREGATE functions on TIMESTAMP column throws > ClassCastException > --------------------------------------------------------------------------------------- > > Key: CALCITE-1703 > URL: https://issues.apache.org/jira/browse/CALCITE-1703 > Project: Calcite > Issue Type: Bug > Components: core > Affects Versions: 1.11.0 > Environment: Any > Reporter: Gangadhar Kairi > Assignee: Julian Hyde > Labels: Between, Function, Timestamp > > Getting below error while executing the query on timestamp columns with > BETWEEN or AGGREGATE function operator. > java.sql.SQLException: Error while executing SQL "select * from "DATE" where > "JOINTIMES" < '2017-03-16 18:04:07.034'": java.sql.Timestamp cannot be cast > to java.lang.Long > at org.apache.calcite.avatica.Helper.createException(Helper.java:56) > at org.apache.calcite.avatica.Helper.createException(Helper.java:41) > at > org.apache.calcite.avatica.AvaticaStatement.executeInternal(AvaticaStatement.java:156) > at > org.apache.calcite.avatica.AvaticaStatement.executeQuery(AvaticaStatement.java:218) > at > org.apache.calcite.test.CsvTest.testTimestampGTCheck(CsvTest.java:617) > 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.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:51) > at > com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:237) > at > com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70) > 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 com.intellij.rt.execution.application.AppMain.main(AppMain.java:147) > Caused by: java.lang.ClassCastException: java.sql.Timestamp cannot be cast to > java.lang.Long > at Baz$1$1.moveNext(Unknown Source) > at > org.apache.calcite.linq4j.Linq4j$EnumeratorIterator.<init>(Linq4j.java:664) > at org.apache.calcite.linq4j.Linq4j.enumeratorIterator(Linq4j.java:98) > at > org.apache.calcite.linq4j.AbstractEnumerable.iterator(AbstractEnumerable.java:33) > at org.apache.calcite.avatica.MetaImpl.createCursor(MetaImpl.java:89) > at > org.apache.calcite.avatica.AvaticaResultSet.execute(AvaticaResultSet.java:196) > at > org.apache.calcite.jdbc.CalciteResultSet.execute(CalciteResultSet.java:67) > I could able to reproduce this issues in CsvTests. > > Fire a test with query "select * from \"DATE\" where \"JOINTIMES\" BETWEEN '" > + from + "' and '" + to + "'" you will see test failing with exception. > Root cause and fix: > Timestamp datatype needs to be handled in the same way as the Date datatype. > In RexToLixTranslator.convert() method and in PhysTypeImpl.fieldReference() > method. -- This message was sent by Atlassian JIRA (v6.3.15#6346)