Skip to content

Commit

Permalink
fix ci
Browse files Browse the repository at this point in the history
  • Loading branch information
Weijun-H committed Nov 29, 2023
1 parent fdad00b commit cb469eb
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 16 deletions.
10 changes: 10 additions & 0 deletions datafusion/expr/src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1631,6 +1631,16 @@ fn create_name(e: &Expr) -> Result<String> {
}
Ok(format!("{}({}){}", fun.name(), names.join(","), info))
}
AggregateFunctionDefinition::Name(name) => {
let mut name = create_function_name(name, *distinct, args)?;
if let Some(fe) = filter {
name = format!("{name} FILTER (WHERE {fe})");
};
if let Some(order_by) = order_by {
name = format!("{name} ORDER BY [{}]", expr_vec_fmt!(order_by));
};
Ok(name)
}
},
Expr::GroupingSet(grouping_set) => match grouping_set {
GroupingSet::Rollup(exprs) => {
Expand Down
8 changes: 6 additions & 2 deletions datafusion/optimizer/src/analyzer/count_wildcard_rule.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use crate::analyzer::AnalyzerRule;
use datafusion_common::config::ConfigOptions;
use datafusion_common::tree_node::{Transformed, TreeNode, TreeNodeRewriter};
use datafusion_common::Result;
use datafusion_expr::expr::{AggregateFunction, InSubquery};
use datafusion_expr::expr::{AggregateFunction, AggregateFunctionDefinition, InSubquery};
use datafusion_expr::expr_rewriter::rewrite_preserving_name;
use datafusion_expr::utils::COUNT_STAR_EXPANSION;
use datafusion_expr::Expr::ScalarSubquery;
Expand Down Expand Up @@ -144,7 +144,11 @@ impl TreeNodeRewriter for CountWildcardRewriter {
_ => old_expr,
},
Expr::AggregateFunction(AggregateFunction {
func_def: _,
func_def:
AggregateFunctionDefinition::BuiltIn {
fun: aggregate_function::AggregateFunction::Count,
name: _,
},
args,
distinct,
filter,
Expand Down
17 changes: 3 additions & 14 deletions datafusion/optimizer/src/single_distinct_to_groupby.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ fn is_single_distinct_agg(plan: &LogicalPlan) -> Result<bool> {
let mut aggregate_count = 0;
for expr in aggr_expr {
if let Expr::AggregateFunction(AggregateFunction {
func_def,
func_def: AggregateFunctionDefinition::BuiltIn { fun, name: _ },
distinct,
args,
filter,
Expand All @@ -86,19 +86,8 @@ fn is_single_distinct_agg(plan: &LogicalPlan) -> Result<bool> {
for e in args {
fields_set.insert(e.canonical_name());
}
} else {
match func_def {
AggregateFunctionDefinition::BuiltIn { fun, name: _ } => {
if !matches!(fun, Sum | Min | Max) {
return Ok(false);
} else {
return Ok(true);
}
}
_ => {
return Ok(false);
}
}
} else if !matches!(fun, Sum | Min | Max) {
return Ok(false);
}
}
}
Expand Down

0 comments on commit cb469eb

Please sign in to comment.