Skip to content

fix: avoid internal errors for OneOf signature mismatches#21032

Open
myandpr wants to merge 1 commit intoapache:mainfrom
myandpr:20501-oneof-error-message
Open

fix: avoid internal errors for OneOf signature mismatches#21032
myandpr wants to merge 1 commit intoapache:mainfrom
myandpr:20501-oneof-error-message

Conversation

@myandpr
Copy link

@myandpr myandpr commented Mar 18, 2026

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::OneOf aggregates branch failures into an Internal error, which then becomes visible during planning together with internal TypeSignatureClass::... details.

This PR is intentionally narrower than #20070 and only fixes that TypeSignature::OneOf internal-error path.

What changes are included in this PR?

In datafusion/expr/src/type_coercion/functions.rs:

  • keep the existing success path when any OneOf branch matches
  • change the all-failed OneOf case to return Function '...' failed to match any signature as a planning error rather than an internal error

This does not restore the older Sum not supported for Boolean wording.

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:

  • OneOf mismatches no longer returning Internal error
  • OneOf arity mismatches also returning a planning error rather than an internal error

Updated sqllogictests for affected user-visible errors, including:

  • sum(Boolean)
  • nth_value(...)
  • substr(...)
  • generate_series(...)

Are there any user-facing changes?

Yes.

For failed TypeSignature::OneOf function calls, DataFusion now returns a normal planning error instead of an Internal error, while continuing to show the function call and candidate signatures.

Signed-off-by: yaommen <myanstu@163.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Type signature matching errors are overly verbose and show internal details

1 participant