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


##########
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:
   found there is a similar helper in hll agg:
   
   
https://github.com/apache/datafusion-comet/blob/397b5bbf754e0c40c6ae9472fa7530037bf00889/native/spark-expr/src/agg_funcs/hll_plus_plus.rs#L123-L140
   
   considering extending it to cover more data type so we dont need another 
file, or at least we can have one centralized helper for similar usage.



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