[
https://issues.apache.org/jira/browse/CALCITE-4407?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17235751#comment-17235751
]
Julian Hyde commented on CALCITE-4407:
--------------------------------------
bq. I would suggest to strength the SqlCall of all the SqlNode instances to
return a specific SqlOperator, it always needs to implement the #createCall
correctly.
Not quite all {{SqlNode}} sub-classes; only sub-classes of {{SqlCall}}. There
are 40 concrete sub-classes of {{SqlCall}}. Each of those should have an
operator that overrides {{SqlOperator.createCall}}. About half of them do.
It shouldn't be too much effort to implement the other 20 or so cases.
By the way, I am trying to avoid sub-classing {{SqlOperator}} these days.
(There are many orthogonal reasons why one would want to sub-class an operator,
and it's a pain to have to re-implement all of the methods because you want to
refine just one.) So, we should consider adding a factory object to
{{SqlOperator}} to create {{SqlCall}} instances.
> Support unparse special syntax when operator is DELETE
> ------------------------------------------------------
>
> Key: CALCITE-4407
> URL: https://issues.apache.org/jira/browse/CALCITE-4407
> Project: Calcite
> Issue Type: Wish
> Reporter: xzh_dz
> Priority: Major
> Labels: pull-request-available
> Attachments: image-2020-11-18-16-12-18-340.png
>
> Time Spent: 50m
> Remaining Estimate: 0h
>
> This exception can be reproduced as below:
> SqlParserTest:
> {code:java}
> // code placeholder
> @Test void testSqlDeleteSqlBasicCallToString() throws Exception {
> final String sql0 = "delete from emps";
> final SqlNode sqlNode0 = getSqlParser(sql0).parseStmt();
> final SqlNode sqlNodeVisited0 = sqlNode0.accept(new SqlShuttle() {
> @Override public SqlNode visit(SqlIdentifier identifier) {
> return new SqlIdentifier(identifier.names,
> identifier.getParserPosition());
> }
> });
> System.out.println(sqlNodeVisited0.toString());
> }{code}
> Exception:
> {code:java}
> // code placeholder
> java.lang.UnsupportedOperationException: class
> org.apache.calcite.sql.SqlSyntax$7:
> SPECIALjava.lang.UnsupportedOperationException: class
> org.apache.calcite.sql.SqlSyntax$7: SPECIAL
> at org.apache.calcite.util.Util.needToImplement(Util.java:1080) at
> org.apache.calcite.sql.SqlSyntax$7.unparse(SqlSyntax.java:128) at
> org.apache.calcite.sql.SqlOperator.unparse(SqlOperator.java:377) at
> org.apache.calcite.sql.SqlDialect.unparseCall(SqlDialect.java:453) at
> org.apache.calcite.sql.SqlCall.unparse(SqlCall.java:103) at
> org.apache.calcite.sql.SqlNode.toSqlString(SqlNode.java:155)
> {code}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)