Skip to content

fix: accept a space before a utc offset in timestamp literals - #376

Open
anjeongkyun wants to merge 1 commit into
tekumara:mainfrom
anjeongkyun:fix/372-timestamp-offsets
Open

fix: accept a space before a utc offset in timestamp literals#376
anjeongkyun wants to merge 1 commit into
tekumara:mainfrom
anjeongkyun:fix/372-timestamp-offsets

Conversation

@anjeongkyun

Copy link
Copy Markdown
Contributor

Two parts, both from #372.

The space. Snowflake takes '2026-01-01 10:00:00 +09:00', duckdb reads the offset as a time zone name and raises Unknown TimeZone '+09:00'. It parses the same value fine without the space, so timestamp_offsets drops it for string literals cast to timestamp_tz or timestamp_ltz, which also covers to_timestamp_tz(). All four shapes Snowflake documents now work, and the offset is applied rather than ignored.

The 500. ConversionException wasn't in the list of duckdb exceptions translated in _execute, so anything it raised surfaced as a server error. Clients treat that as retryable: the python connector repeated one failing insert 333 times, the JDBC driver 7. It's now a ProgrammingError with 100035 / 22007, which is what a real account returns for an unrecognised timestamp.

Not covered: a literal in INSERT INTO t VALUES ('2026-01-01 10:00:00 +09:00'). There's no cast to hang the rewrite off, and knowing the target column type means reaching for the schema, which the transforms don't do. It fails with the error above rather than a 500 now. Happy to look at it if you have a preference for how, otherwise it seemed better left out of this change.

Rendering the stored offset back is still option 2, untouched here.

Refs #372

Snowflake takes '2026-01-01 10:00:00 +09:00', duckdb reads the offset as a time
zone name and raises Unknown TimeZone '+09:00'. It parses the same value without
the space, so the space is dropped for string literals cast to timestamp_tz or
timestamp_ltz.

ConversionException also wasn't translated in _execute, so it surfaced as a
server error. Clients retry those: the python connector repeated one failing
insert 333 times. It's now a ProgrammingError with 100035 / 22007, matching what
a real account returns.

Refs tekumara#372
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