cloud-fan commented on a change in pull request #24806: [WIP][SPARK-27856][SQL]
Only allow type upcasting when inserting table
URL: https://github.com/apache/spark/pull/24806#discussion_r292767210
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/types/DecimalType.scala
##########
@@ -89,6 +90,7 @@ case class DecimalType(precision: Int, scale: Int) extends
FractionalType {
(precision - scale) <= (dt.precision - dt.scale) && scale <= dt.scale
case dt: IntegralType =>
isTighterThan(DecimalType.forType(dt))
+ // For DoubleType/FloatType, the value can be NaN, PositiveInfinity or
NegativeInfinity.
Review comment:
For `isWiderThan`, yes it's not safe to cast float/double to decimal because
of NaN stuff.
For `isTighterThan`, I think it's safe to cast decimal to float/double if
the precision doesn't exceed?
----------------------------------------------------------------
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]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]