haohuaijin commented on code in PR #8454:
URL: https://github.com/apache/arrow-datafusion/pull/8454#discussion_r1419900172
##########
datafusion/core/src/physical_optimizer/projection_pushdown.rs:
##########
@@ -245,12 +246,36 @@ fn try_swapping_with_streaming_table(
}
/// Unifies `projection` with its input (which is also a [`ProjectionExec`]).
-/// Two consecutive projections can always merge into a single projection.
fn try_unifying_projections(
projection: &ProjectionExec,
child: &ProjectionExec,
) -> Result<Option<Arc<dyn ExecutionPlan>>> {
let mut projected_exprs = vec![];
+ let mut column_ref_map: HashMap<Column, usize> = HashMap::new();
+
+ // Collect the column references usage in the outer projection.
+ projection.expr().iter().for_each(|(expr, _)| {
Review Comment:
We don't prevent `Column` and `Literal` push_down. We prevent other express
push_down, used to prevent multiple evaluation of an equal expression.
```rust
if column_ref_map.iter().any(|(column, count)| {
*count > 1 &&
!is_expr_trivial(&child.expr()[column.index()].0.clone())
}) {
return Ok(None);
}
```
--
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]