coderfender commented on code in PR #2835:
URL: https://github.com/apache/datafusion-comet/pull/2835#discussion_r2604844886


##########
spark/src/test/scala/org/apache/comet/CometCastSuite.scala:
##########
@@ -652,54 +652,136 @@ class CometCastSuite extends CometTestBase with 
AdaptiveSparkPlanHelper {
     castTest(gen.generateStrings(dataSize, numericPattern, 8).toDF("a"), 
DataTypes.LongType)
   }
 
-  ignore("cast StringType to FloatType") {
-    // https://github.com/apache/datafusion-comet/issues/326
-    castTest(gen.generateStrings(dataSize, numericPattern, 8).toDF("a"), 
DataTypes.FloatType)
-  }
+  def specialValues: Seq[String] = Seq(
+    "1.5f",
+    "1.5F",
+    "2.0d",
+    "2.0D",
+    "3.14159265358979d",
+    "inf",
+    "Inf",
+    "INF",
+    "+inf",
+    "+Infinity",
+    "-inf",
+    "-Infinity",
+    "NaN",
+    "nan",
+    "NAN",
+    "1.23e4",
+    "1.23E4",
+    "-1.23e-4",
+    "  123.456789  ",
+    "0.0",
+    "-0.0",
+    "",
+    "xyz",
+    null)
 
-  test("cast StringType to FloatType (partial support)") {
-    withSQLConf(
-      CometConf.getExprAllowIncompatConfigKey(classOf[Cast]) -> "true",
-      SQLConf.ANSI_ENABLED.key -> "false") {
-      castTest(
-        gen.generateStrings(dataSize, "0123456789.", 8).toDF("a"),
-        DataTypes.FloatType,
-        testAnsi = false)
+  test("cast StringType to FloatType special values") {
+    Seq(true, false).foreach { v =>
+      castTest(specialValues.toDF("a"), DataTypes.FloatType, testAnsi = v)
     }
   }
 
-  ignore("cast StringType to DoubleType") {
-    // https://github.com/apache/datafusion-comet/issues/326
-    castTest(gen.generateStrings(dataSize, numericPattern, 8).toDF("a"), 
DataTypes.DoubleType)
+  test("cast StringType to DoubleType special values") {
+    Seq(true, false).foreach { v =>
+      castTest(specialValues.toDF("a"), DataTypes.DoubleType, testAnsi = v)
+    }
   }
 
-  test("cast StringType to DoubleType (partial support)") {
-    withSQLConf(
-      CometConf.getExprAllowIncompatConfigKey(classOf[Cast]) -> "true",
-      SQLConf.ANSI_ENABLED.key -> "false") {
+  test("cast StringType to DoubleType") {
+    Seq(true, false).foreach { v =>
       castTest(
-        gen.generateStrings(dataSize, "0123456789.", 8).toDF("a"),
+        gen.generateStrings(dataSize, numericPattern, 10).toDF("a"),
         DataTypes.DoubleType,
-        testAnsi = false)
+        testAnsi = v)
+    }
+  }
+
+  test("cast StringType to FloatType") {
+    Seq(true, false).foreach { v =>
+      castTest(
+        gen.generateStrings(dataSize, numericPattern, 10).toDF("a"),
+        DataTypes.FloatType,
+        testAnsi = v)
     }
   }
 
-  ignore("cast StringType to DecimalType(10,2)") {
-    // https://github.com/apache/datafusion-comet/issues/325
-    val values = gen.generateStrings(dataSize, numericPattern, 8).toDF("a")
+  test("cast StringType to DecimalType(10,2)") {
+    val values = gen.generateStrings(dataSize, numericPattern, 12).toDF("a")
     castTest(values, DataTypes.createDecimalType(10, 2))
   }
 
-  test("cast StringType to DecimalType(10,2) (partial support)") {
-    withSQLConf(
-      CometConf.getExprAllowIncompatConfigKey(classOf[Cast]) -> "true",
-      SQLConf.ANSI_ENABLED.key -> "false") {
-      val values = gen
-        .generateStrings(dataSize, "0123456789.", 8)
-        .filter(_.exists(_.isDigit))
-        .toDF("a")
-      castTest(values, DataTypes.createDecimalType(10, 2), testAnsi = false)
-    }
+  test("cast StringType to DecimalType(10,2) basic values") {
+    val values = Seq(
+      "123.45",
+      "-67.89",

Review Comment:
   Great suggestion !  I added some more variety to test inputs to make sure we 
test out varied inputs 



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