You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Rui Wang (Jira)" <ji...@apache.org> on 2020/06/25 18:44:00 UTC
[jira] [Commented] (CALCITE-4091) Temporal Intervals improvements
[ https://issues.apache.org/jira/browse/CALCITE-4091?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17145739#comment-17145739 ]
Rui Wang commented on CALCITE-4091:
-----------------------------------
Interval type is a relatively complicated type in SQL. Let me see if I have some time to check SQL standard (and other vendors, if possible) about your posted cases.
> Temporal Intervals improvements
> --------------------------------
>
> Key: CALCITE-4091
> URL: https://issues.apache.org/jira/browse/CALCITE-4091
> Project: Calcite
> Issue Type: Improvement
> Components: core
> Affects Versions: 1.23.0
> Environment: {code:java}
>
> {code}
> 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)