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

Julian Hyde commented on CALCITE-5302:
--------------------------------------

If I recall correctly, there's a good reason that only FUNCTION syntax is 
allowed. Calls to such functions have to pass through the default parser, and 
the only UDFs the default parser can handle will be UDFs that have function 
syntax.

I suppose that the parser could be extended so that, without recompilation, it 
could recognize user-defined binary, prefix-unary and post-fix unary operators. 
It would be a considerable amount of work. The operators would have look like 
operators lexically (e.g. be made up of non-alphanumerics) and the parser would 
have to put them into their right place in the AST when they occur alongside 
other operators of higher or lower precedence.

> CalciteCatalogReader should support SqlSyntax other than FUNCTION
> -----------------------------------------------------------------
>
>                 Key: CALCITE-5302
>                 URL: https://issues.apache.org/jira/browse/CALCITE-5302
>             Project: Calcite
>          Issue Type: Bug
>            Reporter: Almog Gavra
>            Priority: Major
>
> As part of an effort to implement {{AT TIME ZONE}} functionality in a project 
> using a customer parser, I noticed that {{CalciteCatalogReader}} only allows 
> looking up operators that use {{{}SqlSyntax.FUNCTION{}}}: 
> [https://github.com/apache/calcite/blob/b16df019ed9fc7dba7392be9b758358c5a4e927b/core/src/main/java/org/apache/calcite/prepare/CalciteCatalogReader.java#L250-L257]
> {noformat}
> @Override public void lookupOperatorOverloads(final SqlIdentifier opName,
>     @Nullable SqlFunctionCategory category,
>     SqlSyntax syntax,
>     List<SqlOperator> operatorList,
>     SqlNameMatcher nameMatcher) {
>   if (syntax != SqlSyntax.FUNCTION) {
>     return;
>   }{noformat}
> This means that if we want to implement a different kind of syntax (e.g. in 
> the case of {{{}AT TIME ZONE{}}}, a SqlSyntax.BINARY) we cannot add that to 
> the reader and instead use {{{}ListSqlOperatorTable{}}}.
> I wanted to double check here and see whether that limitation is intentional 
> (and if so, what a suggested workaround is), or whether it's a bug that 
> should be fixed - which I'm happy to contribute.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to