myandpr opened a new pull request, #21032:
URL: https://github.com/apache/datafusion/pull/21032

   ## Summary
   
   Fixes #20501.
   
   This PR changes `TypeSignature::OneOf` failures in the UDF coercion path 
from an `Internal error` into a normal planning error.
   
   Before this change, unsupported calls such as `SUM(Boolean)` could produce 
user-visible errors with:
   
   - `Internal error: Function 'sum' failed to match any signature`
   - internal `TypeSignatureClass::...` details
   - repeated branch-specific failure output
   
   After this change, DataFusion returns a normal planning error, and the 
existing planner diagnostics continue to show the function call and candidate 
signatures.
   
   ## What changed
   
   In `datafusion/expr/src/type_coercion/functions.rs`:
   
   - kept the existing success path when any `OneOf` branch matches
   - changed the all-failed `OneOf` case to return:
     - `Function '...' failed to match any signature`
     - as a planning error rather than an internal error
   
   This keeps the fix narrowly scoped to `TypeSignature::OneOf` error 
propagation.
   
   ## Why
   
   `#20501` reports that after `#18769`, unsupported aggregate calls such as 
`SUM(Boolean)` started producing misleading internal errors.
   
   The direct cause is that `TypeSignature::OneOf` aggregated branch failures 
into an `Internal error`, which then became visible during planning.
   
   This PR fixes that specific problem by making the failure user-facing and 
non-internal.
   
   ## Why this does not restore `Sum not supported for Boolean`
   
   The older message came from a more function-specific path.
   
   This PR intentionally does not try to infer a single "best" branch error 
from `OneOf`, because that can be misleading for overloaded functions with:
   
   - different arities, such as `substr(...)` or `nth_value(...)`
   - multiple valid type families, such as `sum(...)`
   
   In those cases, returning a branch-specific error can report the wrong arity 
or an overly specific type requirement that only reflects one overload.
   
   So this PR prefers a neutral and accurate planning error over a more 
specific but potentially incorrect branch-specific message.
   
   ## Tests
   
   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(...)`


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to