Garamda commented on code in PR #13511:
URL: https://github.com/apache/datafusion/pull/13511#discussion_r1980817866


##########
datafusion/sql/src/expr/function.rs:
##########
@@ -349,15 +365,49 @@ impl<S: ContextProvider> SqlToRel<'_, S> {
         } else {
             // User defined aggregate functions (UDAF) have precedence in case 
it has the same name as a scalar built-in function
             if let Some(fm) = self.context_provider.get_aggregate_meta(&name) {
-                let order_by = self.order_by_to_sort_expr(
-                    order_by,
-                    schema,
-                    planner_context,
-                    true,
-                    None,
-                )?;
-                let order_by = (!order_by.is_empty()).then_some(order_by);
-                let args = self.function_args_to_expr(args, schema, 
planner_context)?;
+                if fm.is_ordered_set_aggregate() && within_group.is_empty() {
+                    return plan_err!("WITHIN GROUP clause is required when 
calling ordered set aggregate function({})", fm.name());
+                }
+
+                if null_treatment.is_some() && 
!fm.supports_null_handling_clause() {
+                    return plan_err!(
+                        "[IGNORE | RESPECT] NULLS are not permitted for {}",
+                        fm.name()
+                    );
+                }

Review Comment:
   > One big question we might need to answer before merging is if we need a 
migration strategy for this. Because we now require WITHIN GROUP for these 
functions, any users who have queries stored outside of DataFusion will 
experience breakages that they can't work around. If we want to provide a 
migration path, we may need to support having both forms of calling these 
functions, as in
   > 
   > SELECT approx_percentile_cont(column_name, 0.75, 100) FROM table_name;
   > SELECT approx_percentile_cont(0.75, 100) WITHIN GROUP (ORDER BY 
column_name) FROM table_name;
   > 
   > for at least 1 release so folks can migrate their queries.
   
   This is one of the biggest concerns when I started to work on this feature.
   If the community decides the migration strategy like that, then I will make 
both syntax supported.
   Also, I will file an issue to track the plan so that the current syntax can 
be excluded as scheduled. (if I am authorized to do so)



-- 
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: github-unsubscr...@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org
For additional commands, e-mail: github-h...@datafusion.apache.org

Reply via email to