You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2022/06/15 07:59:31 UTC
[GitHub] [spark] cloud-fan commented on a diff in pull request #36873: [SPARK-39476][SQL] Disable Unwrap cast optimize when casting from Long to Float/ Double or from Integer to Float
cloud-fan commented on code in PR #36873:
URL: https://github.com/apache/spark/pull/36873#discussion_r897659097
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/UnwrapCastInBinaryComparison.scala:
##########
@@ -358,8 +358,16 @@ object UnwrapCastInBinaryComparison extends Rule[LogicalPlan] {
toType.sameType(literalType) &&
!fromExp.foldable &&
toType.isInstanceOf[NumericType] &&
- ((fromExp.dataType.isInstanceOf[NumericType] && Cast.canUpCast(fromExp.dataType, toType)) ||
- fromExp.dataType.isInstanceOf[BooleanType])
+ canUnwrapCast(fromExp.dataType, toType)
+ }
+
+ private def canUnwrapCast(from: DataType, to: DataType): Boolean = (from, to) match {
+ case (BooleanType, _) => true
+ case (IntegerType, FloatType) => false
Review Comment:
can we add some code comments to explain the reason?
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org