shivbhatia10 commented on code in PR #20595:
URL: https://github.com/apache/datafusion/pull/20595#discussion_r3176551114


##########
datafusion/sqllogictest/test_files/spark/math/isnan.slt:
##########
@@ -0,0 +1,72 @@
+# 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.
+
+# This file is part of the implementation of the datafusion-spark function 
library.
+# For more information, please see:
+#   https://github.com/apache/datafusion/issues/15914
+
+# Tests for Spark-compatible isnan function.
+# Spark semantics differ from DataFusion's built-in isnan:
+#   Spark returns false for NULL inputs; DataFusion returns NULL.
+#
+# Example: SELECT isnan(NULL::DOUBLE)
+#   Spark:      returns false
+#   DataFusion: returns NULL
+
+# Scalar input: float64
+query BBBBB
+SELECT isnan(1.0::DOUBLE), isnan('NaN'::DOUBLE), isnan('inf'::DOUBLE), 
isnan(0.0::DOUBLE), isnan(-1.0::DOUBLE);

Review Comment:
   I added an slt test to confirm that different numeric types are coerced to 
float types under the current implementation. I checked that pyspark matches 
our current behaviour exactly.



##########
datafusion/sqllogictest/test_files/spark/math/isnan.slt:
##########
@@ -0,0 +1,72 @@
+# 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.
+
+# This file is part of the implementation of the datafusion-spark function 
library.
+# For more information, please see:
+#   https://github.com/apache/datafusion/issues/15914
+
+# Tests for Spark-compatible isnan function.
+# Spark semantics differ from DataFusion's built-in isnan:
+#   Spark returns false for NULL inputs; DataFusion returns NULL.
+#
+# Example: SELECT isnan(NULL::DOUBLE)
+#   Spark:      returns false
+#   DataFusion: returns NULL
+
+# Scalar input: float64
+query BBBBB
+SELECT isnan(1.0::DOUBLE), isnan('NaN'::DOUBLE), isnan('inf'::DOUBLE), 
isnan(0.0::DOUBLE), isnan(-1.0::DOUBLE);

Review Comment:
   ```
   # Spark's isnan accepts any numeric type by implicitly casting to double, so
   # integers, bigints, and decimals all return false (they can never be NaN).
   # This test guards against the signature being accidentally narrowed in a way
   # that would diverge from Spark.
   query BBBB
   SELECT
     isnan(1) AS int_lit,
     isnan(CAST(1 AS BIGINT)) AS bigint,
     isnan(CAST(1 AS DECIMAL(10, 2))) AS dec,
     isnan(CAST(NULL AS INT)) AS null_int;
   ----
   false false false false
   
   ```



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