alamb commented on code in PR #11386:
URL: https://github.com/apache/datafusion/pull/11386#discussion_r1672702694
##########
datafusion/sqllogictest/test_files/union.slt:
##########
@@ -135,6 +135,21 @@ SELECT SUM(d) FROM (
----
5
+# three way union with aggregate and type coercion
Review Comment:
I verified that this test covers the fix by running this test without the
code changes and it fails as expected
```
Running "pg_compat/pg_compat_union.slt"
Running "union.slt"
External error: query failed: DataFusion error: External error: External
error: External error: Arrow error: Invalid argument error: RowConverter column
schema mismatch, expected Int32 got Int64
[SQL] SELECT c1, SUM(c2) FROM (
SELECT 1 as c1, 1::int as c2
UNION
SELECT 2 as c1, 2::int as c2
UNION
SELECT 3 as c1, COALESCE(3::int, 0) as c2
) as a
GROUP BY c1
at test_files/union.slt:139
Error: Execution("1 failures")
error: test failed, to rerun pass `-p datafusion-sqllogictest --test
sqllogictests`
```
##########
datafusion/optimizer/src/eliminate_nested_union.rs:
##########
@@ -60,7 +60,8 @@ impl OptimizerRule for EliminateNestedUnion {
let inputs = inputs
.into_iter()
.flat_map(extract_plans_from_union)
- .collect::<Vec<_>>();
+ .map(|plan| coerce_plan_expr_for_schema(&plan, &schema))
Review Comment:
This makes sense -- that the children were not all coerced with respect to
the outermost union schema but rather with respect to the inner one.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]