jayzhan211 commented on code in PR #8726:
URL: https://github.com/apache/arrow-datafusion/pull/8726#discussion_r1440446700


##########
datafusion/physical-expr/src/array_expressions.rs:
##########
@@ -2110,16 +2110,38 @@ pub fn cardinality(args: &[ArrayRef]) -> 
Result<ArrayRef> {
         return exec_err!("cardinality expects one argument");
     }
 
-    let list_array = as_list_array(&args[0])?.clone();
-
-    let result = list_array
-        .iter()
-        .map(|arr| match compute_array_dims(arr)? {
-            Some(vector) => Ok(Some(vector.iter().map(|x| 
x.unwrap()).product::<u64>())),
-            None => Ok(None),
-        })
-        .collect::<Result<UInt64Array>>()?;
-
+    let result = match &args[0].data_type() {
+        DataType::List(_) => {

Review Comment:
   Although this implementation is small, I think having a closure for generic 
array is still a good practice.
   



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

Reply via email to