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

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


The following commit(s) were added to refs/heads/main by this push:
     new 7d31a095df fix: typo for the builder error type (#24052)
7d31a095df is described below

commit 7d31a095df009437f20f17e33f0efa712ccdad6c
Author: Joseph Lenton <[email protected]>
AuthorDate: Sat Aug 8 12:02:01 2026 +0100

    fix: typo for the builder error type (#24052)
    
    ## Which issue does this PR close?
    
    There is no ticket for this (I can open one if it is really needed).
    This is a very small nitpick QoL improvement, by changing the wording
    for an error.
    
    The typo fixes the phrase `... can't cast to got ...`, by adding a comma
    and making the rest a bit clearer.
    
    ## Rationale for this change
    
    - The error doesn't read as natural english with `... can't cast to got
    ...`.
    - I've added more clarity on what `got` and `for` are, by changing to
    `data of type` and `field of type`.
    
    ## What changes are included in this PR?
    
     - Rewording an error message.
    
    ## Are these changes tested?
    
     - I added a test to confirm the error message looks right.
    
    ## Are there any user-facing changes?
    
     - A user facing error message has changed.
     - No documentation changes are needed.
     - No API breaking changes are in this PR.
    
    ---------
    
    Co-authored-by: Nuno Faria <[email protected]>
---
 datafusion/expr/src/logical_plan/builder.rs | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/datafusion/expr/src/logical_plan/builder.rs 
b/datafusion/expr/src/logical_plan/builder.rs
index 1f32d9c6da..a3d2c6e17a 100644
--- a/datafusion/expr/src/logical_plan/builder.rs
+++ b/datafusion/expr/src/logical_plan/builder.rs
@@ -283,7 +283,7 @@ impl LogicalPlanBuilder {
                     && !can_cast_types(&data_type, field_type)
                 {
                     return exec_err!(
-                        "type mismatch and can't cast to got {} and {}",
+                        "Types don't match and no valid cast exists, received 
data of type {} for field of type {}",
                         data_type,
                         field_type
                     );
@@ -3034,4 +3034,25 @@ mod tests {
             ]
         );
     }
+
+    #[test]
+    fn test_values_with_schema_type_mismatch_error_message() {
+        // Date32 field, but the value is a Boolean, which cannot be cast to 
Date32.
+        let schema = Arc::new(
+            DFSchema::from_unqualified_fields(
+                vec![Field::new("a", DataType::Date32, false)].into(),
+                HashMap::new(),
+            )
+            .unwrap(),
+        );
+
+        let err = 
LogicalPlanBuilder::values_with_schema(vec![vec![lit(true)]], &schema)
+            .unwrap_err();
+
+        assert_eq!(
+            err.strip_backtrace(),
+            "Execution error: Types don't match and no valid cast exists, \
+         received data of type Boolean for field of type Date32"
+        );
+    }
 }


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

Reply via email to