[
https://issues.apache.org/jira/browse/CALCITE-4545?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17307381#comment-17307381
]
Julian Hyde commented on CALCITE-4545:
--------------------------------------
Thanks, [~danny0405]. It seems that we have 4 facts that each seem reasonable,
but when combined lead to this bug:
* the parser should not refer to an operator table when parsing an identifier,
to see whether it is actually a nilary function
* after parsing, and before invoking the unparser, it is not necessary to
invoke the validator to 'fix up' the parse tree (e.g. converting identifiers to
nilary calls)
* the unparser, if enabled by appropriate options, can unparse identifiers with
quoting (e.g. backticks)
* quoted identifiers cannot be treated as nilary functions
Does anyone remember the rationale for the last one? I think the validator
should resolve the quoted identifier {{`CURRENT_ROW_TIMESTAMP`}} as a function
call if there is a nilary function "CURRENT_ROW_TIMESTAMP" in the operator
table.
> Unparse a new function of FUNCTION_ID syntax will be quoted
> -----------------------------------------------------------
>
> Key: CALCITE-4545
> URL: https://issues.apache.org/jira/browse/CALCITE-4545
> Project: Calcite
> Issue Type: Bug
> Components: core
> Reporter: Jark Wu
> Priority: Major
> Fix For: 1.26.0, 1.27.0
>
>
> In Flink, we would like to introduce some new functions of FUNCTION_ID
> syntax, e.g. {{CURRENT_ROW_TIMESTAMP}}. However, when unparsing this new
> function, we will get the quoted string {{`CURRENT_ROW_TIMESTAMP`}} which
> can't be executed anymore, because Calcite think it is a column reference.
> The root cause of it is {{org.apache.calcite.sql.SqlIdentifier#unparse}}
> calls {{org.apache.calcite.sql.SqlUtil#unparseSqlIdentifierSyntax}} where it
> uses a static Calcite {{SqlStdOperatorTable.instance()}} instead of a
> user-defined operator table. Therefore, it thinks it's not a sql function and
> unparse it with quotes.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)