wnob opened a new pull request, #3144:
URL: https://github.com/apache/calcite/pull/3144

   Always look in the root schema's type map when inserting a `CAST` for 
automatic type coercion.
   
   Other things to note:
   - I modified `SqlFunctions.toTimestampWithLocalTimeZone(String)`, which is 
only invoked by the rex-to-lix translator to convert strings to `TIMESTAMP WITH 
LOCAL TIME ZONE` values, such as during coercion or casting in general. The 
method was implemented to address 
[CALCITE-1947](https://issues.apache.org/jira/browse/CALCITE-1947) but requires 
an explicit time zone component in the string literal to avoid a 
string-index-out-of-bounds exception in the constructor for 
`TimestampWithTimeZoneString`, which was originally named 
`TimestampWithLocalTimeZoneString` but renamed after the discussion in the Jira 
ticket to avoid confusion. It appears the problem with the name was address but 
the problem of semantics remains; one cannot cast a string without an explicit 
time zone to a timestamp w/ LTZ. I added a fallback that invokes 
`DateTimeUtils.timestampStringToUnixDate()`, which is the same function invoked 
by the rex-to-lix translator to convert strings to regular `TIMESTAMP` values. 
This
  effectively assumes UTC for all timestamp w/ LTZ conversions lacking an 
explicit time zone. Currently looking into getting the proper zone out of the 
`DataContext` but having trouble figuring out where it gets passed in.
   - I set the default time zone for the BQ Quidem test to UTC, which causes 
`TIMESTAMP WITH LOCAL TIME ZONE` to assume UTC for the coercion of strings 
without an explicit time zone component (this is consistent with how BigQuery 
actually behaves).


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to