You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "hvanhovell (via GitHub)" <gi...@apache.org> on 2023/04/08 10:55:15 UTC

[GitHub] [spark] hvanhovell commented on a diff in pull request #40693: [SPARK-43058] Move Numeric and Fractional to PhysicalDataType

hvanhovell commented on code in PR #40693:
URL: https://github.com/apache/spark/pull/40693#discussion_r1161097318


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/Cast.scala:
##########
@@ -915,9 +916,9 @@ case class Cast(
     case TimestampType =>
       buildCast[Long](_, t => timestampToLong(t))
     case x: NumericType if ansiEnabled =>
-      b => x.exactNumeric.asInstanceOf[Numeric[Any]].toLong(b)
+      b => PhysicalNumericType.exactNumeric(x).toLong(b)

Review Comment:
   One small issue with all of these changes is that we are doing the same resolution over and over on the hot path, while we only need to do it once. Can you move the resolution to the `PhysicalNumericType.numeric` out of the function, and do this for all calls in here?
   
   For example:
   
   ``` scala
   val exactNumeric = PhysicalNumericType.exactNumeric(x)
   b => exactNumeric.toLong(b)
   ```



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