raminqaf opened a new pull request, #29780:
URL: https://github.com/apache/flink/pull/29780

   ## What is the purpose of the change
   
   Backport of #29690 to release-2.4. A stored VARIANT timestamp casts only to 
its own type on release-2.4. With this commit it reaches the other datetime 
types the way a regular cast from its SQL type does, using the session time 
zone. It relies on the FLINK-41280 fixes for values before 1970, which are 
already on release-2.4 via #29726.
   
   With `table.local-time-zone` set to `Europe/Berlin` and `v_timestamp_ltz` 
holding the UTC instant `2024-01-01 23:30:00.123456`:
   
   | Query                                   | Before                           
                                      | After                     |
   
|-----------------------------------------|------------------------------------------------------------------------|---------------------------|
   | `CAST(v_timestamp_ltz AS TIMESTAMP(3))` | fails `Cannot cast a VARIANT 
TIMESTAMP_LTZ value to TIMESTAMP(3). ...` | `2024-01-02 00:30:00.123` |
   | `CAST(v_timestamp_ltz AS DATE)`         | fails `VariantTypeException: 
Expected type DATE but got TIMESTAMP_LTZ` | `2024-01-02`              |
   | `CAST(v_timestamp_ltz AS TIME(3))`      | fails `Cannot cast a VARIANT 
TIMESTAMP_LTZ value to TIME(3). ...`      | `00:30:00.123`            |
   
   ## Brief change log
   
     - Cherry-pick of 4cdc6d83a9d, applied without conflicts
   
   ## Verifying this change
   
   `CastRulesTest` (814 tests) and `FromVariantConverterTest` (43 tests) pass 
on this branch.
   
   ## Does this pull request potentially affect one of the following parts:
   
     - Dependencies (does it add or upgrade a dependency): no
     - The public API, i.e., is any changed class annotated with 
`@Public(Evolving)`: no
     - The serializers: no
     - The runtime per-record code paths (performance sensitive): yes, the 
VARIANT to datetime cast readers, as in #29690. A same-kind cast does the same 
work as before.
     - Anything that affects deployment or recovery: JobManager (and its 
components), Checkpointing, Kubernetes/Yarn, ZooKeeper: no
     - The S3 file system connector: no
   
   ## Documentation
   
     - Does this pull request introduce a new feature? yes
     - If yes, how is the feature documented? docs, the VARIANT cast table and 
a bullet in `data-types.md`, en and zh
   
   ---
   
   ##### Was generative AI tooling used to co-author this PR?
   
   - [X] Yes (please specify the tool below)
   
   Generated-by: Claude Code 2.1.317 (Claude Opus 5.5)
   


-- 
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