Skip to content

Regression: count(*) does not work unless using default expression planners #15114

@niebayes

Description

@niebayes

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:

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:

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.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions