alamb commented on code in PR #18713:
URL: https://github.com/apache/datafusion/pull/18713#discussion_r2554091775
##########
datafusion/optimizer/src/optimize_unions.rs:
##########
@@ -105,6 +105,31 @@ fn extract_plans_from_union(plan: Arc<LogicalPlan>) ->
Vec<LogicalPlan> {
.into_iter()
.map(Arc::unwrap_or_clone)
.collect::<Vec<_>>(),
+ LogicalPlan::Projection(Projection {
Review Comment:
Am I right in understanding this change that it transforms
```
Projection
Union
to
```
Union
Projection
```
(aka it pushes the projection to each input of the union?)
Maybe some comments could help future readers
##########
datafusion/optimizer/src/optimize_unions.rs:
##########
@@ -331,6 +356,27 @@ mod tests {
")
}
+ #[test]
+ fn eliminate_nested_union_in_projection() -> Result<()> {
Review Comment:
Without the change in this PR the test fails like
```
────────────┬───────────────────────────────────────────────────────────────────
1 1 │ Union
2 2 │ Projection: id AS table_id, key, value
3 │- TableScan: table
4 │- Projection: id AS table_id, key, value
5 │- TableScan: table
3 │+ Union
4 │+ TableScan: table
5 │+ TableScan: table
6 6 │ TableScan: table
────────────┴───────────────────────────────────────────────────────────────────
```
In other words, the plan is left as
```
Union
Projection: id AS table_id, key, value
Union
TableScan: table
TableScan: table
TableScan: table
```
--
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]