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

LakeShen commented on CALCITE-6134:
-----------------------------------

IMO, `OperatorTable` is used in sql validate phase,and your exception stack is 
from sql parse phase.

DateAdd is the token in 
`calcite/babel/src/main/codegen/includes/parserImpls.ftl`,I think that it is 
already defined the grammar in this file,maybe you could extend this file for 
your logic,but why you need to create a custom function with name 'DATEADD'?

> Can't parse custom function with name 'DATEADD' in babel
> --------------------------------------------------------
>
>                 Key: CALCITE-6134
>                 URL: https://issues.apache.org/jira/browse/CALCITE-6134
>             Project: Calcite
>          Issue Type: Bug
>          Components: babel
>    Affects Versions: 1.36.0
>            Reporter: SimonAlexs
>            Priority: Major
>
> h4. *1. config*
>     I use SqlBabelParserImpl.FACTORY, and create SqlCustomOperatorTable.java 
> which extends org.apache.calcite.sql.fun.SqlStdOperatorTable.
> {code:java}
> Frameworks.newConfigBuilder()
>         .parserConfig(SqlParser.config()
>                 .withLex(Lex.MYSQL)
>                 .withCaseSensitive(false)
>                 .withConformance(SqlConformanceEnum.MYSQL_5)
>                 .withParserFactory(SqlBabelParserImpl.FACTORY)
>         )
>         .operatorTable(SqlCustomOperatorTable.instance()) {code}
>     In my SqlCustomOperatorTable, I define my custom function named with 
> 'DATEADD'. 
> h4. *2. error*
>     When i try the sql below, i got error as follows.
> {code:java}
> select dateadd(1698389166000, interval 1 year) {code}
> {code:java}
> Encountered "1698389166000" at line 1, column 16.
> Was expecting one of:
>     <IDENTIFIER> ...
>     <HYPHENATED_IDENTIFIER> ...
>     <QUOTED_IDENTIFIER> ...
>     <BACK_QUOTED_IDENTIFIER> ...
>     <BIG_QUERY_BACK_QUOTED_IDENTIFIER> ...
>     <BRACKET_QUOTED_IDENTIFIER> ...
>     <UNICODE_QUOTED_IDENTIFIER> ... {code}
>     Is 'DATEADD' a reserved word? Is there any method to let me create a 
> custom function with name 'DATEADD'?
>     Thanks for your help.



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

Reply via email to