fix: avoid internal errors for OneOf signature mismatches#21032
Open
myandpr wants to merge 1 commit intoapache:mainfrom
Open
fix: avoid internal errors for OneOf signature mismatches#21032myandpr wants to merge 1 commit intoapache:mainfrom
myandpr wants to merge 1 commit intoapache:mainfrom
Conversation
Signed-off-by: yaommen <myanstu@163.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which issue does this PR close?
Rationale for this change
After #18769, unsupported calls such as
SUM(Boolean)started producing misleading internal errors.The immediate problem is that
TypeSignature::OneOfaggregates branch failures into anInternal error, which then becomes visible during planning together with internalTypeSignatureClass::...details.This PR is intentionally narrower than #20070 and only fixes that
TypeSignature::OneOfinternal-error path.What changes are included in this PR?
In
datafusion/expr/src/type_coercion/functions.rs:OneOfbranch matchesOneOfcase to returnFunction '...' failed to match any signatureas a planning error rather than an internal errorThis does not restore the older
Sum not supported for Booleanwording.That older message came from a more function-specific path, and this PR intentionally does not try to infer a single branch-specific error from
OneOf, since that can be misleading for overloaded functions with different arities or multiple valid type families.In those cases, returning a branch-specific error can report the wrong arity or an overly specific type requirement that only reflects one overload.
Are these changes tested?
Yes.
Added unit tests covering:
OneOfmismatches no longer returningInternal errorOneOfarity mismatches also returning a planning error rather than an internal errorUpdated sqllogictests for affected user-visible errors, including:
sum(Boolean)nth_value(...)substr(...)generate_series(...)Are there any user-facing changes?
Yes.
For failed
TypeSignature::OneOffunction calls, DataFusion now returns a normal planning error instead of anInternal error, while continuing to show the function call and candidate signatures.