Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions datafusion/functions-aggregate/src/approx_percentile_cont.rs
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,13 @@ impl AggregateUDFImpl for ApproxPercentileCont {
}

fn return_type(&self, arg_types: &[DataType]) -> Result<DataType> {
// Defensive: the public signature already restricts callers to 2 or 3
// arguments. This guards against aggregate planning accidentally
// feeding state-field types (e.g. from `PartialReduce`) back into
// `return_type`, which would otherwise be silently mis-typed.
if arg_types.len() > 3 {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the public signature already restricts approx_percentile_cont to 2 or 3 arguments, this extra arity check reads more like a defensive internal invariant than user-facing validation.

A short comment explaining that it protects aggregate planning from accidentally feeding state-field types back into return_type would help clarify the intent for future readers.

return plan_err!("approx_percentile_cont requires at most 3 arguments");
}
if !arg_types[0].is_numeric() {
return plan_err!("approx_percentile_cont requires numeric input types");
}
Expand Down
Loading
Loading