Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
None
-
None
-
None
Description
In Babel, allow 'CAST(integer AS DATE)', even though it is illegal in Calcite SQL (and standard SQL).
Map it to valid standard SQL. BigQuery CAST(n AS DATE) is equivalent to Calcite DATE '1970-01-01' + n * INTERVAL '1' DAY.
Also, add functions DATE_FROM_UNIX_DATE(INTEGER), UNIX_SECONDS(TIMESTAMP), UNIX_MILLIS(TIMESTAMP), UNIX_MICROS(TIMESTAMP), TIMESTAMP_SECONDS(BIGINT), TIMESTAMP_MILLIS(BIGINT), TIMESTAMP_MICROS(BIGINT) in the BigQuery library. They are well-named and well-specified, so they might be useful to people working in dialects besides BigQuery. DATE_FROM_UNIX_DATE(0) should return DATE '1970-01-01'.
Attachments
Issue Links
- is blocked by
-
CALCITE-3224 New RexNode-to-Expression CodeGen Implementation
- Closed
- is related to
-
CALCITE-4134 Interval expressions
- Closed