mbutrovich commented on code in PR #6447:
URL: https://github.com/apache/datafusion-comet/pull/6447#discussion_r4197861645


##########
docs/source/contributor-guide/floating_point.md:
##########
@@ -0,0 +1,192 @@
+<!--
+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.
+-->
+
+# Floating-Point Semantics
+
+This page describes how Comet matches Spark's handling of `-0.0` and NaN in 
`FLOAT` and `DOUBLE`
+values. It is aimed at contributors working on an expression or operator that 
compares, orders,
+hashes, deduplicates or groups floating-point values, including values nested 
in arrays, structs
+and maps. For user-facing differences from Spark, see
+[Floating-point Number 
Comparison](../user-guide/latest/compatibility/floating-point.md). The work
+to apply these rules systematically is tracked in
+[#6385](https://github.com/apache/datafusion-comet/issues/6385).
+
+The short version: Spark has no single rule for floating-point equality. Each 
function inherits one
+from the Java API that its implementation calls. Arrow and DataFusion follow 
IEEE 754 total order,
+which matches none of them. A native implementation must follow the rule of 
the Spark function it
+replaces, using the shared helpers in 
`native/spark-expr/src/float_semantics/`, and its tests must
+include a NaN with the sign bit set.
+

Review Comment:
   The new `CometNativeReaderSuite` test says that Spark's own reader probes 
the bloom filter with the literal's bits and skips the file holding the other 
zero. As I read parquet-java 1.16.0's `DictionaryFilter`, the same thing 
happens without bloom filters. It loads the dictionary into a `HashSet` 
([L126-L129](https://github.com/apache/parquet-java/blob/402c3810c372d29603e181771acebfecc71bef61/parquet-hadoop/src/main/java/org/apache/parquet/filter2/dictionarylevel/DictionaryFilter.java#L126-L129))
 and drops the row group when the set doesn't contain the literal 
([L160-L163](https://github.com/apache/parquet-java/blob/402c3810c372d29603e181771acebfecc71bef61/parquet-hadoop/src/main/java/org/apache/parquet/filter2/dictionarylevel/DictionaryFilter.java#L160-L163)),
 and `Double.equals` keeps the two zeros apart. Parquet files are 
dictionary-encoded by default. I haven't run this against Spark.
   
   If that holds, `WHERE d = -0.0D` returns rows from Comet that Spark doesn't, 
whenever a row group holds `0.0` but no `-0.0`. Comet's answer is the one 
Spark's SQL semantics call for, but someone comparing the two engines will see 
different results. Should this paragraph say so, and is there a Spark issue we 
could link for the reader's behavior?



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