Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve messages for INTERVAL literal semantic errors #23002

Merged
merged 2 commits into from
Nov 27, 2024

Conversation

takezoe
Copy link
Member

@takezoe takezoe commented Aug 11, 2024

Description

When an INTERVAL literal is invalid, ExpressionAnalyzer ignores an original error and always report as 'xxxx' is not a valid INTERVAL literal which is confusing in cases like below:

INTERVAL '12-10' YEAR TO DAY

In this case, YEAR TO DAY is invalid in the first place but still reported as '12-10' is not a valid INTERVAL literal.

It would be better to keep the original error message for better error reporting.

Additional context and related issues

Release notes

( ) This is not user-visible or is docs only, and no release notes are required.
( ) Release notes are required. Please propose a release note for me.
(x) Release notes are required, with the following suggested text:

# General
* Improved error messages for `INTERVAL` literals. ({issue}`issuenumber`)

Copy link

github-actions bot commented Sep 3, 2024

This pull request has gone a while without any activity. Tagging the Trino developer relations team: @bitsondatadev @colebow @mosabua

@github-actions github-actions bot added the stale label Sep 3, 2024
@hashhar hashhar removed the stale label Sep 6, 2024
@hashhar hashhar self-requested a review September 6, 2024 04:45
Copy link

This pull request has gone a while without any activity. Tagging the Trino developer relations team: @bitsondatadev @colebow @mosabua

@github-actions github-actions bot added the stale label Sep 27, 2024
@hashhar hashhar removed the stale label Sep 27, 2024
@hashhar
Copy link
Member

hashhar commented Sep 27, 2024

I'll take a look this Wednesday.

@@ -191,24 +191,24 @@ public static long convertToTimestampWithTimeZone(TimeZoneKey timeZoneKey, Strin
private static final int SECOND_FIELD = 6;
private static final int MILLIS_FIELD = 7;

private static final PeriodFormatter INTERVAL_DAY_SECOND_FORMATTER = cretePeriodFormatter(IntervalField.DAY, IntervalField.SECOND);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move the typo fix to a separate commit.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved to a dedicated commit.

@takezoe takezoe force-pushed the improve-interval-error branch from 162762f to 8dc209a Compare September 28, 2024 02:11
@takezoe
Copy link
Member Author

takezoe commented Sep 28, 2024

Would we allow cases where from and to are the same? like

INTERVAL '12' DAY TO DAY

This seems valid syntactically and Trino treats this in the same way as INTERVAL '12' DAY but it might not make sense semantically.

@hashhar
Copy link
Member

hashhar commented Oct 1, 2024

This seems valid syntactically

Doesn't seem to be true. See #23157 (comment).

From spec:

If to is specified then from SHALL be more significant than to.

@takezoe
Copy link
Member Author

takezoe commented Oct 2, 2024

Ah, it is a part of syntax rules so syntactically invalid. Will update this PR to raise an error in that case. Thanks.

@takezoe takezoe force-pushed the improve-interval-error branch 2 times, most recently from fb002ab to 2ac032e Compare October 4, 2024 16:58
@takezoe
Copy link
Member Author

takezoe commented Oct 5, 2024

@hashhar Updated the PR to raise an error when FROM and TO are the same. Could you take a look?

@takezoe
Copy link
Member Author

takezoe commented Oct 21, 2024

@hashhar ping

@takezoe
Copy link
Member Author

takezoe commented Nov 5, 2024

@martint @hashhar Does this have a chance to merge?

@hashhar
Copy link
Member

hashhar commented Nov 20, 2024

Sorry for the delay @takezoe, I'll do a final pass tomorrow (I skimmed it once more right now and don't see anything wrong) and merge.

Copy link
Member

@hashhar hashhar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM % commit boundaries

@takezoe takezoe force-pushed the improve-interval-error branch from 6eaca40 to 0733431 Compare November 22, 2024 16:17
@hashhar
Copy link
Member

hashhar commented Nov 22, 2024

Thanks @takezoe. I'll squash before merging.

@martint Do you want to take a look?

@takezoe
Copy link
Member Author

takezoe commented Nov 22, 2024

@hashhar Thank you! All commits except one for typo fix can be squashed.

@hashhar hashhar force-pushed the improve-interval-error branch from 5692073 to 6a6a3ac Compare November 22, 2024 18:54
@hashhar
Copy link
Member

hashhar commented Nov 27, 2024

Unrelated CI failure. Merging. Thanks @takezoe and sorry for the wait.

@hashhar hashhar merged commit 0b24c49 into trinodb:master Nov 27, 2024
90 of 91 checks passed
@github-actions github-actions bot added this to the 466 milestone Nov 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

3 participants