Skip to content

Commit

Permalink
Don't add filters to used columns
Browse files Browse the repository at this point in the history
  • Loading branch information
Dandandan committed Sep 27, 2023
1 parent 32dfbb0 commit 08d2943
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions datafusion/optimizer/src/push_down_projection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,12 @@ impl OptimizerRule for PushDownProjection {
if !scan.projected_schema.fields().is_empty() =>
{
let mut used_columns: HashSet<Column> = HashSet::new();
// filter expr may not exist in expr in projection.
// like: TableScan: t1 projection=[bool_col, int_col], full_filters=[t1.id = Int32(1)]
// projection=[bool_col, int_col] don't contain `ti.id`.
exprlist_to_columns(&scan.filters, &mut used_columns)?;
if projection_is_empty {
// filter expr may not exist in expr in projection.
// like: TableScan: t1 projection=[bool_col, int_col], full_filters=[t1.id = Int32(1)]
// projection=[bool_col, int_col] don't contain `ti.id`.
exprlist_to_columns(&scan.filters, &mut used_columns)?;

used_columns
.insert(scan.projected_schema.fields()[0].qualified_column());
push_down_scan(&used_columns, scan, true)?
Expand Down

0 comments on commit 08d2943

Please sign in to comment.