Skip to content

Commit e3560fe

Browse files
committed
Add .slt tests
1 parent c8a2de8 commit e3560fe

2 files changed

Lines changed: 68 additions & 2 deletions

File tree

datafusion/spark/src/function/math/isnan.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,10 @@ use datafusion_expr::{
3030
/// Spark-compatible `isnan` expression
3131
/// <https://spark.apache.org/docs/latest/api/sql/index.html#isnan>
3232
///
33-
/// Differences with standard SQL:
34-
/// - Returns `false` for NULL inputs (not NULL)
33+
/// Differences with DataFusion isnan:
34+
/// - Spark returns `false` for NULL inputs; DataFusion propagates NULL
35+
/// - Spark only accepts Float32 and Float64; DataFusion accepts all numeric
36+
/// types (returning false for integers and decimals, which are never NaN)
3537
#[derive(Debug, PartialEq, Eq, Hash)]
3638
pub struct SparkIsNaN {
3739
signature: Signature,
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
# This file is part of the implementation of the datafusion-spark function library.
19+
# For more information, please see:
20+
# https://github.com/apache/datafusion/issues/15914
21+
22+
# Scalar input: float64
23+
query BBBBB
24+
SELECT isnan(1.0::DOUBLE), isnan('NaN'::DOUBLE), isnan('inf'::DOUBLE), isnan(0.0::DOUBLE), isnan(-1.0::DOUBLE);
25+
----
26+
false true false false false
27+
28+
# Scalar input: float64 NULL returns false (Spark behaviour, not NULL)
29+
query B
30+
SELECT isnan(NULL::DOUBLE);
31+
----
32+
false
33+
34+
# Scalar input: float32
35+
query BBBBB
36+
SELECT isnan(1.0::FLOAT), isnan('NaN'::FLOAT), isnan('inf'::FLOAT), isnan(0.0::FLOAT), isnan(-1.0::FLOAT);
37+
----
38+
false true false false false
39+
40+
# Scalar input: float32 NULL returns false
41+
query B
42+
SELECT isnan(NULL::FLOAT);
43+
----
44+
false
45+
46+
# Array input: float64 — NULL produces false, not NULL
47+
query B
48+
SELECT isnan(a) FROM (VALUES (1.0::DOUBLE), ('NaN'::DOUBLE), (NULL::DOUBLE), ('inf'::DOUBLE), (0.0::DOUBLE)) AS t(a);
49+
----
50+
false
51+
true
52+
false
53+
false
54+
false
55+
56+
# Array input: float32
57+
query B
58+
SELECT isnan(a) FROM (VALUES (1.0::FLOAT), ('NaN'::FLOAT), (NULL::FLOAT), ('inf'::FLOAT), (0.0::FLOAT)) AS t(a);
59+
----
60+
false
61+
true
62+
false
63+
false
64+
false

0 commit comments

Comments
 (0)