[
https://issues.apache.org/jira/browse/CALCITE-4091?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17161512#comment-17161512
]
Julian Hyde commented on CALCITE-4091:
--------------------------------------
I am working on sub-task CALCITE-4134 (interval expressions).
Someone could work on another sub-task to allow time units such as {{WEEK}} and
{{WEEKS}} in interval literals and interval expressions.
I don't think we should support MySQL time unit ranges such as {{HOUR_MINUTE}}.
Use instead {{HOUR TO MINUTE}}.
> 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
> Assignee: Julian Hyde
> 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)