Skip to content

Commit

Permalink
address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
peter-toth committed Jul 11, 2024
1 parent 17f33f7 commit b79a9a6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion datafusion/expr/src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1425,7 +1425,7 @@ impl Expr {
/// Adds references to all columns and their occurrence counts in the expression to
/// the map.
///
/// See [`Self::column_refs`] for details
/// See [`Self::column_refs_counts`] for details
pub fn add_column_ref_counts<'a>(&'a self, map: &mut HashMap<&'a Column, usize>) {
self.apply(|expr| {
if let Expr::Column(col) = expr {
Expand Down
6 changes: 4 additions & 2 deletions datafusion/optimizer/src/common_subexpr_eliminate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -899,7 +899,9 @@ struct ExprIdentifierVisitor<'a, 'n> {
random_state: &'a RandomState,
// a flag to indicate that common expression found
found_common: bool,
// if we are in a conditional branch
// if we are in a conditional branch. A conditional branch means that the expression
// might not be executed depending on the runtime values of other expressions, and
// thus can not be extracted as a common expression.
conditional: bool,
}

Expand Down Expand Up @@ -1053,7 +1055,7 @@ impl<'n> TreeNodeVisitor<'n> for ExprIdentifierVisitor<'_, 'n> {
} else {
*count += 1;
}
if *count > 1 || *count == 1 && *conditional_count > 0 {
if *count > 1 || (*count == 1 && *conditional_count > 0) {
self.found_common = true;
}
}
Expand Down

0 comments on commit b79a9a6

Please sign in to comment.