forked from apache/datafusion
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: sketch
AggregateFunctionPlanner
- Loading branch information
Showing
10 changed files
with
92 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
datafusion/functions-aggregate/src/aggregate_function_planner.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
use datafusion_expr::{ | ||
expr, lit, | ||
planner::{PlannerResult, RawAggregateFunction, UserDefinedSQLPlanner}, | ||
Expr, | ||
}; | ||
|
||
pub struct AggregateFunctionPlanner; | ||
|
||
impl UserDefinedSQLPlanner for AggregateFunctionPlanner { | ||
fn plan_aggregate_function( | ||
&self, | ||
aggregate_function: RawAggregateFunction, | ||
) -> datafusion_common::Result<PlannerResult<RawAggregateFunction>> { | ||
let RawAggregateFunction { | ||
udf, | ||
args, | ||
distinct, | ||
filter, | ||
order_by, | ||
null_treatment, | ||
} = aggregate_function.clone(); | ||
|
||
if udf.name() == "count" && args.is_empty() { | ||
return Ok(PlannerResult::Planned(Expr::AggregateFunction( | ||
expr::AggregateFunction::new_udf( | ||
udf.clone(), | ||
vec![lit(1).alias("")], | ||
distinct, | ||
filter.clone(), | ||
order_by.clone(), | ||
null_treatment.clone(), | ||
), | ||
))); | ||
} | ||
|
||
Ok(PlannerResult::Original(aggregate_function.clone())) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters