[CALCITE-7559] SqlParserUtil.parseTimeTzLiteral should reject unknown…#4986
Merged
mihaibudiu merged 1 commit intoJun 4, 2026
Merged
Conversation
xuzifu666
reviewed
Jun 3, 2026
| } catch (DateTimeException e) { | ||
| String message = e.getMessage(); | ||
| if (message == null) { | ||
| message = "Error parsing TIME ZONE"; |
Member
There was a problem hiding this comment.
Improper capitalization => "Error parsing timezone"
Contributor
There was a problem hiding this comment.
I actually think this is fine, since this is how the SQL type is spelled
| message = "Error parsing TIME ZONE"; | ||
| } | ||
| throw SqlUtil.newContextException(pos, | ||
| RESOURCE.illegalLiteral("TIME WITH TIME ZONE", s, message)); |
mihaibudiu
approved these changes
Jun 3, 2026
mihaibudiu
left a comment
Contributor
There was a problem hiding this comment.
This is good, but please add the JIRA link as suggested. No need for a new commit, since this is a small PR, we'll just merge once you update.
xuzifu666
approved these changes
Jun 4, 2026
OldTruckDriver
force-pushed
the
parse-time-tz-validate-timezone
branch
from
June 4, 2026 08:56
906fec2 to
a500dda
Compare
Contributor
Author
|
Thanks! Added the JIRA link to the test case in the format used elsewhere. Amended into the existing commit. |
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



SqlParserUtil.parseTimeTzLiteral(...)usedTimeZone.getTimeZone(String), which silently falls back to GMT for unknown zone IDs, so invalidTIME WITH TIME ZONEliterals were accepted instead of rejected. The siblingparseTimestampTzLiteral(...)already validates the zone viaZoneId.of(...).This applies the same pattern as CALCITE-7527: validate the zone with
ZoneId.of(...)and throw aCalciteContextExceptionon an invalid zone, making the two paths consistent.Added
SqlParserUtilTest.testTimeWithTimeZonecovering a valid zone, an unknown zone, and a missing zone.