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

   ## Which issue does this PR close?
   
   Closes #14432  
   Relates to #14429
   
   ## Rationale for this change
   
   This PR adds a user-facing diagnostic when a SQL function is called with the 
wrong number of arguments, such as `sum(1, 2)`.
   
   Previously, this kind of error was surfaced only as a plain execution error. 
This change enriches the experience with a helpful span and message pointing 
directly to the problematic function call in the SQL query, improving developer 
experience and query debugging.
   
   ## What changes are included in this PR?
   
   - Adds a `Diagnostic` to the "wrong number of arguments" error
   - Extracts the span from the SQL parser and extends it if needed to cover 
the full function call
   - Adds a test in `sql/tests/cases/diagnostic.rs` validating both the message 
and the span
   
   ## Are these changes tested?
   
   Yes — a dedicated test has been added:  
   `test_wrong_number_of_arguments_sum`  
   It checks:
   - The diagnostic message
   - The span pointing to the correct part of the SQL query
   
   ## Are there any user-facing changes?
   
   Yes — end users will now see a clearer and contextual error message when 
using a function with an incorrect number of arguments.
   
   Before:
   
   Execution error: SUM expects exactly one argument
   
   After:
   
   sum function requires 1 argument, got 2
   
   With the span pointing to `sum(1, 2)` in the query.
   
   


-- 
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: github-unsubscr...@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org
For additional commands, e-mail: github-h...@datafusion.apache.org

Reply via email to