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

Will Noble commented on CALCITE-5164:
-------------------------------------

I've noticed an inconsistency between the semantics of {{TIMESTAMP()}} in 
[MySQL|https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_timestamp]
 and that in 
[BigQuery|https://cloud.google.com/bigquery/docs/reference/standard-sql/timestamp_functions#timestamp].
 In MySQL, the second argument could be a {{TIME}} to add to the first argument 
when the first is a {{{}DATE{}}}. In BigQuery, however, the second argument 
could be a time zone to apply to the first argument, which could be a 
{{{}DATE{}}}. How is the parser meant to handle situations like this where 
dialects have conflicting semantics? Is there a good existing example of how we 
might proceed?

> 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