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: throw error on sub-day generate_series increments #11907

Merged
merged 6 commits into from
Aug 11, 2024

Conversation

tshauck
Copy link
Contributor

@tshauck tshauck commented Aug 9, 2024

Which issue does this PR close?

closes #11823

Rationale for this change

Currently, when trying to generate a series of dates with increments less than a day, the query will hang due to loss of precision (the step size becomes 0 relative to the Date32).

What changes are included in this PR?

  • Raise an error if attempting increment by less than a day
  • Refactor to use a ListBuilder
  • A few minor quick-fixes

Are these changes tested?

Yes, added a test.

Are there any user-facing changes?

Minor in that queries will now error when they would've hung forever.

@github-actions github-actions bot added the sqllogictest SQL Logic Tests (.slt) label Aug 9, 2024
@tshauck tshauck marked this pull request as ready for review August 9, 2024 16:27
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 very much @tshauck -- I think this code looks much nicer 👌 -- thank you

While reviewing this PR I had some more ideas for tests, so I took the liberty of writing them and pushing a few to your branch.

During this process, I actually think I found a regression introduced by this PR. Specifically, when generating intervals from arrays. If you try and run the tests in #11921 on this PR they all generate internal errors.

datafusion/functions-nested/src/range.rs Outdated Show resolved Hide resolved
let mut values = vec![];
let mut offsets = vec![0];
// values are date32s
let values_builder = Date32Builder::new();
Copy link
Contributor

Choose a reason for hiding this comment

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

👍 I think this is a very nice formulation

@tshauck tshauck force-pushed the raise-execution-error-on-gen-date branch from d547f5a to b63b7ba Compare August 9, 2024 20:23
@tshauck tshauck requested a review from alamb August 9, 2024 21:09
@tshauck
Copy link
Contributor Author

tshauck commented Aug 9, 2024

@alamb I rebased and updated the code to avoid those internal errors. I think root cause was me using .append_value w/ .append leading to more rows being returned than expected.

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.

Thanks @tshauck -- this looks great to me

@alamb alamb merged commit 7d6cd13 into apache:main Aug 11, 2024
24 checks passed
@tshauck tshauck deleted the raise-execution-error-on-gen-date branch August 11, 2024 14:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sqllogictest SQL Logic Tests (.slt)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

generate_series hangs indefinitely when providing a step of less than 1 day
2 participants