Skip to content

Commit

Permalink
Optimize single_column
Browse files Browse the repository at this point in the history
  • Loading branch information
alamb committed Jul 17, 2024
1 parent 3024a8a commit 7886e29
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions datafusion/core/src/physical_optimizer/pruning.rs
Original file line number Diff line number Diff line change
Expand Up @@ -747,10 +747,13 @@ impl RequiredColumns {
/// * `a > 5 OR b < 10` returns `None`
/// * `true` returns None
pub(crate) fn single_column(&self) -> Option<&phys_expr::Column> {
let cols = self.iter().map(|(c, _s, _f)| c).collect::<HashSet<_>>();

if cols.len() == 1 {
cols.iter().next().copied()
if self.columns.windows(2).all(|w| {
// check if all columns are the same (ignoring statistics and field)
let c1 = &w[0].0;
let c2 = &w[1].0;
c1 == c2
}) {
self.columns.first().map(|r| &r.0)
} else {
None
}
Expand Down

0 comments on commit 7886e29

Please sign in to comment.