huaxingao commented on a change in pull request #28264:
URL: https://github.com/apache/spark/pull/28264#discussion_r414689318
##########
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.
Review comment:
I kind of feel we are saying "Positive infinity equals to negative
infinity" :)
I will change it to
```Positive/negative infinities are equal to themselves``` so it won't have
any ambiguity.
----------------------------------------------------------------
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]