ErikBPF opened a new pull request, #7579:
URL: https://github.com/apache/datafusion-comet/pull/7579

   ## Which issue does this PR close?
   
   Closes #7224.
   
   ## Rationale for this change
   
   The native `CAST(string AS TIMESTAMP)` returns NULL for a zone offset with a 
non-zero seconds part, and raises `CAST_INVALID_INPUT` under ANSI mode, while 
Spark accepts those offsets through `ZoneId.of`. Arrow's `Tz` has minute 
precision, so the offset cannot be carried as a single zone.
   
   ## What changes are included in this PR?
   
   - `parse_sign_offset` accepts the seconds layouts `ZoneId.of` accepts: 
`+HH:MM:SS` and `+HHMMSS`. A short hour stays allowed, but once a seconds 
segment is present the minute and second must be two digits, which matches 
Spark's `getZoneId` normalization.
   - `extract_offset_suffix` returns the minute-precision zone plus a residual 
in seconds, and the parser subtracts the residual after applying the zone.
   - The residual adjustment uses `checked_sub`: an instant pushed below the 
representable range returns NULL (or the ANSI error) instead of wrapping.
   - `TIMESTAMP_NTZ` strips the zone as before, so it now parses these values 
instead of returning NULL.
   
   ## How are these changes tested?
   
   - Unit tests for the accepted and rejected layouts, including `+08:00:30`, 
`+080030`, `-01:30:15`, and the rejected `+8:0:3` and `+08:0:30`.
   - A boundary test for the residual subtraction at `i64::MIN` microseconds, 
in Legacy, Try and ANSI modes.
   - `CometNativeCastSuite` cases for both `TIMESTAMP` and `TIMESTAMP_NTZ` that 
compare against Spark, including one layout Spark rejects.
   


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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to