Apache DataFusion SQL Query Engine
fix: typo for the builder error type (#24052)
Joseph Lenton7d31a095df00
diff --git a/datafusion/expr/src/logical_plan/builder.rs b/datafusion/expr/src/logical_plan/builder.rsindex 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"+ );+ }}