panbingkun commented on code in PR #36169:
URL: https://github.com/apache/spark/pull/36169#discussion_r850075349


##########
sql/core/src/test/scala/org/apache/spark/sql/errors/QueryExecutionErrorsSuite.scala:
##########
@@ -278,4 +284,35 @@ class QueryExecutionErrorsSuite extends QueryTest
     assert(e.getMessage ===
       "Datetime operation overflow: add 1000000 YEAR to TIMESTAMP '2022-03-09 
01:02:03'.")
   }
+
+  test("CANNOT_PARSE_DECIMAL: unparseable decimal") {
+    val e1 = intercept[SparkException] {
+      val schema = new StructType().add("money", DecimalType.DoubleDecimal)
+      spark
+        .read
+        .schema(schema)
+        .format("csv")
+        .option("header", "true")
+        .option("locale", Locale.ROOT.toLanguageTag)
+        .option("multiLine", "true")
+        .option("inferSchema", "false")
+        .option("mode", "FAILFAST")

Review Comment:
   ### from_csv don't support FailFastMode, code as folllow:
   #### In CsvToStructs.parser
   if (mode != PermissiveMode && mode != FailFastMode) {
         throw QueryCompilationErrors.parseModeUnsupportedError("from_csv", 
mode)
   }
   ##
   ### if Mode is not FailFastMode, the deep exception: CANNOT_PARSE_DECIMAL, 
can't throw。
   #### In FailureSafeParser:
   def parse(input: IN): Iterator[InternalRow] = {
       try {
         rawParser.apply(input).iterator.map(row => toResultRow(Some(row), () 
=> null))
       } catch {
         case e: BadRecordException => mode match {
           case PermissiveMode =>
             Iterator(toResultRow(e.partialResult(), e.record))
           case DropMalformedMode =>
             Iterator.empty
           case FailFastMode =>
             throw 
QueryExecutionErrors.malformedRecordsDetectedInRecordParsingError(e)
         }
       }
     }
   
   



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