[GitHub] spark pull request #15329: [SPARK-17763][SQL] JacksonParser silently parses ...

2017-01-05 Thread HyukjinKwon
Github user HyukjinKwon closed the pull request at:

https://github.com/apache/spark/pull/15329


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

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



[GitHub] spark pull request #15329: [SPARK-17763][SQL] JacksonParser silently parses ...

2016-10-08 Thread HyukjinKwon
Github user HyukjinKwon commented on a diff in the pull request:

https://github.com/apache/spark/pull/15329#discussion_r82499895
  
--- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/json/JacksonParser.scala
 ---
@@ -114,6 +120,18 @@ class JacksonParser(
 }
   }
 
+  private def failedRecord(record: String): Seq[InternalRow] = {
+if (options.dropMalformed) {
+  if (!isWarningPrintedForMalformedRecord) {
+logWarning(dropmalformedModeWarningMessage(record))
+isWarningPrintedForMalformedRecord = true
+  }
+  Nil
+} else {
+  throw new NotAllowedNullException(s"Null not allowed: $record")
--- End diff --

Sure, let me try to produce a better message.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

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



[GitHub] spark pull request #15329: [SPARK-17763][SQL] JacksonParser silently parses ...

2016-10-07 Thread yhuai
Github user yhuai commented on a diff in the pull request:

https://github.com/apache/spark/pull/15329#discussion_r82425780
  
--- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/json/JacksonParser.scala
 ---
@@ -114,6 +120,18 @@ class JacksonParser(
 }
   }
 
+  private def failedRecord(record: String): Seq[InternalRow] = {
+if (options.dropMalformed) {
+  if (!isWarningPrintedForMalformedRecord) {
+logWarning(dropmalformedModeWarningMessage(record))
+isWarningPrintedForMalformedRecord = true
+  }
+  Nil
+} else {
+  throw new NotAllowedNullException(s"Null not allowed: $record")
--- End diff --

Please explain why null is not allowed in the error message. Is it possible 
to know which field is not nullable? I am not sure if just printing the record 
is really helpful at here (considering users may often have long JSON records).


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

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



[GitHub] spark pull request #15329: [SPARK-17763][SQL] JacksonParser silently parses ...

2016-10-07 Thread yhuai
Github user yhuai commented on a diff in the pull request:

https://github.com/apache/spark/pull/15329#discussion_r82425563
  
--- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/json/JacksonParser.scala
 ---
@@ -34,6 +34,8 @@ import org.apache.spark.util.Utils
 
 private[sql] class SparkSQLJsonProcessingException(msg: String) extends 
RuntimeException(msg)
 
+private[sql] class NotAllowedNullException(msg: String) extends 
SparkSQLJsonProcessingException(msg)
--- End diff --

Why do we need this exception?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

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



[GitHub] spark pull request #15329: [SPARK-17763][SQL] JacksonParser silently parses ...

2016-10-03 Thread HyukjinKwon
GitHub user HyukjinKwon opened a pull request:

https://github.com/apache/spark/pull/15329

[SPARK-17763][SQL] JacksonParser silently parses null as 0 when the field 
is not nullable

## What changes were proposed in this pull request?

This PR proposes handling not nullable field properly in `JacksonParser`. 
For example, the codes below:

```scala
val testJson = """{"nullInt":null}""" :: Nil
val testSchema = StructType(StructField("nullInt", IntegerType, false) :: 
Nil)
val data = spark.sparkContext.parallelize(testJson)
spark.read.schema(testSchema).json(data).show()
```

prints

**Before**

```
+---+
|nullInt|
+---+
|  0|
+---+
```

**After**

```
org.apache.spark.sql.catalyst.json.NotAllowedNullException: Null not 
allowed: {"nullInt":null}
at 
org.apache.spark.sql.catalyst.json.JacksonParser.failedRecord(JacksonParser.scala:131)
at 
org.apache.spark.sql.catalyst.json.JacksonParser.parse(JacksonParser.scala:472)
...
```

## How was this patch tested?

Unit test in`JsonSuite`.



You can merge this pull request into a Git repository by running:

$ git pull https://github.com/HyukjinKwon/spark SPARK-17763

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/spark/pull/15329.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #15329


commit 88241865ac192a04270ab86b1be65f1b29466707
Author: hyukjinkwon 
Date:   2016-10-03T07:49:54Z

JacksonParser silently parses null as 0 when the field is not nullable




---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

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