maropu commented on a change in pull request #28264:
URL: https://github.com/apache/spark/pull/28264#discussion_r411043838



##########
File path: docs/sql-ref-datatypes.md
##########
@@ -706,3 +708,28 @@ The following table shows the type names as well as 
aliases used in Spark SQL pa
 </table>
 </div>
 </div>
+
+### Floating Point Special Values
+
+Spark SQL supports several special floating point values in a case-insensitive 
manner:
+
+ * Inf/+Inf/Infinity/+Infinity: positive infinity
+   * ```FloatType```: 1.0f / 0.0f
+   * ```DoubleType```: 1.0 / 0.0
+ * -Inf/-Infinity: negative infinity
+   * ```FloatType```: -1.0f / 0.0f
+   * ```DoubleType```: -1.0 / 0.0
+ * NaN: not a number
+   * ```FloatType```: 0.0f / 0.0f
+   * ```DoubleType```:  0.0d / 0.0
+
+### NaN Semantics
+
+There is special handling for not-a-number (NaN) when dealing with `float` or 
`double` types that
+do not exactly match standard floating point semantics.
+Specifically:
+
+ - NaN = NaN returns true.
+ - In aggregations, all NaN values are grouped together.
+ - NaN is treated as a normal value in join keys.
+ - NaN values go last when in ascending order, larger than any other numeric 
value.

Review comment:
       Also, it might be worth describing the sort order of NaN, Null, and 
infinity in this page.




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

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