vegarsti commented on code in PR #17289:
URL: https://github.com/apache/datafusion/pull/17289#discussion_r2313068847


##########
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:
   Out of curiosity, what other scenarios are there? This comment seems to 
indicate it's common for such functions to support multiple lists



##########
datafusion/common/src/cast.rs:
##########
@@ -147,6 +148,16 @@ pub fn as_list_array(array: &dyn Array) -> 
Result<&ListArray> {
     Ok(downcast_value!(array, ListArray))
 }
 
+// Downcast Array to ListViewArray
+pub fn as_list_view_array(array: &dyn Array) -> Result<&ListViewArray> {
+    Ok(downcast_value!(array, ListViewArray))
+}
+
+// Downcast Array to LargeListViewArray
+pub fn as_large_list_view_array(array: &dyn Array) -> 
Result<&LargeListViewArray> {
+    Ok(downcast_value!(array, LargeListViewArray))
+}

Review Comment:
   Docstrings need triple quotes! ... Although I see that the ones around this 
also don't have docstrings.
   
   ```suggestion
   /// Downcast Array to ListViewArray
   pub fn as_list_view_array(array: &dyn Array) -> Result<&ListViewArray> {
       Ok(downcast_value!(array, ListViewArray))
   }
   
   /// Downcast Array to LargeListViewArray
   pub fn as_large_list_view_array(array: &dyn Array) -> 
Result<&LargeListViewArray> {
       Ok(downcast_value!(array, LargeListViewArray))
   }
   ```



-- 
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]

Reply via email to