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

fix interval units parsing #12448

Merged
merged 4 commits into from
Sep 15, 2024
Merged

fix interval units parsing #12448

merged 4 commits into from
Sep 15, 2024

Conversation

samuelcolvin
Copy link
Contributor

@samuelcolvin samuelcolvin commented Sep 12, 2024

Which issue does this PR close?

Fixes #11271 (accidentally got closed by the companion PR apache/arrow-rs#6211).

Negative PR (at least by lines of Rust) 🎉 .

Rationale for this change

Use the much improved unit parsing logic now supported by arrow-rs, instead of a simple 'add "seconds"' hack

What changes are included in this PR?

Change interval expression parsing to use arrow-rs logic

Are these changes tested?

Yes

Are there any user-facing changes?

Improvements to interval expression functionality.

@github-actions github-actions bot added sql SQL Planner sqllogictest SQL Logic Tests (.slt) labels Sep 12, 2024
@samuelcolvin samuelcolvin changed the title fix interval units properly fix interval units parsing Sep 12, 2024
Comment on lines +600 to +601
# This is interpreted as "0 hours" with PostgreSQL, should be fixed with
query error DataFusion error: Arrow error: Parser error: Invalid input syntax for type interval: "5 day HOUR"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@samuelcolvin
Copy link
Contributor Author

@alamb if this passes I believe it's ready to merge despite the very minor regression, overall it's way better than what went before.

In particular expressions like interval '1s' are pretty common and without this, fail with a very ugly error:

Arrow error: Parser error: Invalid input syntax for type interval: "1s seconds"

Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

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

Thank you @samuelcolvin -- this looks like a great improvement to me. 🙏

@alamb
Copy link
Contributor

alamb commented Sep 15, 2024

This PR has a merge conflict now and it turns out there seems to have been a logical conflict with a few of the prior PRs that were merge. I will fix them in this PR

Screenshot 2024-09-15 at 8 05 45 AM

@alamb alamb merged commit 7bd7747 into apache:main Sep 15, 2024
24 checks passed
@alamb
Copy link
Contributor

alamb commented Sep 15, 2024

Thanks again @samuelcolvin

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sql SQL Planner sqllogictest SQL Logic Tests (.slt)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

interval cast has some problematic behaviour
2 participants