SEPURI-SAI-KRISHNA opened a new pull request, #29266:
URL: https://github.com/apache/flink/pull/29266

   ## What is the purpose of the change
   
   The time zone cache resolved ids with `TimeZone.getTimeZone(String)`, which 
returns GMT for anything it cannot parse. `CONVERT_TZ` therefore returned a 
converted-looking but wrong timestamp for an unrecognized zone, with no error 
and nothing logged. Zone ids are case sensitive, so a typo is enough:
   
   ```sql
   CONVERT_TZ('2024-01-01 12:00:00', 'UTC', 'America/New_York')  -- 2024-01-01 
07:00:00
   CONVERT_TZ('2024-01-01 12:00:00', 'UTC', 'america/new_york')  -- 2024-01-01 
12:00:00, wrong
   ```
   
   The same fallback also hit offset ids that `TimeZone.getTimeZone` does not 
understand, while the `GMT`-prefixed form worked:
   
   ```sql
   CONVERT_TZ('2024-01-01 12:00:00', 'UTC', '+08:00')     -- 12:00:00, expected 
20:00:00
   CONVERT_TZ('2024-01-01 12:00:00', 'UTC', 'GMT+08:00')  -- 20:00:00, correct
   ```
   
   `CONVERT_TZ` already returns NULL for an unparseable datetime and for a NULL 
zone, so the zone case was the odd one out.
   
   ## Brief change log
   
     - Resolve zone ids through `ZoneId.of(id, ZoneId.SHORT_IDS)` and return 
null from the cache when the id is not recognized.
     - `convertTz` resolves both zones up front and returns NULL if either is 
unrecognized.
     - Drop the two now-unused private helpers.
     - Add `testConvertTZWithUnrecognizedTimeZone` and 
`testConvertTZWithOffsetTimeZone` to `TemporalTypesTest`.
   
   ## Verifying this change
   
   This change added tests and can be verified as follows:
   
     - both new tests fail on master and pass with this change
     - the documented forms are unchanged: `America/Los_Angeles`, `PST`, 
`GMT-08:00`, `Etc/GMT+8` and `EST5EDT` all resolve to the same offsets as before
     - `+08:00` and `UTC+01:00` now convert correctly instead of being treated 
as GMT
   
   1299 tests green locally: `CastRulesTest` (745), `TimeFunctionsITCase` 
(514), `TemporalTypesTest` (40).
   
   ## 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): **no**. 
Resolution stays behind the existing per-thread cache; only unrecognized ids 
are not memoised, and they are an error path.
     - 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? **no**
     - If yes, how is the feature documented? **not applicable**
   
   This is a user-visible behaviour change: a query that previously returned a 
wrong timestamp for an unrecognized zone now returns NULL. A release note is 
filled in on FLINK-40731.
   
   ---
   
   ##### Was generative AI tooling used to co-author this PR?
   
   - [X] Yes (please specify the tool below)
   
   Generated-by: Claude Code (Claude Opus 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