You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Julian Hyde (Jira)" <ji...@apache.org> on 2020/06/25 20:58:00 UTC

[jira] [Updated] (CALCITE-4091) Extend INTERVAL literal syntax

     [ https://issues.apache.org/jira/browse/CALCITE-4091?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Julian Hyde updated CALCITE-4091:
---------------------------------
    Summary: Extend INTERVAL literal syntax  (was: Temporal Intervals improvements )

> Extend INTERVAL literal syntax
> ------------------------------
>
>                 Key: CALCITE-4091
>                 URL: https://issues.apache.org/jira/browse/CALCITE-4091
>             Project: Calcite
>          Issue Type: Improvement
>          Components: core
>    Affects Versions: 1.23.0
>            Reporter: Dan Cojocaru
>            Priority: Major
>
> Using this parser configuration: 
> {code:java}
> final FrameworkConfig config = Frameworks.newConfigBuilder() .parserConfig(SqlParser.configBuilder()
> .setConformance(MYSQL_5).setLex(MYSQL).build())
> .programs(Programs.ofRules(RULE_SET))
> .build();
> {code}
> *Case 1.* When parsing : 
> {code:java}
> SELECT DATE_ADD('2008-01-02', INTERVAL '31' WEEK)
> {code}
> fails with :
> {code:java}
> Encountered "WEEK" at line 1, column 45.
> {code}
> *Case 2.* When parsing:
> {code:java}
> SELECT DATE_ADD('2008-01-02', INTERVAL 31 DAY)
> {code}
> fails with
> {code:java}
> Encountered "INTERVAL 31" at line 1, column 31.
> {code}
> *Case 3*. When parsing
> {code:java}
> SELECT DATE_ADD('1970-01-01 12:00:00', INTERVAL CAST(6/4 AS DECIMAL(3,1)) HOUR_MINUTE)
> {code}
> or
> {code:java}
> SELECT DATE_ADD('2008-01-02', INTERVAL ((select 1 from dual) - '31') DAY);
> {code}
> fails with:
> {code:java}
> Encountered "INTERVAL CAST".    
> {code}
> {code:java}
> Encountered "INTERVAL (
> {code}
> Conclusion: INTERVAL is not fully supported: 
>  Case 1 : WEEK time unit argument is not allowed, for other seems to work fine
>  Case 2: expressions(expr) that are nonStrings are not allowed
>  Case 3: expressions(expr) are not allowed at all, only string expr are allowed
> According to MySql documentation [https://dev.mysql.com/doc/refman/8.0/en/expressions.html#temporal-intervals]
> all the above cases should be parsed with success.



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