Skip to content

Commit 03a3eef

Browse files
refactor: drop filter logic in planner for aggregation
1 parent cf8bdc8 commit 03a3eef

File tree

1 file changed

+2
-16
lines changed
  • crates/proof-of-sql-planner/src

1 file changed

+2
-16
lines changed

crates/proof-of-sql-planner/src/plan.rs

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -176,31 +176,23 @@ fn projection_to_proof_plan(
176176
///
177177
/// # Panics
178178
/// The code should never panic
179-
#[expect(clippy::too_many_lines)]
180179
fn aggregate_to_proof_plan(
181180
input: &LogicalPlan,
182181
group_expr: &[Expr],
183182
aggr_expr: &[Expr],
184183
schemas: &impl SchemaAccessor,
185184
alias_map: &IndexMap<&str, &str>,
186185
) -> PlannerResult<DynProofPlan> {
186+
let input_plan = logical_plan_to_proof_plan(input, schemas)?;
187187
match input {
188188
// Only TableScan without fetch is supported
189189
LogicalPlan::TableScan(TableScan {
190190
table_name,
191-
filters,
192191
fetch: None,
193192
..
194193
}) => {
195194
let table_ref = table_reference_to_table_ref(table_name)?;
196195
let input_schema = schemas.lookup_schema(&table_ref);
197-
let input_plan = DynProofPlan::new_table(
198-
table_ref,
199-
input_schema
200-
.iter()
201-
.map(|(name, data_type)| ColumnField::new(name.clone(), *data_type))
202-
.collect(),
203-
);
204196
// Check that all of `group_expr` are columns and convert to `ColumnExprs`
205197
let group_by_exprs = group_expr
206198
.iter()
@@ -278,18 +270,12 @@ fn aggregate_to_proof_plan(
278270
alias: alias.clone(),
279271
})
280272
.collect::<Vec<_>>();
281-
// Filter
282-
let consolidated_filter_proof_expr = filters
283-
.iter()
284-
.map(|f| expr_to_proof_expr(f, &input_schema))
285-
.reduce(|a, b| Ok(DynProofExpr::try_new_and(a?, b?)?))
286-
.unwrap_or_else(|| Ok(DynProofExpr::new_literal(LiteralValue::Boolean(true))))?;
287273
DynProofPlan::try_new_aggregate(
288274
group_by_exprs,
289275
sum_expr,
290276
count_alias,
291277
input_plan,
292-
consolidated_filter_proof_expr,
278+
DynProofExpr::new_literal(LiteralValue::Boolean(true)),
293279
)
294280
.ok_or_else(|| PlannerError::UnsupportedLogicalPlan {
295281
plan: Box::new(input.clone()),

0 commit comments

Comments
 (0)