Skip to content

Commit

Permalink
seperate test
Browse files Browse the repository at this point in the history
  • Loading branch information
wzhfy committed Mar 28, 2020
1 parent bdc3d77 commit cbb8743
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1895,13 +1895,20 @@ abstract class CSVSuite extends QueryTest with SharedSparkSession with TestCsvDa
checkAnswer(spark.read.schema(schema).csv(input), Row(null))
checkAnswer(spark.read.option("multiLine", true).schema(schema).csv(input), Row(null))
assert(spark.read.csv(input).collect().toSet == Set(Row()))
}

test("SPARK-31261: bad csv input with `columnNameCorruptRecord` should not cause NPE") {
val schema = StructType(
StructField("a", IntegerType) :: StructField("_corrupt_record", StringType) :: Nil)
val input = spark.createDataset(Seq("\u0000\u0000\u0001234"))

val schemaWithCorruptField = schema.add("_corrupt_record", StringType)
checkAnswer(
spark.read
.option("columnNameOfCorruptRecord", "_corrupt_record")
.schema(schemaWithCorruptField).csv(input),
.schema(schema)
.csv(input),
Row(null, null))
assert(spark.read.csv(input).collect().toSet == Set(Row()))
}

test("field names of inferred schema shouldn't compare to the first row") {
Expand Down

0 comments on commit cbb8743

Please sign in to comment.