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

Julian Hyde commented on CALCITE-5164:
--------------------------------------

We should define multiple overloaded {{TIMESTAMP}} functions in {{class 
SqlLibraryOperators}}. Different functions would be enabled in different 
libraries. As long as the parser can read 1 or more comma-separated arguments, 
the validator will resolve the appropriate function based on the current 
library (or throw if that overload is not available in this library).

There's also the problem that the type that BigQuery calls {{TIMESTAMP}} 
actually maps to Calcite and ISO standard SQL's {{TIMESTAMP WITH LOCAL TIME 
ZONE}} but we shouldn't be solving that in this case.

> Planner#parser can't parse TIMESTAMP() function
> -----------------------------------------------
>
>                 Key: CALCITE-5164
>                 URL: https://issues.apache.org/jira/browse/CALCITE-5164
>             Project: Calcite
>          Issue Type: Bug
>          Components: babel
>    Affects Versions: 1.30.0
>            Reporter: Jiajun Xie
>            Assignee: Jiajun Xie
>            Priority: Minor
>
> Both core and babel will parse fail.
> {code:java}
>       FrameworkConfig coreConfig = Frameworks.newConfigBuilder().build();
>       Planner corePlanner = Frameworks.getPlanner(coreConfig);
>       corePlanner.parse("SELECT TIMESTAMP('2022-05-21 08:00:00'");
>       // Caused by: org.apache.calcite.sql.parser.babel.ParseException: 
> Incorrect syntax near the keyword 'TIMESTAMP' at line 1, column 8.
>       FrameworkConfig babelConfig = Frameworks.newConfigBuilder()
>           .parserConfig(SqlParser.Config.DEFAULT.withParserFactory(
>               SqlBabelParserImpl.FACTORY))
>           .build();
>       Planner babelPlanner = Frameworks.getPlanner(babelConfig);
>       babelPlanner.parse("SELECT TIMESTAMP('2022-05-21 08:00:00'");
>       // Caused by: org.apache.calcite.sql.parser.babel.ParseException: 
> Incorrect syntax near the keyword 'TIMESTAMP' at line 1, column 8
> {code}
> Here are some databases that support TIMESTAMP function.
>  - MySQL: 
> [https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_timestamp]
> {code:java}
> select timestamp('2022-05-21 08:00:00')
> // result
> timestamp('2022-05-21 08:00:00') 
> 2022-05-21 08:00:00
> {code}
>  - Derby: [https://docs.oracle.com/javadb/10.6.2.1/ref/rreftimestampfunc.html]
> Also, here are some databases that not support TIMESTAMP function:
>  - Oracle: 
> [https://docs.oracle.com/cd/B19306_01/server.102/b14225/ch4datetime.htm]
> {code:java}
> select timestamp('2022-05-21 08:00:00')
> //ORA-00923: FROM keyword not found where expected
> {code}
>  - SQL Server: 
> [https://docs.microsoft.com/en-us/sql/t-sql/functions/date-and-time-data-types-and-functions-transact-sql?view=sql-server-ver15]
> {code:java}
> select timestamp('2022-05-21 08:00:00')
> // Msg 195 Level 15 State 10 Line 1
> // 'timestamp' is not a recognized built-in function name.{code}
> Is it necessary for us to support it in babel module?



--
This message was sent by Atlassian Jira
(v8.20.7#820007)

Reply via email to