[
https://issues.apache.org/jira/browse/CALCITE-6062?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Will Noble updated CALCITE-6062:
--------------------------------
Description:
[This
function|https://github.com/apache/calcite/blob/ce88348960e95e1c13da850b4422b2f49f022d93/core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java#L4333]
that implements conversion from strings to {{TIMESTAMP WITH LOCAL TIME ZONE}}
uses {{TimestampWithTimeZoneString}}, which seems to have been a subtle mistake.
That function is only used to implement {{CAST}} expressions from strings to TS
w/ LTZ. Those expressions should allow for strings that do not have a time
zone, e.g. {{CAST('2023-10-19 12:00:00' AS TIMESTAMP WITH LOCAL TIME ZONE)}},
but it currently cannot because the {{TimestampWithTimeZoneString}} class
always expects a string with a time zone on the end.
In the case that no zone is included in the string, we should assume that the
string expresses a timestamp in the data context time zone by default.
was:
[This
function|https://github.com/apache/calcite/blob/ce88348960e95e1c13da850b4422b2f49f022d93/core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java#L4333]
that implements conversion from strings to {{TIMESTAMP WITH LOCAL TIME ZONE}}
uses {{TimestampWithTimeZoneString}}, which seems to have been a subtle mistake.
That function is only used to implement {{CAST}} expressions from strings to TS
w/ LTZ. Those expressions should allow for strings that do not have a time
zone, e.g. {{CAST('2023-10-19 12:00:00' AS TIMESTAMP WITH LOCAL TIME ZONE)}},
but it currently cannot because the {{TimestampWithTimeZoneString}} class
always expects a time zone string.
In the case that no zone is included in the string, we should assume that the
string expresses a timestamp in the data context time zone by defaul.
> Allow conversion of un-zoned timestamp strings to timestamp with local time
> zone
> --------------------------------------------------------------------------------
>
> Key: CALCITE-6062
> URL: https://issues.apache.org/jira/browse/CALCITE-6062
> Project: Calcite
> Issue Type: Bug
> Components: core
> Reporter: Will Noble
> Priority: Minor
>
> [This
> function|https://github.com/apache/calcite/blob/ce88348960e95e1c13da850b4422b2f49f022d93/core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java#L4333]
> that implements conversion from strings to {{TIMESTAMP WITH LOCAL TIME
> ZONE}} uses {{TimestampWithTimeZoneString}}, which seems to have been a
> subtle mistake.
> That function is only used to implement {{CAST}} expressions from strings to
> TS w/ LTZ. Those expressions should allow for strings that do not have a time
> zone, e.g. {{CAST('2023-10-19 12:00:00' AS TIMESTAMP WITH LOCAL TIME ZONE)}},
> but it currently cannot because the {{TimestampWithTimeZoneString}} class
> always expects a string with a time zone on the end.
> In the case that no zone is included in the string, we should assume that the
> string expresses a timestamp in the data context time zone by default.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)