erratic-pattern commented on code in PR #10473:
URL: https://github.com/apache/datafusion/pull/10473#discussion_r1605592641
##########
datafusion/optimizer/src/common_subexpr_eliminate.rs:
##########
@@ -782,31 +819,31 @@ impl TreeNodeRewriter for CommonSubexprRewriter<'_> {
return Ok(Transformed::new(expr, false, TreeNodeRecursion::Jump));
}
- let (up_index, expr_id) = &self.id_array[self.down_index];
+ let (up_index, expr_id) = self.id_array[self.down_index];
self.down_index += 1;
// skip `Expr`s without identifier (empty identifier).
- if expr_id.is_empty() {
+ let Some(expr_id) = expr_id else {
return Ok(Transformed::no(expr));
- }
+ };
- let (counter, _) = self.expr_stats.get(expr_id).unwrap();
- if *counter > 1 {
+ let (count, _) = self.expr_stats.get(&expr_id).unwrap();
+ if *count > 1 {
// step index to skip all sub-node (which has smaller series
number).
while self.down_index < self.id_array.len()
- && self.id_array[self.down_index].0 < *up_index
+ && self.id_array[self.down_index].0 < up_index
{
self.down_index += 1;
}
let expr_name = expr.display_name()?;
- self.common_exprs.insert(expr_id.clone(), expr);
+ self.common_exprs.insert(expr_id, expr);
// Alias this `Column` expr to it original "expr name",
// `projection_push_down` optimizer use "expr name" to eliminate
useless
// projections.
// TODO: do we really need to alias here?
Review Comment:
My thoughts behind removing this TODO is that, with `explain verbose`, it is
easier to troubleshoot issues if instead of `common_1234` you can see
`common_1234 as <expr>` but maybe I am confused about how it works.
--
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]