cloud-fan commented on a change in pull request #28264:
URL: https://github.com/apache/spark/pull/28264#discussion_r414363818



##########
File path: docs/sql-ref-datatypes.md
##########
@@ -706,3 +708,67 @@ 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```: equivalent to Scala <code>Float.PositiveInfinity</code>.
+   * ```DoubleType```: equivalent to Scala 
<code>Double.PositiveInfinity</code>.
+ * -Inf/-Infinity: negative infinity
+   * ```FloatType```: equivalent to Scala <code>Float.NegativeInfinity</code>.
+   * ```DoubleType```: equivalent to Scala 
<code>Double.NegativeInfinity</code>.
+ * NaN: not a number
+   * ```FloatType```: equivalent to Scala <code>Float.NaN</code>.
+   * ```DoubleType```:  equivalent to Scala <code>Double.NaN</code>.
+
+#### Examples
+
+{% highlight sql %}
+SELECT double('infinity') AS col;
++--------+
+|     col|
++--------+
+|Infinity|
++--------+
+
+SELECT float('-inf') AS col;
++---------+
+|      col|
++---------+
+|-Infinity|
++---------+
+
+SELECT float('NaN') AS col;
++---+
+|col|
++---+
+|NaN|
++---+
+{% endhighlight %}
+
+### Positive/negative Infinity Semantics
+There is special handling for positive and negative infinity. They have the 
following semantics:
+
+ - Positive infinity multiplied by any positive value returns positive 
infinity.
+ - Negative infinity multiplied by any positive value returns negative 
infinity.
+ - Positive infinity multiplied by any negative value returns negative 
infinity.
+ - Negative infinity multiplied by any negative value returns positive 
infinity.
+ - Positive infinity/Negtive infinity multiplied by 0 returns NaN.
+ - Infinity values equal to each other, no matter positive or negative.
+ - In aggregations, all positive infinity values are grouped together. 
Similarly, all negative infinity values are grouped together.
+ - Positive infinity and negative infinity are treated as normal values in 
join keys.
+ - Positive infinity sorts lower than NaN and higher than any other value.
+ - Negatie infinity sorts lower than any other value.
+
+### NaN Semantics

Review comment:
       ditto




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