You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: support named arguments for aggregate and window udfs (apache#18389)
## Which issue does this PR close?
Addresses portions of apache#17379.
## Rationale for this change
Add support for aggregate and window UDFs in the same way as we did it
for scalar UDFs here: apache#18019
## Are these changes tested?
Yes
## Are there any user-facing changes?
Yes, the changes are user-facing, documented, purely additive and
non-breaking.
To support named arguments in your UDF, add parameter names to your function's signature using `.with_parameter_names()`:
606
-
607
-
```rust
608
-
# usearrow::datatypes::DataType;
609
-
# usedatafusion_expr::{Signature, Volatility};
610
-
#
611
-
# #[derive(Debug)]
612
-
# structMyFunction {
613
-
# signature:Signature,
614
-
# }
615
-
#
616
-
implMyFunction {
617
-
fnnew() ->Self {
618
-
Self {
619
-
signature:Signature::uniform(
620
-
2,
621
-
vec![DataType::Float64],
622
-
Volatility::Immutable
623
-
)
624
-
.with_parameter_names(vec![
625
-
"base".to_string(),
626
-
"exponent".to_string()
627
-
])
628
-
.expect("valid parameter names"),
629
-
}
630
-
}
631
-
}
632
-
```
633
-
634
-
The parameter names should match the order of arguments in your function's signature. DataFusion automatically resolves named arguments to the correct positional order before invoking your function.
635
-
636
-
### Example
612
+
To support named arguments in your UDF, add parameter names to your function's signature using `.with_parameter_names()`. This works the same way for Scalar, Window, and Aggregate UDFs:
637
613
638
614
```rust
639
615
# usestd::sync::Arc;
@@ -681,10 +657,14 @@ impl ScalarUDFImpl for PowerFunction {
681
657
}
682
658
```
683
659
684
-
Once registered, users can call your function with named arguments:
660
+
The parameter names should match the order of arguments in your function's signature. DataFusion automatically resolves named arguments to the correct positional order before invoking your function.
661
+
662
+
Once registered, users can call your functions with named arguments in any order:
0 commit comments