File tree 2 files changed +11
-2
lines changed
2 files changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -1482,6 +1482,15 @@ pub fn validate_unique_names<'a>(
1482
1482
/// [`TypeCoercionRewriter::coerce_union`]: https://docs.rs/datafusion-optimizer/latest/datafusion_optimizer/analyzer/type_coercion/struct.TypeCoercionRewriter.html#method.coerce_union
1483
1483
/// [`coerce_union_schema`]: https://docs.rs/datafusion-optimizer/latest/datafusion_optimizer/analyzer/type_coercion/fn.coerce_union_schema.html
1484
1484
pub fn union ( left_plan : LogicalPlan , right_plan : LogicalPlan ) -> Result < LogicalPlan > {
1485
+ if left_plan. schema ( ) . fields ( ) . len ( ) != right_plan. schema ( ) . fields ( ) . len ( ) {
1486
+ return plan_err ! (
1487
+ "UNION queries have different number of columns: \
1488
+ left has {} columns whereas right has {} columns",
1489
+ left_plan. schema( ) . fields( ) . len( ) ,
1490
+ right_plan. schema( ) . fields( ) . len( )
1491
+ ) ;
1492
+ }
1493
+
1485
1494
// Temporarily use the schema from the left input and later rely on the analyzer to
1486
1495
// coerce the two schemas into a common one.
1487
1496
Original file line number Diff line number Diff line change @@ -103,11 +103,11 @@ CREATE TABLE orders(
103
103
);
104
104
105
105
# union_different_num_columns_error() / UNION
106
- query error Error during planning: Union schemas have different number of fields: query 1 has 1 fields whereas query 2 has 2 fields
106
+ query error DataFusion error: Error during planning: UNION queries have different number of columns: left has 1 columns whereas right has 2 columns
107
107
SELECT order_id FROM orders UNION SELECT customer_id, o_item_id FROM orders
108
108
109
109
# union_different_num_columns_error() / UNION ALL
110
- query error Error during planning: Union schemas have different number of fields: query 1 has 1 fields whereas query 2 has 2 fields
110
+ query error DataFusion error: Error during planning: UNION queries have different number of columns: left has 1 columns whereas right has 2 columns
111
111
SELECT order_id FROM orders UNION ALL SELECT customer_id, o_item_id FROM orders
112
112
113
113
# union_with_different_column_names()
You can’t perform that action at this time.
0 commit comments