Jiajun Xie created CALCITE-5164:
-----------------------------------

             Summary: 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


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