Github user HyukjinKwon commented on a diff in the pull request:
https://github.com/apache/spark/pull/18200#discussion_r120642608
--- Diff:
sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/csv/CSVSuite.scala
---
@@ -1174,4 +1174,12 @@ class CSVSuite extends QueryTest with
SharedSQLContext with SQLTestUtils {
}
}
}
+
+ test("SPARK-20978: Set null for malformed column when the number of
tokens is less than schema") {
+ val df = spark.read
+ .schema("a string, b string, unparsed string")
+ .option("columnNameOfCorruptRecord", "unparsed")
+ .csv(Seq("a").toDS())
+ checkAnswer(df, Row("a", null, null))
--- End diff --
BTW, it is true that there is inconsistency in parse mode between JSON and
CSV. These are, up to me knowledge, mostly due to backwards compatibility and
legacy reason (nevertheless, I guess there was a value of adding this to JSON).
For example, parse modes has existed since CSV was a thirdparty, the parse
mode was introduced in JSON to Spark and the original behaviour was treated as
permissive mode, which is (strictly) inconsistent with CSV's one where it fills
the partial results in the record.
In Spark 3.0, probably, we could redefine the behaviour to be consistent.
---
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 [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]