-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
Previously, the count wildcard is expanded by the CountWildCard analyzer rule which however was removed in the latest release 46.0. And the functionality is now moved to the ExprPlanner for planning aggregate functions, see #14689.
This functionality assumes users could get expression planners from the ContextProvider. See:
datafusion/datafusion/sql/src/expr/function.rs
Lines 374 to 379 in dfaede0
for planner in self.context_provider.get_expr_planners().iter() { | |
match planner.plan_aggregate(aggregate_expr)? { | |
PlannerResult::Planned(expr) => return Ok(expr), | |
PlannerResult::Original(expr) => aggregate_expr = expr, | |
} | |
} |
It's ok for the DataFusion native context provider SessionContextProvider
since it's able to retrieve expression planners from the SessionState. See:
datafusion/datafusion/core/src/execution/session_state.rs
Lines 1619 to 1627 in dfaede0
struct SessionContextProvider<'a> { | |
state: &'a SessionState, | |
tables: HashMap<ResolvedTableReference, Arc<dyn TableSource>>, | |
} | |
impl ContextProvider for SessionContextProvider<'_> { | |
fn get_expr_planners(&self) -> &[Arc<dyn ExprPlanner>] { | |
&self.state.expr_planners | |
} |
Unfortunately, user defined ContextProvider is unable to get expression planners from the SessionState, since the expr_planners
field is not exposed.
As a result, users who wish to utilize the default expression planners must import the FunctionRegistry
trait, which provides an expr_planners
method, and notably, SessionState implements this trait.
To address this issue, I propose adding a method to SessionState that returns a reference of the registered expression planners. This would provide a more straightforward and consistent way for user-defined ContextProvider implementations to access these planners without requiring importing the additional FunctionRegistry
trait.