This is an automated email from the ASF dual-hosted git repository.
alamb 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 ca59c72183 Ensure schema and data have the same size (#13264)
ca59c72183 is described below
commit ca59c72183b45db3da56ec40db213b93980c5850
Author: Dmitrii Blaginin <[email protected]>
AuthorDate: Wed Nov 6 11:33:24 2024 +0000
Ensure schema and data have the same size (#13264)
---
datafusion/expr/src/logical_plan/builder.rs | 2 +-
datafusion/sqllogictest/test_files/errors.slt | 7 +++++++
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/datafusion/expr/src/logical_plan/builder.rs
b/datafusion/expr/src/logical_plan/builder.rs
index b7839c4873..790fc508d4 100644
--- a/datafusion/expr/src/logical_plan/builder.rs
+++ b/datafusion/expr/src/logical_plan/builder.rs
@@ -218,7 +218,7 @@ impl LogicalPlanBuilder {
if values.is_empty() {
return plan_err!("Values list cannot be empty");
}
- let n_cols = values[0].len();
+ let n_cols = schema.fields().len();
if n_cols == 0 {
return plan_err!("Values list cannot be zero length");
}
diff --git a/datafusion/sqllogictest/test_files/errors.slt
b/datafusion/sqllogictest/test_files/errors.slt
index da46a7e5e6..8910442755 100644
--- a/datafusion/sqllogictest/test_files/errors.slt
+++ b/datafusion/sqllogictest/test_files/errors.slt
@@ -137,3 +137,10 @@ select 1 group by substr('');
# Error in filter should be reported
query error Divide by zero
SELECT c2 from aggregate_test_100 where CASE WHEN true THEN 1 / 0 ELSE 0 END =
1;
+
+
+statement error DataFusion error: Error during planning: Inconsistent data
length across values list: got 4 values in row 0 but expected 2
+create table records (timestamp timestamp, value float) as values (
+ '2021-01-01 00:00:00', 1.0,
+ '2021-01-01 00:00:00', 2.0
+);
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]