Skip to content

Commit ca59c72

Browse files
authored
Ensure schema and data have the same size (#13264)
1 parent 6a02384 commit ca59c72

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

datafusion/expr/src/logical_plan/builder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ impl LogicalPlanBuilder {
218218
if values.is_empty() {
219219
return plan_err!("Values list cannot be empty");
220220
}
221-
let n_cols = values[0].len();
221+
let n_cols = schema.fields().len();
222222
if n_cols == 0 {
223223
return plan_err!("Values list cannot be zero length");
224224
}

datafusion/sqllogictest/test_files/errors.slt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,3 +137,10 @@ select 1 group by substr('');
137137
# Error in filter should be reported
138138
query error Divide by zero
139139
SELECT c2 from aggregate_test_100 where CASE WHEN true THEN 1 / 0 ELSE 0 END = 1;
140+
141+
142+
statement error DataFusion error: Error during planning: Inconsistent data length across values list: got 4 values in row 0 but expected 2
143+
create table records (timestamp timestamp, value float) as values (
144+
'2021-01-01 00:00:00', 1.0,
145+
'2021-01-01 00:00:00', 2.0
146+
);

0 commit comments

Comments
 (0)