feat: attach Diagnostic to "invalid function argument types" error#23063
Open
choplin wants to merge 1 commit into
Open
feat: attach Diagnostic to "invalid function argument types" error#23063choplin wants to merge 1 commit into
choplin wants to merge 1 commit into
Conversation
Add span-aware Diagnostic to the error produced by `verify_function_arguments` when a scalar or aggregate function is called with argument types that do not match any supported signature. - Add `spans: Spans` field to `ScalarFunction` and `AggregateFunction` so function-call source locations survive planning and optimization. - Populate spans from sqlparser in the SQL planner when `collect_spans` is enabled. - Pass the function-call span to `Diagnostic::new_error` so downstream consumers can highlight the offending call site. - Update all pattern matches, tree-node transforms, and serialization code for the new field. Closes apache#14431
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?
Diagnosticto "invalid function argument types" error #14431Rationale for this change
When a scalar or aggregate function is called with argument types that don't match any supported signature (e.g.
SELECT sum('a')), the error message is a raw text dump with no source location. This PR attaches aDiagnosticso downstream consumers can highlight the offending call site in the original SQL query.What changes are included in this PR?
spans: Spansfield toScalarFunctionandAggregateFunctionso function-call source locations survive planning and optimization.collect_spansis enabled, following the same pattern used forColumn.verify_function_arguments, attach aDiagnosticwith:invalid argument type(s) for 'sum')called with argument type(s): Utf8)candidate function(s): sum(Decimal), sum(UInt64), ...)spansfield.Are there any user-facing changes?
No breaking API changes.
ScalarFunctionandAggregateFunctiongain aspans: Spansfield, butSpansis ignored inPartialEq/Hashand defaults to empty, so existing code usingScalarFunction::new_udf/AggregateFunction::new_udfis unaffected.When an error occurs, a diagnositc is attached in the error message.
Before (no
Diagnosticattached):After (same error message, with
Diagnosticnow attached):