[
https://issues.apache.org/jira/browse/CALCITE-1041?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15082270#comment-15082270
]
Wei Hu commented on CALCITE-1041:
---------------------------------
udf is as below:
java.sql.Timestamp myfunc(Timestamp field)
SQL: select * from table where myFunc(field) in (cast('1970-01-01 00:00:00'),
cast('1997-02-01 00:00:00'));
calcite's generated code throw compile exception:
Error stack:
Caused by: java.lang.RuntimeException: Error while compiling generated Java
code:
...............
..............
at org.apache.calcite.avatica.Helper.wrap(Helper.java:37)
at
org.apache.calcite.adapter.enumerable.EnumerableInterpretable.toBindable(EnumerableInterpretable.java:108)
at
org.apache.calcite.prepare.CalcitePrepareImpl$CalcitePreparingStmt.implement(CalcitePrepareImpl.java:1044)
at org.apache.calcite.prepare.Prepare.prepareSql(Prepare.java:293)
at org.apache.calcite.prepare.Prepare.prepareSql(Prepare.java:188)
at
org.apache.calcite.prepare.CalcitePrepareImpl.prepare2_(CalcitePrepareImpl.java:669)
at
org.apache.calcite.prepare.CalcitePrepareImpl.prepare_(CalcitePrepareImpl.java:570)
at
org.apache.calcite.prepare.CalcitePrepareImpl.prepareSql(CalcitePrepareImpl.java:539)
at
org.apache.calcite.jdbc.CalciteConnectionImpl.parseQuery(CalciteConnectionImpl.java:173)
at
org.apache.calcite.jdbc.CalciteMetaImpl.prepareAndExecute(CalciteMetaImpl.java:504)
at
org.apache.calcite.avatica.AvaticaConnection.prepareAndExecuteInternal(AvaticaConnection.java:477)
at
org.apache.calcite.avatica.AvaticaStatement.executeInternal(AvaticaStatement.java:109)
... 33 more
Caused by: org.codehaus.commons.compiler.CompileException: Line 66, Column 101:
Cannot cast "long" to "java.sql.Timestamp"
at org.codehaus.janino.UnitCompiler.compileError(UnitCompiler.java:10092)
at org.codehaus.janino.UnitCompiler.compileGet2(UnitCompiler.java:3839)
at org.codehaus.janino.UnitCompiler.access$6400(UnitCompiler.java:183)
at org.codehaus.janino.UnitCompiler$10.visitCast(UnitCompiler.java:3246)
at org.codehaus.janino.Java$Cast.accept(Java.java:3802)
the Generated Code cause Exception :
if (v && v1 ==
org.apache.calcite.runtime.SqlFunctions.toLong((java.sql.Timestamp)
org.apache.calcite.avatica.util.DateTimeUtils.timestampStringToUnixDate("1986-12-18
00:00:00"))
> User-defined function that returns DATE or TIMESTAMP value
> ----------------------------------------------------------
>
> Key: CALCITE-1041
> URL: https://issues.apache.org/jira/browse/CALCITE-1041
> Project: Calcite
> Issue Type: Bug
> Reporter: Julian Hyde
> Assignee: Julian Hyde
>
> In CALCITE-986 comments there are reported problems with a UDF that returns a
> TIMESTAMP value. [~Droopyhu], since that case is resolved, can you add
> details here?
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)