File tree Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Expand file tree Collapse file tree 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>(
14821482/// [`TypeCoercionRewriter::coerce_union`]: https://docs.rs/datafusion-optimizer/latest/datafusion_optimizer/analyzer/type_coercion/struct.TypeCoercionRewriter.html#method.coerce_union
14831483/// [`coerce_union_schema`]: https://docs.rs/datafusion-optimizer/latest/datafusion_optimizer/analyzer/type_coercion/fn.coerce_union_schema.html
14841484pub 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+
14851494 // Temporarily use the schema from the left input and later rely on the analyzer to
14861495 // coerce the two schemas into a common one.
14871496
Original file line number Diff line number Diff line change @@ -103,11 +103,11 @@ CREATE TABLE orders(
103103);
104104
105105# 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
107107SELECT order_id FROM orders UNION SELECT customer_id, o_item_id FROM orders
108108
109109# 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
111111SELECT order_id FROM orders UNION ALL SELECT customer_id, o_item_id FROM orders
112112
113113# union_with_different_column_names()
You can’t perform that action at this time.
0 commit comments