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

Danny Chen commented on CALCITE-3238:
-------------------------------------

Thanks [~jmxie], the new way to construct SqlDataTypeSpec is by constructing a 
SqlTypeNameSpec first, which has the precision, scale info you want (i.e. 
SqlBasicTypeNameSpec).

The SqlDataTypeSpec was usually in the sql parser or in the rel to sql (JDBC 
driver), so strictly to say, it is not a public API for use, so i did some 
refactoring directly instead of deprecating something when making this patch.

The original SqlDataTypeSpec hold all the things, the precision, the scale, the 
timezone, the nullability ... which just makes the logic too complex to keep 
right (many if else logic branches), so i refactor it with another component 
named SqlTypeNameSpec, the SqlTypeNameSpec holds the type name, precision and 
scale; the SqlDataTypeSpec holds a SqlTypeNameSpec with nullability and 
timezone info. This is like a composition instead of a inheritance which is 
more close to what we write a SQL in the parser: type name [precision, [scale]] 
nullability, timezone ..

> Support Time Zone suffix of DateTime types for SqlDataTypeSpec
> --------------------------------------------------------------
>
>                 Key: CALCITE-3238
>                 URL: https://issues.apache.org/jira/browse/CALCITE-3238
>             Project: Calcite
>          Issue Type: Sub-task
>          Components: core
>    Affects Versions: 1.20.0
>            Reporter: Danny Chen
>            Assignee: Danny Chen
>            Priority: Major
>              Labels: pull-request-available
>             Fix For: 1.21.0
>
>          Time Spent: 20m
>  Remaining Estimate: 0h
>
> This is the grammar copied from SQL-2011:
> {code:sql}
> <datetime type> ::=
>     DATE
>   | TIME [ <left paren> <time precision> <right paren> ] [ <with or without 
> time zone> ]
>   | TIMESTAMP [ <left paren> <timestamp precision> <right paren> ]
>         [ <with or without time zone> ]
> <with or without time zone> ::=
>       WITH TIME ZONE
>     | WITHOUT TIME ZONE
> <time precision> ::=
>    <time fractional seconds precision>
> <timestamp precision> ::=
>    <time fractional seconds precision>
> <time fractional seconds precision> ::=
>    <unsigned integer>
> {code}
> We extend this grammar to support "with local time zone" definition:
> {code:sql}
> time(0) with local time zone
> timestamp(0) with local time zone
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to