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

Change error type of invalid argument to PlanError rather than InternalError, remove misleading comments #7355

Merged
merged 5 commits into from
Aug 23, 2023

Conversation

alamb
Copy link
Contributor

@alamb alamb commented Aug 21, 2023

Which issue does this PR close?

related to #6108 and #7326
related to #7339

Rationale for this change

Inspired by @Weijun-H 's change in #7339 I was trying to clean up a comment I saw left over from #7339 I realized that not only are the comments in the rest of this file misleading the same bug also applied to several other functions.

Specifically, despite the comment claims that "this should have been covered earlier" it is clearly not and some of these error paths are directly user visible due to invalid queries (and thus should be plan errors, not internal errors). For example

DataFusion CLI v29.0.0
❯ select encode(1,2);
Internal error: The encode function can only accept utf8 or binary.. This was likely caused by a bug in DataFusion's code and we would welcome that you file an bug report in our issue tracker
❯ select array_concat(1,2);
Internal error: The array_concat function can only accept list as the args.. This was likely caused by a bug in DataFusion's code and we would welcome that you file an bug report in our issue tracker

What changes are included in this PR?

  1. Change to DataFusionError::Plan
  2. Update tests
  3. Update comments

Are these changes tested?

Yes

Are there any user-facing changes?

yes, better error messages

@github-actions github-actions bot added the logical-expr Logical plan and expressions label Aug 21, 2023
@github-actions github-actions bot added the sqllogictest SQL Logic Tests (.slt) label Aug 21, 2023
@alamb alamb changed the title Fix error type of invalid argument types, remove misleading comments Change error type of invalid argument to PlanError rather than InternalError, remove misleading comments Aug 21, 2023
@@ -737,8 +732,7 @@ impl BuiltinScalarFunction {
Utf8 => List(Arc::new(Field::new("item", Utf8, true))),
Null => Null,
_ => {
// this error is internal as `data_types` should have captured this.
return internal_err!(
return plan_err!(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

it is true that this is currently caught by higher up type checks, but I think it is better to throw a plan error here to tell users about the problem if something changes rather than throw a confusing internal error

Also given that this code is often copy/pasted it probably should default to returning a nice error message rather than an opaque one

@alamb
Copy link
Contributor Author

alamb commented Aug 22, 2023

Thank you @DDtKey !

@alamb
Copy link
Contributor Author

alamb commented Aug 23, 2023

@jackwener / @liukun4515 / @Dandandan -- here is an example of a PR that has been reviewed by contributors but that I can't merge due to the restriction put in place by #7226

Screenshot 2023-08-23 at 6 11 25 AM

What is the reason we want to require an approval from one of the committers prior to merging?

@alamb alamb merged commit bfe3e42 into apache:main Aug 23, 2023
@alamb
Copy link
Contributor Author

alamb commented Aug 23, 2023

Thank you @Dandandan

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
logical-expr Logical plan and expressions sqllogictest SQL Logic Tests (.slt)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants