Skip to content

Apache DataFusion SQL Query Engine

fix: format within_group error message (#16613)

haiywuebf49b4fe585
diff --git a/datafusion/sql/src/expr/function.rs b/datafusion/sql/src/expr/function.rs
index 6b23bd5c2c..d0cb4263db 100644
--- a/datafusion/sql/src/expr/function.rs
+++ b/datafusion/sql/src/expr/function.rs
@@ -228,7 +228,7 @@ impl<S: ContextProvider> SqlToRel<'_, S> {
}
if !order_by.is_empty() && !within_group.is_empty() {
- return plan_err!("ORDER BY and WITHIN GROUP clauses cannot be used together in the same aggregate function. ");
+ return plan_err!("ORDER BY and WITHIN GROUP clauses cannot be used together in the same aggregate function");
}
// If function is a window function (it has an OVER clause),
diff --git a/datafusion/sqllogictest/test_files/aggregate.slt b/datafusion/sqllogictest/test_files/aggregate.slt
index 5d6ef1e785..3f064485e5 100644
--- a/datafusion/sqllogictest/test_files/aggregate.slt
+++ b/datafusion/sqllogictest/test_files/aggregate.slt
@@ -7053,6 +7053,6 @@ FROM (VALUES ('a'), ('d'), ('c'), ('a')) t(a_varchar);
----
[a, c, d]
-query error Error during planning: ORDER BY and WITHIN GROUP clauses cannot be used together in the same aggregate function.
+query error Error during planning: ORDER BY and WITHIN GROUP clauses cannot be used together in the same aggregate function
SELECT array_agg(a_varchar order by a_varchar) WITHIN GROUP (ORDER BY a_varchar)
FROM (VALUES ('a'), ('d'), ('c'), ('a')) t(a_varchar);