gstvg commented on code in PR #23660: URL: https://github.com/apache/datafusion/pull/23660#discussion_r3633943962
########## datafusion/sqllogictest/test_files/multi_arg_lambda.slt: ########## @@ -0,0 +1,62 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at + +# http://www.apache.org/licenses/LICENSE-2.0 + +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +statement ok +set datafusion.sql_parser.dialect = databricks; + +query I +SELECT multi_arg_higher_order_udf(1, 2, 3, (a, b, c) -> a+1); +---- +2 + +query I +SELECT multi_arg_higher_order_udf(1, 2, 3, (a, b, c) -> b+1); +---- +3 + +query I +SELECT multi_arg_higher_order_udf(1, 2, 3, (a, b, c) -> c+1); +---- +4 + +query I +SELECT multi_arg_higher_order_udf(1, 2, 3, (a, b, c) -> a+b); +---- +3 + +query I +SELECT multi_arg_higher_order_udf(1, 2, 3, (a, b, c) -> a+c); +---- +4 + +query I +SELECT multi_arg_higher_order_udf(1, 2, 3, (a, b, c) -> b+c); +---- +5 + +query I +SELECT multi_arg_higher_order_udf(1, 2, 3, (a, b, c) -> a+b+c); +---- +6 + +query I +SELECT multi_arg_higher_order_udf(1, 2, 3, (a, b, c) -> 1); Review Comment: Yes, the generic syntax parses this as the postgres json operator (example discussion https://github.com/apache/datafusion-sqlparser-rs/pull/2224 ) ########## datafusion/sqllogictest/src/test_context.rs: ########## @@ -712,3 +718,91 @@ fn register_async_abs_udf(ctx: &SessionContext) { let udf = AsyncScalarUDF::new(Arc::new(async_abs)); ctx.register_udf(udf.into_scalar_udf()); } + +fn register_multi_arg_lambda_udf(ctx: &SessionContext) { + // In 54 release, all built-in higher-order functions are single-parameter, but the public higher-order trait supports + // user defined functions with multi-parameter lambdas. To test the lambda handling of multiple parameters, we create + // a dummy udf that provides every value argument it receives as a parameter to it's lambda, the last argument: + // multi_arg_higher_order_udf([..value_args], ([..value_args_as_params]) -> ...) + #[derive(Debug, PartialEq, Eq, Hash)] + struct MultiArgHigherOrderUdf { + signature: HigherOrderSignature, + } + + impl HigherOrderUDFImpl for MultiArgHigherOrderUdf { Review Comment: I agree, that was an oversight, https://github.com/apache/datafusion/pull/23660/commits/b61236f145a6f114647ae4351813da6fd7c6e61f -- 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]
