jacktengg opened a new pull request, #70204:
URL: https://github.com/apache/doris/pull/70204

   ### What problem does this PR solve?
   
   Issue Number: N/A
   
   Related PR: N/A
   
   Problem Summary:
   
   TIMESTAMPTZ input in a time zone gap loses its position within that gap. For 
example, New York skips from 01:59:59 to 03:00:00 on 2024-03-10. Doris converts 
local 02:30:00 to 03:00:00. The required result is 03:30:00, or 07:30:00 UTC.
   
   BE uses `cctz::convert`, which selects the transition instant for skipped 
local time. FE constant folding uses the same policy. Use the offset before the 
transition for TIMESTAMPTZ input instead. This moves the input forward by the 
actual gap length and keeps its fraction.
   
   Apply this policy to strict and fallback string parsing, session-local 
strings, and DATETIMEV2/TIMESTAMP_NS casts. Use one FE helper for these 
TIMESTAMPTZ paths. Round the local value before the zone lookup so a carry that 
leaves the gap selects the correct offset.
   
   Minimal reproduction:
   
   ```sql
   SET time_zone = 'America/New_York';
   SET debug_skip_fold_constant = true;
   SELECT CAST('2024-03-10 02:30:00' AS TIMESTAMPTZ(6));
   -- Result: 2024-03-10 03:30:00.000000-04:00
   ```
   
   The regression test uses constant queries and inserts no rows. It covers gap 
boundaries, fractions, a 30-minute gap on Lord Howe, fixed offsets, repeated 
local time, and FE/BE agreement. Its output file was generated by the 
regression script.
   
   ### Release note
   
   TIMESTAMPTZ conversion now moves local input in a time zone gap forward by 
the actual gap length. For example, New York local 2024-03-10 02:30:00 now 
becomes 03:30:00-04:00.
   
   ### Check List (For Author)
   
   - Test:
       - Unit Test: 18 BE tests passed under ASAN. FE tests: 52 passed, 2 
existing tests skipped, no failures.
       - Regression test: 7 suites passed. These cover DST gaps and overlaps, 
casts, UTC functions, historical offsets, output boundaries, and TIMESTAMP_NS 
named-zone parsing.
       - Manual test: the reported query returned `03:30:00.000000-04:00`, 
`1800`, and `0`.
       - Build: `DISABLE_BE_JAVA_EXTENSIONS=ON ./build.sh --be -j32` and 
`./build.sh --fe -j16` passed.
       - Checks: clang-format 16, build hygiene, clang-tidy, and FE Checkstyle 
passed.
   - Behavior changed: Yes. TIMESTAMPTZ gap input retains its position within 
the gap.
   - Does this need documentation: No. The release note describes the corrected 
conversion policy.
   
   Validation commands:
   
   ```sh
   ./run-be-ut.sh --run --filter='TimeStampTzValueTest.*:CastTimeStampTzTest.*' 
-j32
   ./run-fe-ut.sh --run 
'org.apache.doris.nereids.trees.expressions.literal.TimestampTzLiteralTest,org.apache.doris.nereids.trees.expressions.literal.TimeStampNsLiteralTest,org.apache.doris.nereids.trees.expressions.literal.DateTimeLiteralTest'
   ./run-regression-test.sh --run -d datatype_p0/timestamptz -s 
test_timestamptz_dst_gap -forceGenOut
   ./run-regression-test.sh --run -d 
datatype_p0/timestamptz,datatype_p0/timestamp_ns -s 
test_timestamptz_dst_gap,test_timestamptz_dst_fold,test_timestamptz_cast,test_timestamptz_utc_functions,test_timestamptz_historical_offset,test_timestamptz_output_boundary,test_timestamp_ns_named_zone_gap
 -parallel 2
   ```
   
   Local build note: a temporary change to the ccache version print avoided 
SIGPIPE in `env.sh`. That change and test port settings were restored and are 
excluded from this PR.
   


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