Github user maropu commented on a diff in the pull request:

    https://github.com/apache/spark/pull/18250#discussion_r121567491
  
    --- Diff: 
sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/csv/CSVSuite.scala
 ---
    @@ -1174,4 +1174,33 @@ class CSVSuite extends QueryTest with 
SharedSQLContext with SQLTestUtils {
             }
           }
       }
    +
    +  test("SPARK-21024 CSV parser mode controls parser exceptions") {
    +    withTempPath { path =>
    +      Seq("0,1", "0,1,2,3").toDF().write.text(path.getAbsolutePath)
    +
    +      Seq(false).foreach { wholeFile =>
    +        val msg = intercept[SparkException] {
    +          spark.read.format("csv")
    +            .schema("a INT, b INT")
    +            .option("maxColumns", "2")
    +            .option("mode", "FAILFAST")
    +            .option("wholeFile", wholeFile)
    +            .load(path.getAbsolutePath)
    +            .collect
    +        }.getMessage
    +        assert(msg.contains("Number of columns processed may have exceeded 
limit of 2 columns."))
    +
    +        val columnNameOfCorruptRecord = "_unparsed"
    +        val df = spark.read.format("csv")
    +          .schema(s"a INT, b INT, $columnNameOfCorruptRecord STRING")
    +          .option("maxColumns", "2")
    +          .option("mode", "PERMISSIVE")
    +          .option("columnNameOfCorruptRecord", columnNameOfCorruptRecord)
    +          .option("wholeFile", wholeFile)
    +          .load(path.getAbsolutePath)
    +        checkAnswer(df, Row(0, 1, null) :: Row(null, null, "0,1,2,") :: 
Nil)
    --- End diff --
    
    @HyukjinKwon weird behaviour..., when we set `maxColumns` in a Univocity 
parser, it seems `currentParsedContent` returns the (`maxColumns` + 1) elements 
in inputs.


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

Reply via email to