Skip to content

Commit b79a9a6

Browse files
committed
address review comments
1 parent 17f33f7 commit b79a9a6

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

datafusion/expr/src/expr.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1425,7 +1425,7 @@ impl Expr {
14251425
/// Adds references to all columns and their occurrence counts in the expression to
14261426
/// the map.
14271427
///
1428-
/// See [`Self::column_refs`] for details
1428+
/// See [`Self::column_refs_counts`] for details
14291429
pub fn add_column_ref_counts<'a>(&'a self, map: &mut HashMap<&'a Column, usize>) {
14301430
self.apply(|expr| {
14311431
if let Expr::Column(col) = expr {

datafusion/optimizer/src/common_subexpr_eliminate.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -899,7 +899,9 @@ struct ExprIdentifierVisitor<'a, 'n> {
899899
random_state: &'a RandomState,
900900
// a flag to indicate that common expression found
901901
found_common: bool,
902-
// if we are in a conditional branch
902+
// if we are in a conditional branch. A conditional branch means that the expression
903+
// might not be executed depending on the runtime values of other expressions, and
904+
// thus can not be extracted as a common expression.
903905
conditional: bool,
904906
}
905907

@@ -1053,7 +1055,7 @@ impl<'n> TreeNodeVisitor<'n> for ExprIdentifierVisitor<'_, 'n> {
10531055
} else {
10541056
*count += 1;
10551057
}
1056-
if *count > 1 || *count == 1 && *conditional_count > 0 {
1058+
if *count > 1 || (*count == 1 && *conditional_count > 0) {
10571059
self.found_common = true;
10581060
}
10591061
}

0 commit comments

Comments
 (0)