You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@datafusion.apache.org by gi...@apache.org on 2026/10/16 14:13:31 UTC

(datafusion) branch gh-readonly-queue/main/pr-26329-9f4b005e6e89a820e7c4d014d1ba1d1ca128c5a2 created (now 81824e8230)

This is an automated email from the ASF dual-hosted git repository.

github-merge-queue[bot] pushed a change to branch gh-readonly-queue/main/pr-26329-9f4b005e6e89a820e7c4d014d1ba1d1ca128c5a2
in repository https://gitbox.apache.org/repos/asf/datafusion.git


      at 81824e8230 fix: report OneOf signature mismatches as planning errors (#26329)

This branch includes the following new commits:

     new 81824e8230 fix: report OneOf signature mismatches as planning errors (#26329)

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datafusion.apache.org
For additional commands, e-mail: commits-help@datafusion.apache.org


(datafusion) 01/01: fix: report OneOf signature mismatches as planning errors (#26329)

Posted by gi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

github-merge-queue[bot] pushed a commit to branch gh-readonly-queue/main/pr-26329-9f4b005e6e89a820e7c4d014d1ba1d1ca128c5a2
in repository https://gitbox.apache.org/repos/asf/datafusion.git

commit 81824e8230c1189acd2243e1e4ce7aa6e8b38e82
Author: Singleton <13...@users.noreply.github.com>
AuthorDate: Fri Oct 16 14:13:08 2026 +0000

    fix: report OneOf signature mismatches as planning errors (#26329)
    
    ## Which issue does this PR close?
    
    Part of #20501.
    
    This is a deliberately narrow slice of that issue, and it is the slice a
    maintainer previously asked for: #21032 attempted this fix as a large
    change (it also reworked `sum`/`avg` diagnostics and the public
    `first_value`/`last_value`/`nth_value` arity contracts), was asked to be
    split up, and then went stale. This PR is **one behaviour change and
    nothing else**.
    
    ## Rationale for this change
    
    `get_valid_types_with_udf` reports "no `OneOf` branch matched" with
    `internal_err!`. Every alternative signature failing means the *caller*
    passed the wrong number or types of arguments — a user mistake — yet the
    user is told:
    
    > This issue was likely caused by a bug in DataFusion's code. Please
    help us to resolve this by filing a bug report in our issue tracker: ...
    
    So an ordinary SQL typo invites a bug report, and the failure surfaces
    as `Internal error: ...` even though nothing internal went wrong. The
    maintainer comment on #20070 named exactly this ("Can try to fix the
    display + internal error reference").
    
    ### Before / after
    
    `SELECT substr(1, 2)`
    
    Before:
    
    ```text
    Error during planning: Internal error: Function 'substr' failed to match any signature, errors: Error during planning: Function 'substr' requires String, but received Int64 (DataType: Int64).,Error during planning: Function 'substr' expects 3 arguments but received 2.
    This issue was likely caused by a bug in DataFusion's code. Please help us to resolve this by filing a bug report in our issue tracker: https://github.com/apache/datafusion/issues
    ```
    
    After:
    
    ```text
    Error during planning: Function 'substr' failed to match any signature, errors: Error during planning: Function 'substr' requires String, but received Int64 (DataType: Int64).,Error during planning: Function 'substr' expects 3 arguments but received 2.
    ```
    
    The message body, the candidate signatures, and the trailing "No
    function matches the given name and argument types ... You might need to
    add explicit type casts." line are all unchanged. Only the `Internal
    error` kind and the bug-report boilerplate are gone.
    
    ## What changes are included in this PR?
    
    - `datafusion/expr/src/type_coercion/functions.rs`: return `plan_err!`
    instead of `internal_err!` when every `OneOf` branch rejects the
    arguments. One line of behaviour change.
    - A unit test covering that failure. It mirrors `substr`'s real
    signature, so one branch fails on the argument type and the other on the
    arity.
    - Ten `sqllogictest` expectations that asserted the old user-visible
    text, in `array/array_range.slt`, `spark/math/round.slt`, `errors.slt`
    and `math.slt`.
    
    ## Are these changes tested?
    
    Yes.
    
    - The new unit test fails on `main` and passes with the change; `cargo
    test -p datafusion-expr --lib` is 282 passed, 0 failed.
    - `cargo fmt --all --check` is clean.
    - I audited every other expectation of this message. The remaining ones
    — `functions.slt`, `aggregate.slt`, `string_literal.slt`,
    `named_arguments.slt`, and one assertion in
    `datafusion/optimizer/src/analyzer/type_coercion.rs` — match on a
    substring that does not include the removed prefix, so they are
    unaffected. No `sqllogictest` file asserted the "This issue was likely
    caused by a bug..." boilerplate.
    
    I could not run the full `sqllogictest` suite locally (it needs a full
    `datafusion-core` build), so CI is the verification for the four updated
    `.slt` files.
    
    ## Scope
    
    Deliberately left out, to keep this reviewable:
    
    - the message is still verbose and still prefixes every branch error
    with `Error during planning:` — that is #19004;
    - `errors.join(",")` still runs the branch errors together without a
    separator, which is why the after-message reads `...(DataType:
    Int64).,Error during planning: ...`;
    - the arity phrasing suggested on #20070 (`log expects 1 to 2 arguments,
    got 3`) is a separate improvement.
    
    Happy to follow up on any of those in separate PRs.
---
 datafusion/expr/src/type_coercion/functions.rs           | 8 ++++++--
 datafusion/sqllogictest/test_files/array/array_range.slt | 8 ++++----
 datafusion/sqllogictest/test_files/errors.slt            | 2 +-
 datafusion/sqllogictest/test_files/math.slt              | 4 ++--
 datafusion/sqllogictest/test_files/spark/math/round.slt  | 6 +++---
 5 files changed, 16 insertions(+), 12 deletions(-)

diff --git a/datafusion/expr/src/type_coercion/functions.rs b/datafusion/expr/src/type_coercion/functions.rs
index ad7b086f39..1e4e7c0a3e 100644
--- a/datafusion/expr/src/type_coercion/functions.rs
+++ b/datafusion/expr/src/type_coercion/functions.rs
@@ -559,9 +559,13 @@ fn get_valid_types_with_udf<F: UDFCoercionExt>(
                 }
             }
 
-            // Every signature failed, return the joined error
+            // Every signature failed. That means the caller passed the wrong
+            // number or types of arguments, which is a user mistake rather than
+            // a bug in DataFusion, so report it as a planning error. Reporting it
+            // as an internal error told users to file a bug report for their own
+            // typo, and the caller appends the candidate signatures anyway.
             if res.is_empty() {
-                return internal_err!(
+                return plan_err!(
                     "Function '{}' failed to match any signature, errors: {}",
                     func.name(),
                     errors.join(",")
diff --git a/datafusion/sqllogictest/test_files/array/array_range.slt b/datafusion/sqllogictest/test_files/array/array_range.slt
index 022740239a..14d47021ce 100644
--- a/datafusion/sqllogictest/test_files/array/array_range.slt
+++ b/datafusion/sqllogictest/test_files/array/array_range.slt
@@ -244,17 +244,17 @@ select generate_series(arrow_cast('2021-01-01T00:00:00', 'Timestamp(Nanosecond,
 [2021-01-01T00:00:00-05:00, 2021-01-01T01:29:54.500-05:00, 2021-01-01T02:59:49-05:00, 2021-01-01T04:29:43.500-05:00, 2021-01-01T05:59:38-05:00]
 
 ## mixing types for timestamps is not supported
-query error DataFusion error: Error during planning: Internal error: Function 'generate_series' failed to match any signature
+query error DataFusion error: Error during planning: Function 'generate_series' failed to match any signature
 select generate_series(arrow_cast('2021-01-01T00:00:00', 'Timestamp(Nanosecond, Some("-05:00"))'), DATE '2021-01-02', INTERVAL '1' HOUR);
 
 ## mixing types not allowed even if an argument is null
-query error DataFusion error: Error during planning: Internal error: Function 'generate_series' failed to match any signature
+query error DataFusion error: Error during planning: Function 'generate_series' failed to match any signature
 select generate_series(TIMESTAMP '1992-09-01', DATE '1993-03-01', NULL);
 
-query error DataFusion error: Error during planning: Internal error: Function 'generate_series' failed to match any signature
+query error DataFusion error: Error during planning: Function 'generate_series' failed to match any signature
 select generate_series(1, '2024-01-01', '2025-01-02');
 
-query error DataFusion error: Error during planning: Internal error: Function 'generate_series' failed to match any signature
+query error DataFusion error: Error during planning: Function 'generate_series' failed to match any signature
 select generate_series('2024-01-01'::timestamp, '2025-01-02', interval '1 day');
 
 ## should return NULL
diff --git a/datafusion/sqllogictest/test_files/errors.slt b/datafusion/sqllogictest/test_files/errors.slt
index d9722dbd73..674e8f969b 100644
--- a/datafusion/sqllogictest/test_files/errors.slt
+++ b/datafusion/sqllogictest/test_files/errors.slt
@@ -124,7 +124,7 @@ from aggregate_test_100
 order by c9
 
 # WindowFunction wrong signature
-statement error DataFusion error: Error during planning: Internal error: Function 'nth_value' failed to match any signature
+statement error DataFusion error: Error during planning: Function 'nth_value' failed to match any signature
 select
 c9,
 nth_value(c5, 2, 3) over (order by c9) as nv1
diff --git a/datafusion/sqllogictest/test_files/math.slt b/datafusion/sqllogictest/test_files/math.slt
index 1b9fa63bf8..9ef5043264 100644
--- a/datafusion/sqllogictest/test_files/math.slt
+++ b/datafusion/sqllogictest/test_files/math.slt
@@ -175,10 +175,10 @@ NULL
 query error DataFusion error: Error during planning: 'round' does not support zero arguments
 SELECT round();
 
-query error Error during planning: Internal error: Function 'round' failed to match any signature
+query error Error during planning: Function 'round' failed to match any signature
 SELECT round(1, 2, 3);
 
-query error Error during planning: Internal error: Function 'round' failed to match any signature
+query error Error during planning: Function 'round' failed to match any signature
 SELECT round('x');
 
 query error round decimal_places 2147483648 is out of supported i32 range
diff --git a/datafusion/sqllogictest/test_files/spark/math/round.slt b/datafusion/sqllogictest/test_files/spark/math/round.slt
index 9ea027dada..dc7bc139df 100644
--- a/datafusion/sqllogictest/test_files/spark/math/round.slt
+++ b/datafusion/sqllogictest/test_files/spark/math/round.slt
@@ -593,13 +593,13 @@ set datafusion.execution.enable_ansi_mode = false;
 # -------------------------------------------------------------------
 
 # round(string) should fail
-query error Error during planning: Internal error: Function 'round' failed to match any signature
+query error Error during planning: Function 'round' failed to match any signature
 SELECT round('hello'::varchar);
 
 # round(boolean) should fail
-query error Error during planning: Internal error: Function 'round' failed to match any signature
+query error Error during planning: Function 'round' failed to match any signature
 SELECT round(true);
 
 # round(timestamp) should fail
-query error Error during planning: Internal error: Function 'round' failed to match any signature
+query error Error during planning: Function 'round' failed to match any signature
 SELECT round('2023-01-01T00:00:00'::timestamp);


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datafusion.apache.org
For additional commands, e-mail: commits-help@datafusion.apache.org