Skip to content

fix: Fixed error handling for generate_series/range #16391

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

Merged
merged 15 commits into from
Jun 16, 2025

Conversation

jonathanc-n
Copy link
Contributor

Which issue does this PR close?

  • Closes #.

Rationale for this change

I was reviewing #16388 and noticed that the linked issue had an incorrect error message.

What changes are included in this PR?

Correct the argument that was being returned and made the message more verbose. Also did a driveby clean on some nits for other error messages

Are these changes tested?

Yes

@github-actions github-actions bot added sqllogictest SQL Logic Tests (.slt) functions Changes to functions implementation physical-plan Changes to the physical-plan crate labels Jun 13, 2025
_ => return plan_err!("First argument must be an integer literal"),
other => {
return plan_err!(
"Argument #{} must be an integer literal or null value, got {:?}",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is there a better way to word this, Argument #... seems awkward 🤷

Copy link
Contributor

Choose a reason for hiding this comment

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

I don' have any good suggestions

I do think the {:?} might be hard to read for complex expressions. Maybe you could change this to have the display name instead. Something like

Suggested change
"Argument #{} must be an integer literal or null value, got {:?}",
"Argument #{} must be an integer literal or null value, got {} ({:?})", expr_index, other, other,

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.

Looks good to me -- thank you @jonathanc-n

_ => return plan_err!("First argument must be an integer literal"),
other => {
return plan_err!(
"Argument #{} must be an integer literal or null value, got {:?}",
Copy link
Contributor

Choose a reason for hiding this comment

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

I don' have any good suggestions

I do think the {:?} might be hard to read for complex expressions. Maybe you could change this to have the display name instead. Something like

Suggested change
"Argument #{} must be an integer literal or null value, got {:?}",
"Argument #{} must be an integer literal or null value, got {} ({:?})", expr_index, other, other,

@jonathanc-n
Copy link
Contributor Author

Fixed @alamb! Should be good now

return plan_err!(
"Argument #{} must be an integer literal or null value, got {} ({:?})",
expr_index + 1,
other,
Copy link
Contributor

Choose a reason for hiding this comment

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

do we need to output other twice?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think @alamb's intention here was to have one less verbose and one with more information in case the user wants.

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah, I'm checking the message in the slt test

got Utf8\("foo"\) \(Literal\(Utf8\("foo"\), None\)\)

would be that self explanatory to keep the last one only?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah I think it would be, let me change that

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed!

@github-actions github-actions bot removed the physical-plan Changes to the physical-plan crate label Jun 15, 2025
@alamb alamb merged commit ad0c21f into apache:main Jun 16, 2025
28 checks passed
@alamb
Copy link
Contributor

alamb commented Jun 16, 2025

Thanks again @jonathanc-n

@jonathanc-n jonathanc-n deleted the fix-error branch June 16, 2025 23:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
functions Changes to functions implementation sqllogictest SQL Logic Tests (.slt)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants