Skip to content

Commit 581c4e0

Browse files
committed
Don't pushdown constant filter below aggr
1 parent fd237f8 commit 581c4e0

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

‎datafusion/optimizer/src/push_down_filter.rs‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -817,6 +817,8 @@ impl OptimizerRule for PushDownFilter {
817817
let group_expr_columns = agg
818818
.group_expr
819819
.iter()
820+
// TODO: explain why and add failing cases
821+
.filter(|e| e.any_column_refs())
820822
.map(|e| Ok(Column::from_qualified_name(e.schema_name().to_string())))
821823
.collect::<Result<HashSet<_>>>()?;
822824

@@ -826,7 +828,9 @@ impl OptimizerRule for PushDownFilter {
826828
let mut push_predicates = vec![];
827829
for expr in predicates {
828830
let cols = expr.column_refs();
829-
if cols.iter().all(|c| group_expr_columns.contains(c)) {
831+
if !cols.is_empty()
832+
&& cols.iter().all(|c| group_expr_columns.contains(c))
833+
{
830834
push_predicates.push(expr);
831835
} else {
832836
keep_predicates.push(expr);

0 commit comments

Comments
 (0)