parthchandra commented on code in PR #3768:
URL: https://github.com/apache/datafusion-comet/pull/3768#discussion_r2997993059


##########
spark/src/test/scala/org/apache/comet/SparkErrorConverterSuite.scala:
##########
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.comet
+
+import org.scalatest.funsuite.AnyFunSuite
+
+class SparkErrorConverterSuite extends AnyFunSuite {
+  private def castOverflowError(fromType: String, value: String): Throwable = {
+    SparkErrorConverter
+      .convertErrorType(
+        "CastOverFlow",
+        "CAST_OVERFLOW",
+        Map("fromType" -> fromType, "toType" -> "INT", "value" -> value),
+        Array.empty,
+        null)
+      .getOrElse(fail("Expected CastOverFlow to be converted to a Spark 
exception"))
+  }
+
+  test("CastOverFlow conversion handles float inf") {
+    val err = castOverflowError("FLOAT", "inf")

Review Comment:
   If the native code is appending a D at the end, would these tests be 
matching the values that the native code produces? this tests for the value to 
be "inf" but the native code may be producing "infD".
   Can we add an end to end SQL test ?



##########
spark/src/main/spark-3.5/org/apache/spark/sql/comet/shims/ShimSparkErrorConverter.scala:
##########
@@ -44,6 +44,24 @@ trait ShimSparkErrorConverter {
   private def sqlCtx(context: Array[QueryContext]): SQLQueryContext =
     context.headOption.map(_.asInstanceOf[SQLQueryContext]).getOrElse(null)
 
+  private def parseFloatLiteral(value: String): Float = {
+    value.toLowerCase match {
+      case "inf" | "+inf" | "infinity" | "+infinity" => Float.PositiveInfinity
+      case "-inf" | "-infinity" => Float.NegativeInfinity
+      case "nan" | "+nan" | "-nan" => Float.NaN
+      case _ => value.toFloat
+    }
+  }
+
+  private def parseDoubleLiteral(value: String): Double = {
+    value.toLowerCase match {
+      case "inf" | "+inf" | "infinity" | "+infinity" | "infd" => 
Double.PositiveInfinity

Review Comment:
   What about "+infd", "-infd", etc. How about checking for a `d` at the end of 
the lowercased string and stripping it out before the match? 



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