Skip to content

fix: Fixed error handling for generate_series/range#16391

Merged
alamb merged 15 commits into
apache:mainfrom
jonathanc-n:fix-error
Jun 16, 2025
Merged

fix: Fixed error handling for generate_series/range#16391
alamb merged 15 commits into
apache:mainfrom
jonathanc-n:fix-error

Conversation

@jonathanc-n

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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,

@alamb alamb left a comment

Copy link
Copy Markdown
Contributor

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

Comment thread datafusion/functions-table/src/generate_series.rs Outdated
_ => 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
Copy Markdown
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
Copy Markdown
Contributor Author

Fixed @alamb! Should be good now

Comment thread datafusion/functions-table/src/generate_series.rs Outdated
return plan_err!(
"Argument #{} must be an integer literal or null value, got {} ({:?})",
expr_index + 1,
other,

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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

alamb commented Jun 16, 2025

Copy link
Copy Markdown
Contributor

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