Skip to content

Commit 864c2b5

Browse files
committed
test: hash quotients of a NaN divisor with the sign bit set
The removed Project and Filter rewrite normalized the divisor of Divide and Remainder, which also canonicalized a NaN divisor. Without it the quotient keeps the sign bit, and hash and xxhash64 must still hash it as Spark does, in both ANSI modes.
1 parent a0b1f4d commit 864c2b5

1 file changed

Lines changed: 34 additions & 0 deletions

File tree

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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+
-- Division and remainder pass a NaN divisor through, so `1.0D / (-d)` of a NaN is a NaN with the
19+
-- sign bit set, the NaN that arithmetic produces on x86-64. Spark hashes every NaN alike. ANSI
20+
-- mode divides through a different native path.
21+
-- ConfigMatrix: spark.sql.ansi.enabled=false,true
22+
23+
statement
24+
CREATE TABLE nan_divisor(d double, f float) USING parquet
25+
26+
statement
27+
INSERT INTO nan_divisor VALUES (double('NaN'), float('NaN')), (1.5, float(1.5)), (NULL, NULL)
28+
29+
query
30+
SELECT hash(1.0D / (-d)), xxhash64(1.0D / (-d)), hash(1.0D % (-d)), xxhash64(1.0D % (-d))
31+
FROM nan_divisor
32+
33+
query
34+
SELECT hash(1.0F % (-f)), xxhash64(1.0F % (-f)) FROM nan_divisor

0 commit comments

Comments
 (0)