timsaucer commented on code in PR #18019: URL: https://github.com/apache/datafusion/pull/18019#discussion_r2442510363
########## docs/source/library-user-guide/functions/adding-udfs.md: ########## @@ -586,6 +586,119 @@ For async UDF implementation details, see [`async_udf.rs`](https://github.com/ap [`process_scalar_func_inputs`]: https://docs.rs/datafusion/latest/datafusion/physical_expr/functions/fn.process_scalar_func_inputs.html [`advanced_udf.rs`]: https://github.com/apache/datafusion/blob/main/datafusion-examples/examples/advanced_udf.rs +## Named Arguments + +DataFusion supports PostgreSQL-style named arguments for scalar functions, allowing you to pass arguments by parameter name: Review Comment: Will this work for other dialects? Do you know what happens when you try setting a different dialect and running your tests against it? ########## docs/source/library-user-guide/functions/adding-udfs.md: ########## @@ -586,6 +586,119 @@ For async UDF implementation details, see [`async_udf.rs`](https://github.com/ap [`process_scalar_func_inputs`]: https://docs.rs/datafusion/latest/datafusion/physical_expr/functions/fn.process_scalar_func_inputs.html [`advanced_udf.rs`]: https://github.com/apache/datafusion/blob/main/datafusion-examples/examples/advanced_udf.rs +## Named Arguments + +DataFusion supports PostgreSQL-style named arguments for scalar functions, allowing you to pass arguments by parameter name: Review Comment: My guess is that this *does* work with other dialects out of the box. ########## datafusion/expr/src/udf.rs: ########## @@ -957,3 +949,284 @@ mod tests { hasher.finish() } } + +/// Argument resolution logic for named function parameters +pub mod arguments { Review Comment: I don't think this repo tends to use modules defined within a file like this but rather uses separate files per module ########## datafusion/expr/src/udf.rs: ########## @@ -957,3 +949,284 @@ mod tests { hasher.finish() } } + +/// Argument resolution logic for named function parameters +pub mod arguments { + use crate::Expr; + use datafusion_common::{plan_err, Result}; + + /// Resolves function arguments, handling named and positional notation. + /// + /// This function validates and reorders arguments to match the function's parameter names + /// when named arguments are used. + /// + /// # Rules + /// - All positional arguments must come before named arguments + /// - Named arguments can be in any order after positional arguments + /// - All parameter names must match the provided parameter_names Review Comment: Do we require case sensitive? -- 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]
