Skip to content

Commit 7886e29

Browse files
committed
Optimize single_column
1 parent 3024a8a commit 7886e29

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

datafusion/core/src/physical_optimizer/pruning.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -747,10 +747,13 @@ impl RequiredColumns {
747747
/// * `a > 5 OR b < 10` returns `None`
748748
/// * `true` returns None
749749
pub(crate) fn single_column(&self) -> Option<&phys_expr::Column> {
750-
let cols = self.iter().map(|(c, _s, _f)| c).collect::<HashSet<_>>();
751-
752-
if cols.len() == 1 {
753-
cols.iter().next().copied()
750+
if self.columns.windows(2).all(|w| {
751+
// check if all columns are the same (ignoring statistics and field)
752+
let c1 = &w[0].0;
753+
let c2 = &w[1].0;
754+
c1 == c2
755+
}) {
756+
self.columns.first().map(|r| &r.0)
754757
} else {
755758
None
756759
}

0 commit comments

Comments
 (0)