You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Pavel Gubin (Jira)" <ji...@apache.org> on 2019/08/30 09:46:00 UTC

[jira] [Comment Edited] (CALCITE-3312) TIMESTAMPDIFF cannot be converted to SQL

    [ https://issues.apache.org/jira/browse/CALCITE-3312?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16919373#comment-16919373 ] 

Pavel Gubin edited comment on CALCITE-3312 at 8/30/19 9:45 AM:
---------------------------------------------------------------

Function call above is converted to 
{noformat}
CAST(/INT(Reinterpret(-(2017-01-01 00:00:00, 2016-01-01 00:00:00)), 12)):INTEGER NOT NULL
{noformat}
 in {{SqlToRelConverter}} which is then passed all the way through to {{RelToSqlConverter}} and to actual SQL serialization.


was (Author: pavel gubin):
Function call above is converted to {{CAST(/INT(Reinterpret(-(2017-01-01 00:00:00, 2016-01-01 00:00:00)), 12)):INTEGER NOT NULL}} in {{SqlToRelConverter}} which is then passed all the way through to {{RelToSqlConverter}} and to actual SQL serialization.

> TIMESTAMPDIFF cannot be converted to SQL
> ----------------------------------------
>
>                 Key: CALCITE-3312
>                 URL: https://issues.apache.org/jira/browse/CALCITE-3312
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>            Reporter: Pavel Gubin
>            Priority: Major
>
> The following test in {{RelToSqlConverterTest}}:
> {code}
>   @Test public void testTimestampDiff() {
>     String query = "SELECT {fn TIMESTAMPDIFF(SQL_TSI_YEAR,TIMESTAMP '2016-01-01 00:00:00', TIMESTAMP '2017-01-01 00:00:00')}";
>     String expected = "";
>     sql(query).ok(expected);
>   }
> {code}
> fails with:
> {noformat}
> java.lang.UnsupportedOperationException: class org.apache.calcite.sql.SqlSyntax$6: SPECIAL
> 	at org.apache.calcite.util.Util.needToImplement(Util.java:967)
> 	at org.apache.calcite.sql.SqlSyntax$6.unparse(SqlSyntax.java:116)
> 	at org.apache.calcite.sql.SqlOperator.unparse(SqlOperator.java:348)
> 	at org.apache.calcite.sql.SqlDialect.unparseCall(SqlDialect.java:402)
> 	at org.apache.calcite.sql.SqlCall.unparse(SqlCall.java:105)
> 	at org.apache.calcite.sql.SqlUtil.unparseBinarySyntax(SqlUtil.java:382)
> 	at org.apache.calcite.sql.SqlSyntax$3.unparse(SqlSyntax.java:65)
> 	at org.apache.calcite.sql.SqlOperator.unparse(SqlOperator.java:348)
> 	at org.apache.calcite.sql.SqlDialect.unparseCall(SqlDialect.java:402)
> 	at org.apache.calcite.sql.SqlCall.unparse(SqlCall.java:108)
> 	at org.apache.calcite.sql.fun.SqlCastFunction.unparse(SqlCastFunction.java:174)
> 	at org.apache.calcite.sql.SqlDialect.unparseCall(SqlDialect.java:402)
> 	at org.apache.calcite.sql.SqlCall.unparse(SqlCall.java:108)
> 	at org.apache.calcite.sql.SqlNodeList.commaList(SqlNodeList.java:121)
> 	at org.apache.calcite.sql.SqlOperator.unparseListClause(SqlOperator.java:365)
> 	at org.apache.calcite.sql.SqlOperator.unparseListClause(SqlOperator.java:354)
> 	at org.apache.calcite.sql.SqlSelectOperator.unparse(SqlSelectOperator.java:152)
> 	at org.apache.calcite.sql.SqlDialect.unparseCall(SqlDialect.java:402)
> 	at org.apache.calcite.sql.SqlSelect.unparse(SqlSelect.java:230)
> 	at org.apache.calcite.sql.SqlNode.toSqlString(SqlNode.java:152)
> 	at org.apache.calcite.sql.SqlNode.toSqlString(SqlNode.java:157)
> 	at org.apache.calcite.rel.rel2sql.RelToSqlConverterTest.toSql(RelToSqlConverterTest.java:145)
> 	at org.apache.calcite.rel.rel2sql.RelToSqlConverterTest.access$100(RelToSqlConverterTest.java:77)
> 	at org.apache.calcite.rel.rel2sql.RelToSqlConverterTest$Sql.exec(RelToSqlConverterTest.java:3634)
> 	at org.apache.calcite.rel.rel2sql.RelToSqlConverterTest$Sql.ok(RelToSqlConverterTest.java:3609)
> 	at org.apache.calcite.rel.rel2sql.RelToSqlConverterTest.testTimestampDiff(RelToSqlConverterTest.java:1942)
> 	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:47)
> 	at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
> 	at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
> {noformat}



--
This message was sent by Atlassian Jira
(v8.3.2#803003)