Skip to content

Resolve local timestamps using the offset for the input date and reject trailing text - #19540

Open
DaZuiZui wants to merge 1 commit into
apache:masterfrom
DaZuiZui:codex/fix-server-timestamp-parser
Open

DaZuiZui wants to merge 1 commit into
apache:masterfrom
DaZuiZui:codex/fix-server-timestamp-parser

Conversation

@DaZuiZui

@DaZuiZui DaZuiZui commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

Description

Split the shared timestamp parser change out of #19533 so its server behavior can be reviewed independently. DateTimeUtils.convertDatetimeStrToLong is used by tree SQL time literals, table SQL time literals and string-to-TIMESTAMP casts, and Pipe source start/end time parameters. The table CSV changes in #19533 depend on this parser.

An offset-free timestamp now uses the configured zone's rules for the date in the input. An explicit offset determines the instant directly. The parser also consumes the entire input, and conversion to nanoseconds avoids intermediate overflow at the lower limit.

Behavior changes

Input or condition Before After
2026-07-01T12:00:00 with session zone America/New_York, parsed in December Used December's -05:00 offset and stored 2026-07-01T17:00:00Z Uses July's -04:00 offset and stores 2026-07-01T16:00:00Z. A January noon still resolves to 17:00:00Z.
CAST('2026-12-04T03:33:17.083Zjunk' AS TIMESTAMP) Accepted as 2026-12-04T03:33:17.083Z after discarding junk The cast fails.
1970-01-01T00:00:00z or 1970-01-01T08:00:00+08:00:00 Rejected lowercase z and second-precision offsets Both resolve to epoch 0. Nonzero offset seconds are honored too, so 1970-01-01T08:00:15+08:00:15 also resolves to 0.
1999-02-29T00:00:00.000 in UTC The parser error quoted 1999-02-29T00:00:00.000+00:00 The parser error quotes the supplied 1999-02-29T00:00:00.000 and still explains that 1999 is not a leap year.
1677-09-21T00:12:43.145224192Z at nanosecond precision Multiplying whole epoch seconds overflowed before adding the fractional second Returns -9223372036854775808 (Long.MIN_VALUE). One nanosecond earlier, 1677-09-21T00:12:43.145224191Z, still raises ArithmeticException.

Validation

DateTimeUtilsTest covers the explicit offsets, invalid-date diagnostic and nanosecond boundary. IoTDBDatetimeFormatIT and IoTDBDatetimeFormatTableIT cover tree and table SQL time literals in winter and summer, casting a string column to TIMESTAMP in the same session zone, and rejecting a cast with trailing text.

The parser, statement generator and cast unit suites passed locally (88 passed, one existing ignored test). All 7 tests in the two integration test classes passed on a local standalone cluster (3 tree, 4 table). Spotless and the integration test selection check passed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant