Details
-
Sub-task
-
Status: Closed
-
Major
-
Resolution: Fixed
-
1.23.0
-
None
-
None
Description
Support interval expressions.
Standard SQL has only interval literals (e.g. INTERVAL '1' HOUR, INTERVAL -'1:2' HOUR TO MINUTE). Note that the 'value' part is a character literal and may contain formatting characters like ':'.
Interval expressions are a SQL extension present in MySQL and BigQuery. We support the syntax INTERVAL numericExpression timeUnit:
- the 'value' part is a numeric expression;
- timeUnit is a time unit (such as HOUR), not a time unit range (such as HOUR TO MINUTE);
- timeUnit may have precision, e.g. HOUR(2);
- timeUnit may be plural, e.g. HOURS, if SqlConformance.allowPluralTimeUnits (see
CALCITE-3383); - numeric literals and identifiers do not require parentheses, but other expressions require parentheses.
Examples:
- SELECT INTERVAL empno HOUR FROM Emp
- SELECT INTERVAL (empno * 2) MINUTE FROM Emp
- INTERVAL -3 YEAR
Attachments
Issue Links
- is related to
-
CALCITE-6114 RexExecutor fails on interval expressions with fractional second parts
- Open
- relates to
-
CALCITE-5659 Allow CAST in an INTERVAL definition
- Open
-
CALCITE-4089 In Babel, allow 'CAST(integer AS DATE)' even though it is illegal in Calcite SQL
- Closed
-
CALCITE-5776 Support for alternative Interval syntax
- Open