dongjoon-hyun commented on a change in pull request #25331: [SPARK-27768][SQL] 
Infinity, -Infinity, NaN should be recognized in a case insensitive manner.
URL: https://github.com/apache/spark/pull/25331#discussion_r309910327
 
 

 ##########
 File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/Cast.scala
 ##########
 @@ -1235,48 +1255,72 @@ case class Cast(child: Expression, dataType: DataType, 
timeZoneId: Option[String
       (c, evPrim, evNull) => code"$evPrim = (long) $c;"
   }
 
-  private[this] def castToFloatCode(from: DataType): CastFunction = from match 
{
-    case StringType =>
-      (c, evPrim, evNull) =>
-        code"""
+  private[this] def castToFloatCode(from: DataType, ctx: CodegenContext): 
CastFunction = {
+    from match {
+      case StringType =>
+        val str = ctx.freshVariable("str", StringType)
+        (c, evPrim, evNull) =>
+          code"""
           try {
             $evPrim = Float.valueOf($c.toString());
           } catch (java.lang.NumberFormatException e) {
-            $evNull = true;
+              final String $str = $c.toString().trim();
 
 Review comment:
   Although this is called only in case of exceptions, it would be great to 
call `.toString` once by reusing the one in line 1265.

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

Reply via email to