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

Julian Hyde commented on CALCITE-6624:
--------------------------------------

[~dmsysolyatin], As you acknowledge, you have diverged a lot from the topic of 
this case. The topic is parsing, and in Calcite parsing does not have any 
knowledge of types or type systems (except for the fact that a few types, for 
example {{DECIMAL(10, 4)}} and {{BOOLEAN ARRAY}}, have their own syntax).

I support the proposal that Calcite should support constructors of the form 
{{<typename> <character literal>}}. I think it should do this in its native 
dialect, out of the box. Sure, it's what Postgres does, but as is often the 
case, what Postgres does makes sense and becomes the industry standard. Can you 
log a Jira case for this? Mark it as related to CALCITE-5424.

Back to the topic of this case. I think what you want goes beyond parsing. (For 
BigQuery, in addition to changes to the parser, we needed to make changes to 
the type system, and how literals were validated.) It would be helpful if you 
propose changes to components, and be specific. As you note, MySQL has some 
weird behaviors (like a TIMESTAMP literal becoming a DATETIME value) and I want 
to make sure that those behaviors don't become Calcite's default behavior.

> SqlParser should parse MySQL DATETIME type
> ------------------------------------------
>
>                 Key: CALCITE-6624
>                 URL: https://issues.apache.org/jira/browse/CALCITE-6624
>             Project: Calcite
>          Issue Type: Bug
>          Components: babel
>    Affects Versions: 1.37.0
>            Reporter: Dmitry Sysolyatin
>            Assignee: Dmitry Sysolyatin
>            Priority: Major
>              Labels: pull-request-available
>
> MySQL has two different data types: TIMESTAMP and DATETIME. The difference 
> between them is the range they support.
> From the documentation [1]
> ??The TIMESTAMP data type is used for values that contain both date and time 
> parts. TIMESTAMP has a range of '1970-01-01 00:00:01' UTC to '2038-01-19 
> 03:14:07' UTC.??
> ??The DATETIME type is used for values that contain both date and time parts. 
> MySQL retrieves and displays DATETIME values in 'YYYY-MM-DD hh:mm:ss' format. 
> The supported range is '1000-01-01 00:00:00' to '9999-12-31 23:59:59'.??
> Calcite's TIMESTAMP likely supports both ranges, and for unparse logic, the 
> MySQL dialect class always uses DATETIME because the TIMESTAMP range is a 
> subset of the DATETIME range.
> The only missing part is parsing the DATETIME datatype. For example
> {code:java}
> SELECT CAST(timestamp_field AS DATETIME) FROM <table>
> {code}
> [1] [https://dev.mysql.com/doc/refman/8.4/en/datetime.html]



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

Reply via email to