jayzhan211 commented on code in PR #10493:
URL: https://github.com/apache/datafusion/pull/10493#discussion_r1600899609
##########
datafusion/optimizer/src/analyzer/count_wildcard_rule.rs:
##########
@@ -54,23 +56,37 @@ fn is_wildcard(expr: &Expr) -> bool {
}
fn is_count_star_aggregate(aggregate_function: &AggregateFunction) -> bool {
- matches!(
- &aggregate_function.func_def,
- AggregateFunctionDefinition::BuiltIn(
- datafusion_expr::aggregate_function::AggregateFunction::Count,
- )
- ) && aggregate_function.args.len() == 1
- && is_wildcard(&aggregate_function.args[0])
+ match aggregate_function {
+ AggregateFunction {
+ func_def: AggregateFunctionDefinition::UDF(udf),
+ args,
+ ..
+ } if udf.name() == "COUNT" && args.len() == 1 && is_wildcard(&args[0])
=> true,
+ AggregateFunction {
+ func_def:
+ AggregateFunctionDefinition::BuiltIn(
+
datafusion_expr::aggregate_function::AggregateFunction::Count,
+ ),
+ args,
+ ..
+ } if args.len() == 1 && is_wildcard(&args[0]) => true,
+ _ => false,
+ }
}
fn is_count_star_window_aggregate(window_function: &WindowFunction) -> bool {
- matches!(
- &window_function.fun,
+ let args = &window_function.args;
+ match window_function.fun {
WindowFunctionDefinition::AggregateFunction(
- datafusion_expr::aggregate_function::AggregateFunction::Count,
- )
- ) && window_function.args.len() == 1
- && is_wildcard(&window_function.args[0])
+ aggregate_function::AggregateFunction::Count,
+ ) if args.len() == 1 && is_wildcard(&args[0]) => true,
+ WindowFunctionDefinition::AggregateUDF(ref udaf)
+ if udaf.name() == "COUNT" && args.len() == 1 &&
is_wildcard(&args[0]) =>
Review Comment:
The name should follow what is defined in `Count` struct. case sensitive is
not needed, it is strictly comparing with `fn name()`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]