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


##########
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:
   Essentially I think to achieve what you want to are doing something like this
   ```
   case FloatType: PhysicalFloatType. exactNumeric()
   case DoubleType: ....
   ...
   ```
   
   This is already the least code implementation.
   
   If we pull it out of the method it will even becomes this
   ```
   Map map; 
   case FloatType: map.put(FloatType, PhysicalFloatType. exactNumeric())
   
   within methods
   case FloatType: map,get(FloatType)
   ```
   @hvanhovell what do you think?
   
   



-- 
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: [email protected]

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