timsaucer commented on code in PR #17289: URL: https://github.com/apache/datafusion/pull/17289#discussion_r2319395473
########## datafusion/functions-nested/src/transform.rs: ########## @@ -0,0 +1,708 @@ +// 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. + +//! [`ScalarUDFImpl`] definition for array_transform function. + +use arrow::array::{ + Array, ArrayRef, FixedSizeListArray, GenericListArray, GenericListViewArray, +}; +use arrow::datatypes::{DataType, Field, FieldRef}; +use datafusion_common::cast::{ + as_fixed_size_list_array, as_large_list_array, as_large_list_view_array, + as_list_array, as_list_view_array, +}; +use datafusion_common::{exec_datafusion_err, exec_err, plan_err, Result}; +use datafusion_expr::type_coercion::functions::data_types_with_scalar_udf; +use datafusion_expr::{ + ColumnarValue, Documentation, ReturnFieldArgs, ScalarFunctionArgs, ScalarUDFImpl, + Signature, TypeSignature, +}; +use datafusion_expr::{Expr, ScalarUDF}; +use datafusion_macros::user_doc; +use std::any::Any; +use std::sync::Arc; + +#[doc = "ScalarFunction that returns a [`ScalarUDF`] for ArrayTransform"] +pub fn array_transform_udf( + inner: Arc<ScalarUDF>, + argument_index: usize, +) -> Arc<ScalarUDF> { + Arc::new(ScalarUDF::new_from_impl(<ArrayTransform>::new( + inner, + argument_index, + ))) +} + +#[user_doc( + doc_section(label = "Array Transform"), + description = "Transform every element of an array according to a scalar function. This work is under development and currently only supports passing a single ListArray as input to the inner function. Other inputs must be scalar values.", Review Comment: There's an example in [this comment](https://github.com/apache/datafusion/pull/17289#issuecomment-3218278949) where you would want to pass two different columns of data. One column has an array of primitive data and the other has an array of list array. Another use case would be where you have two list arrays and you want to do an element by element application. -- 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]
