alamb commented on code in PR #10243:
URL: https://github.com/apache/datafusion/pull/10243#discussion_r1580913377
##########
datafusion/sql/src/unparser/expr.rs:
##########
@@ -199,37 +238,20 @@ impl Unparser<'_> {
escape_char: *escape_char,
}),
Expr::AggregateFunction(agg) => {
- let func_name = if let
AggregateFunctionDefinition::BuiltIn(built_in) =
- &agg.func_def
- {
- built_in.name()
- } else {
- return not_impl_err!(
- "Only built in agg functions are supported, got
{agg:?}"
- );
- };
-
- let args = agg
- .args
- .iter()
- .map(|e| {
- if matches!(e, Expr::Wildcard { qualifier: None }) {
-
Ok(FunctionArg::Unnamed(ast::FunctionArgExpr::Wildcard))
- } else {
- self.expr_to_sql(e).map(|e| {
-
FunctionArg::Unnamed(ast::FunctionArgExpr::Expr(e))
- })
- }
- })
- .collect::<Result<Vec<_>>>()?;
+ let func_name = agg.func_def.name();
Review Comment:
👍
##########
datafusion/sql/src/unparser/expr.rs:
##########
@@ -901,6 +959,53 @@ mod tests {
}),
"COUNT(DISTINCT *)",
),
+ (
+ Expr::AggregateFunction(AggregateFunction {
+ func_def: AggregateFunctionDefinition::BuiltIn(
+ datafusion_expr::AggregateFunction::Count,
+ ),
+ args: vec![Expr::Wildcard { qualifier: None }],
+ distinct: false,
+ filter: Some(Box::new(lit(true))),
+ order_by: None,
+ null_treatment: None,
+ }),
+ "COUNT(*) FILTER (WHERE true)",
Review Comment:
nice
--
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]