MohamedAbdeen21 commented on code in PR #10868: URL: https://github.com/apache/datafusion/pull/10868#discussion_r1635299991
########## datafusion/optimizer/src/common_subexpr_eliminate.rs: ########## @@ -515,14 +522,15 @@ fn build_common_expr_project_plan( let mut fields_set = BTreeSet::new(); let mut project_exprs = common_exprs .into_iter() - .map(|(expr_id, expr)| { + .enumerate() + .map(|(index, (expr_id, expr))| { Review Comment: We were not on the same page. When I wrote the previous comment, I thought that the uppermost `#1` would be considered for the elimination alongside the `a+2`, thus producing the intermediate projection `#1 as #1, a + 2 as #2`. The only issue here is, ExprMask skips single columns and therefore `#1` column is never considered and creates this abomination of a plan ... ``` Projection: c1, c2, c3, c4\ Projection: #1 AS c1, #1 AS c2, #1 AS c3, #1 AS c4\ Projection: test.c + Int32(2) AS #1, test.c\ Projection: test.a + test.b AS #1, test.c\ TableScan: test ``` -- 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: github-unsubscr...@datafusion.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org For additional commands, e-mail: github-h...@datafusion.apache.org