Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
None
-
None
Description
Currently if you write TIMESTAMP '1969-07-20 22:56:00' it will be converted to a value of type TIMESTAMP. But if someone has set a custom type mapping where the name TIMESTAMP corresponds to the TIMESTAMP WITH LOCAL TIME ZONE type then the literal value should be of that type.
Custom type mappings are specified by defining user-defined types in the schema; see the method Schema.getType.
The contents of the string are currently handled by the parser. But in order to implement this change, the parsing of that string will need to be deferred to validation time (when the actual type is known, not just its name). This applies to literals TIMESTAMP, DATE, TIME, ARRAY, INTERVAL. The parser currently emits subclasses of SqlLiteral, namely SqlTimestampLiteral, SqlDateLiteral, SqlTimeLiteral, SqlArrayLiteral, SqlIntervalLiteral. But after this change, the parser will emit a new subclass, SqlUnknownLiteral (with identifying tag) instead of all of these.
Also as part of this change, add BigQuery-compatible literals:
- NUMERIC '0'
- BIGNUMERIC '0'
- DATETIME '2014-09-27 12:30:00.45'
- JSON 'json_formatted_data'
And a TIMESTAMP WITH LOCAL TIME ZONE literal:
- TIMESTAMP WITH LOCAL TIME ZONE '1969-07-21 02:56:00'
Attachments
Issue Links
- causes
-
CALCITE-5531 COALESCE throws ClassCastException
- Closed
- is related to
-
CALCITE-6710 Generalize typed literal constant syntax
- Open
- relates to
-
CALCITE-5446 Support TIMESTAMP WITH LOCAL TIME ZONE type in JDBC driver
- Open
-
CALCITE-6624 SqlParser should parse MySQL DATETIME type
- Open
-
CALCITE-6055 Customize handling of DateTimeTypeName based on type system
- Open
-
CALCITE-5508 Add constructor functions for DATE, TIME, TIMESTAMP, DATETIME
- Closed
-
CALCITE-5346 Support for type aliases
- Open
-
CALCITE-5870 Allow literals like DECIMAL '12.3' (consistent with Postgres)
- Closed
- links to