You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2021/08/12 07:11:21 UTC

[GitHub] [spark] yaooqinn commented on a change in pull request #33706: [SPARK-36477][SQL] Inferring schema from JSON file shall handle CharConversionException/MalformedInputException

yaooqinn commented on a change in pull request #33706:
URL: https://github.com/apache/spark/pull/33706#discussion_r687446987



##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/json/JsonInferSchema.scala
##########
@@ -68,13 +71,15 @@ private[sql] class JsonInferSchema(options: JSONOptions) extends Serializable {
             Some(inferField(parser))
           }
         } catch {
-          case  e @ (_: RuntimeException | _: JsonProcessingException) => parseMode match {
-            case PermissiveMode =>
-              Some(StructType(Seq(StructField(columnNameOfCorruptRecord, StringType))))
-            case DropMalformedMode =>
-              None
-            case FailFastMode =>
-              throw QueryExecutionErrors.malformedRecordsDetectedInSchemaInferenceError(e)
+          case e @ (_: RuntimeException | _: JsonProcessingException |
+                    _: CharConversionException | _: MalformedInputException) =>

Review comment:
       cases like https://github.com/apache/spark/pull/33706/files#diff-587e4c03ef08aa4964d4409ae33954735a9c090727dd7b5a918892cd3ed0814dR2450 seems not to have a chance to add JSON options

##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/json/JsonInferSchema.scala
##########
@@ -68,13 +71,15 @@ private[sql] class JsonInferSchema(options: JSONOptions) extends Serializable {
             Some(inferField(parser))
           }
         } catch {
-          case  e @ (_: RuntimeException | _: JsonProcessingException) => parseMode match {
-            case PermissiveMode =>
-              Some(StructType(Seq(StructField(columnNameOfCorruptRecord, StringType))))
-            case DropMalformedMode =>
-              None
-            case FailFastMode =>
-              throw QueryExecutionErrors.malformedRecordsDetectedInSchemaInferenceError(e)
+          case e @ (_: RuntimeException | _: JsonProcessingException |
+                    _: CharConversionException | _: MalformedInputException) =>

Review comment:
       cases like https://github.com/apache/spark/pull/33706/files#diff-587e4c03ef08aa4964d4409ae33954735a9c090727dd7b5a918892cd3ed0814dR2450 seems not to have a chance to add JSON options?




-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org