Steven Talbot created CALCITE-4631:
--------------------------------------
Summary: sql->rel->sql bug with unparsing timestampdiff
Key: CALCITE-4631
URL: https://issues.apache.org/jira/browse/CALCITE-4631
Project: Calcite
Issue Type: Bug
Reporter: Steven Talbot
class org.apache.calcite.sql.SqlSyntax$7: SPECIAL
e.g. the following test in RelToSqlConverter.java demonstrates the end-to-end
problem:
{code:java}
@Test void testTimestampDiff() {
final String query = "select timestampdiff(day, a.\"hire_date\",
b.\"hire_date\") "
+ "from \"employee\" a join \"employee\" b using (\"employee_id\")";
final String expected = "TBD, can't get it to generate right now";
sql(query).ok(expected);
}{code}
throws, top of stack:
{noformat}
class org.apache.calcite.sql.SqlSyntax$7: SPECIAL
java.lang.UnsupportedOperationException: class
org.apache.calcite.sql.SqlSyntax$7: SPECIAL
at org.apache.calcite.util.Util.needToImplement(Util.java:1101)
at org.apache.calcite.sql.SqlSyntax$7.unparse(SqlSyntax.java:129)
at org.apache.calcite.sql.SqlOperator.unparse(SqlOperator.java:383)
at org.apache.calcite.sql.SqlDialect.unparseCall(SqlDialect.java:455)
at org.apache.calcite.sql.SqlCall.unparse(SqlCall.java:123)
at org.apache.calcite.sql.SqlUtil.unparseBinarySyntax(SqlUtil.java:425)
at org.apache.calcite.sql.SqlSyntax$4.unparse(SqlSyntax.java:78)
at org.apache.calcite.sql.SqlOperator.unparse(SqlOperator.java:383)
at org.apache.calcite.sql.SqlDialect.unparseCall(SqlDialect.java:455)
at org.apache.calcite.sql.SqlCall.unparse(SqlCall.java:126)
at
org.apache.calcite.sql.fun.SqlCastFunction.unparse(SqlCastFunction.java:181)
at org.apache.calcite.sql.SqlDialect.unparseCall(SqlDialect.java:455)
at org.apache.calcite.sql.SqlCall.unparse(SqlCall.java:126)
at
org.apache.calcite.sql.pretty.SqlPrettyWriter$FrameImpl.list2(SqlPrettyWriter.java:1304)
at
org.apache.calcite.sql.pretty.SqlPrettyWriter$FrameImpl.list(SqlPrettyWriter.java:1284)
at
org.apache.calcite.sql.pretty.SqlPrettyWriter.list(SqlPrettyWriter.java:1081)
at
org.apache.calcite.sql.SqlSelectOperator.unparse(SqlSelectOperator.java:154)
at org.apache.calcite.sql.SqlDialect.unparseCall(SqlDialect.java:455)
at org.apache.calcite.sql.SqlSelect.unparse(SqlSelect.java:261)
at org.apache.calcite.sql.SqlNode.toSqlString(SqlNode.java:156)
at
org.apache.calcite.rel.rel2sql.RelToSqlConverterTest.toSql(RelToSqlConverterTest.java:216){noformat}
>From the debugger, it looks like a SqlKind.REINTERPRET operator gets generated
>by the SqlToRelConverter, and nothing knows how to handle that unparsing to
>SQL.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)