Skip to content

fix(datetime): raise specific "Missing zone offset" error in timestamptz_to_nanos#3505

Open
vishnuprakaz wants to merge 1 commit into
apache:mainfrom
vishnuprakaz:fix/timestamptz-nanos-missing-zone-offset-error
Open

fix(datetime): raise specific "Missing zone offset" error in timestamptz_to_nanos#3505
vishnuprakaz wants to merge 1 commit into
apache:mainfrom
vishnuprakaz:fix/timestamptz-nanos-missing-zone-offset-error

Conversation

@vishnuprakaz

Copy link
Copy Markdown
Contributor

Rationale for this change

timestamptz_to_nanos should raise a clear "Missing zone
offset" error when it's given a nanosecond timestamp that has no
timezone. Today it can't: the check meant to detect a zone-less
timestamp accidentally tests the same pattern as the success
check right above it, so it never matches. The input falls
through to the vague "Invalid timestamp with zone" error
instead.

The fix is one line check the zone-less pattern
(ISO_TIMESTAMP_NANO) instead, mirroring
timestamptz_to_micros, which already does this correctly.
(Introduced in #1632.)

Are these changes tested?

Yes added tests covering the error messages for both
timestamptz_to_nanos and timestamp_to_nanos.

Are there any user-facing changes?

Only a clearer error message: a zone-less nanosecond timestamp
now reports "Missing zone offset" instead of "Invalid timestamp
with zone". No API changes.

  offset' error in timestamptz_to_nanos
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