comphead commented on code in PR #7730:
URL: https://github.com/apache/datafusion-comet/pull/7730#discussion_r4743958978


##########
native/spark-expr/src/math_funcs/numeric_guard.rs:
##########
@@ -0,0 +1,115 @@
+// 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 arrow::array::{Array, ArrowNativeTypeOp, BooleanArray};
+use arrow::compute::nullif;
+use arrow::datatypes::{DataType, Schema};
+use arrow::downcast_primitive_array;
+use datafusion::common::{exec_err, utils::take_function_args, Result, 
ScalarValue};
+use datafusion::logical_expr::{
+    ColumnarValue, ScalarFunctionArgs, ScalarUDF, ScalarUDFImpl, Signature, 
Volatility,
+};
+use datafusion::physical_expr::{
+    expressions::{lit, Literal},
+    PhysicalExpr, ScalarFunctionExpr,
+};
+use std::sync::{Arc, LazyLock};
+
+#[derive(Debug, PartialEq, Eq, Hash)]
+pub(crate) enum NumericGuard {
+    NullIfZero,
+    NullIfNonPositive,
+}
+
+impl NumericGuard {
+    // Compare the native values so both signed zeros match and NaNs pass 
through.

Review Comment:
   This comment is the contract that replaced 
`test_non_ansi_float_divisor_guard_compares_in_spark_ordering`, and nothing now 
tests it at this level. The SQL fixtures cover a `-0.0` divisor 
(`arithmetic.sql` lines 87-91) and NaN divisors (`nan_divisor.sql`), but none 
of the `log`, `log2` or `log10` fixtures has a `-0.0` row, so `value <= 
T::ZERO` for the three logarithms is only pinned for `0.0` and `-1.0`. The same 
kernel also serves `Float32`, `Decimal128` and `Decimal256` divisors and the 
scalar branch in `scalar`. A short unit test in this file over a float array 
with `-0.0`, NaN and a null, a decimal array and a scalar would pin all of 
those without a Spark round trip. Adding a `-0.0` row to the log fixtures would 
cover the SQL side.



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