Skip to content

Commit

Permalink
fix: avoid unnecessary column expr transform
Browse files Browse the repository at this point in the history
  • Loading branch information
ygf11 committed May 17, 2022
1 parent 01de32e commit 3fcd1eb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
11 changes: 6 additions & 5 deletions query/src/sql/exec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ mod data_schema_builder;
mod expression_builder;
mod util;

use std::ops::Not;
use std::sync::Arc;

use common_datavalues::DataField;
Expand Down Expand Up @@ -363,11 +364,11 @@ impl PipelineBuilder {
})?;
}

// Since transform has added or did, making group expressions as column expr is safe.
group_expressions = group_expressions
.iter()
.map(|expr| Expression::Column(expr.column_name()))
.collect();
// Since transform has been added, making group expressions as column expr is safe.
group_expressions
.iter_mut()
.filter(|expr| matches!(expr, Expression::Column(_)).not())
.for_each(|expr| *expr = Expression::Column(expr.column_name()));

// Process aggregation function with non-column expression, such as sum(3)
let pre_input_schema = input_schema.clone();
Expand Down
2 changes: 1 addition & 1 deletion query/src/sql/planner/plans/aggregate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub struct AggregatePlan {
pub group_items: Vec<Scalar>,
// aggregate scalar expressions, such as: sum(col1), count(*);
pub aggregate_functions: Vec<Scalar>,
// from distinct;
// True if the plan is generated from distinct, else the plan is a normal aggregate;
pub from_distinct: bool,
}

Expand Down

0 comments on commit 3fcd1eb

Please sign in to comment.