divyankshah commented on code in PR #5235:
URL: https://github.com/apache/datafusion-comet/pull/5235#discussion_r3715481331


##########
native/spark-expr/src/array_funcs/nested_float_normalize.rs:
##########
@@ -0,0 +1,208 @@
+// 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.
+
+use crate::math_funcs::internal::normalize_float;
+use arrow::array::{
+    Array, ArrayRef, AsArray, FixedSizeListArray, Float32Array, Float64Array, 
LargeListArray,
+    ListArray, StructArray,
+};
+use arrow::datatypes::{DataType, Float32Type, Float64Type};
+use std::sync::Arc;
+
+pub(super) fn has_float_leaf(dt: &DataType) -> bool {
+    match dt {
+        DataType::Float32 | DataType::Float64 => true,
+        DataType::List(field) | DataType::LargeList(field) | 
DataType::FixedSizeList(field, _) => {
+            has_float_leaf(field.data_type())
+        }
+        DataType::Struct(fields) => fields.iter().any(|f| 
has_float_leaf(f.data_type())),
+        _ => false,
+    }
+}
+
+/// Recursively rebuilds nested arrays with `-0.0` normalized to `0.0` and NaN 
canonicalized
+/// in any Float32/Float64 leaves.
+pub(super) fn normalize_nested_floats(array: &ArrayRef) -> ArrayRef {

Review Comment:
   Hi @peterxcli,
   
   thanks for pointing that out. the normalization rule itself isn't 
duplicated, we already call the same normalize_float function you linked. 
there's a bit of repeated dispatch code around it (the Float32/Float64 match 
arms), but the actual behavior comes from one place. hll's version skips nested 
types (struct/list) right now, and I'm not sure if making it handle those too 
would change hll's behavior in ways that need separate testing. But I can 
follow up on it if it's worth doing. Please let me know if I should implement 
it in that way.



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