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 2020/02/04 18:40:20 UTC

[GitHub] [spark] MaxGekk commented on a change in pull request #27456: [SPARK-25040][SQL][FOLLOWUP] Add legacy config for allowing empty strings for certain types in json parser

MaxGekk commented on a change in pull request #27456: [SPARK-25040][SQL][FOLLOWUP] Add legacy config for allowing empty strings for certain types in json parser
URL: https://github.com/apache/spark/pull/27456#discussion_r374851279
 
 

 ##########
 File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/json/JacksonParser.scala
 ##########
 @@ -317,8 +320,18 @@ class JacksonParser(
 
     // SPARK-25040: Disallow empty strings for data types except for string and binary types.
     case VALUE_STRING if parser.getTextLength < 1 =>
-      throw new RuntimeException(
-        s"Failed to parse an empty string for data type ${dataType.catalogString}")
+        // Legacy mode for prior to Spark 3.0.0.
+      if (allowEmptyString) {
+        dataType match {
 
 Review comment:
   If you would match by types that allow empty strings, this could be shorter:
   ```scala
   dataType match {
     case IntergerType | ... if allowEmptyString => null
     case _ => throw new RuntimeException(s"Failed to parse an empty string for data type ${dataType.catalogString}")
   }
   ```

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

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