Github user HyukjinKwon commented on a diff in the pull request:
https://github.com/apache/spark/pull/12268#discussion_r59180459
--- Diff:
sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/csv/CSVParserSuite.scala
---
@@ -1,125 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.spark.sql.execution.datasources.csv
-
-import org.apache.spark.SparkFunSuite
-
-/**
- * test cases for StringIteratorReader
- */
-class CSVParserSuite extends SparkFunSuite {
--- End diff --
Actually, I was a bit worried (and confused) of the range for tests.
`CSVParserSuite` was testing the conversion from `Iterator` to `Reader` which
does not exist now. So, I was thinking test codes in `UnivocityParser` and
`UnivocityGenerator` because they are new classes anyway.
But while trying to add some mode test codes, I realised that it ends up
with an end-to-end just as below:
```scala
test("Parse csv data correctly with univocity parser") {
val cars = sparkContext.textFile(testFile("cars.csv"))
val schema = StructType(
StructField("year", IntegerType) ::
StructField("make", StringType) ::
StructField("model", StringType) ::
StructField("comment", StringType) ::
StructField("blank", StringType) :: Nil)
val requiredSchema = StructType(
StructField("year", IntegerType) ::
StructField("make", StringType) ::
StructField("model", StringType) :: Nil)
val headers = schema.fields.map(_.name)
val options = new CSVOptions(Map.empty)
val filteredCars = cars.filter(_.nonEmpty)
val firstLine = filteredCars.first()
val dropHeaderCars = cars.filter(_ != firstLine)
val parsedCars = UnivocityParser.parse(
dropHeaderCars,
schema,
requiredSchema,
headers,
options).collect()
val expectedCars = Seq(
new GenericMutableRow(
Array(2012, UTF8String.fromString("Tesla"),
UTF8String.fromString("S"))),
new GenericMutableRow(
Array(1997, UTF8String.fromString("Ford"),
UTF8String.fromString("E350"))),
new GenericMutableRow(
Array(2015, UTF8String.fromString("Chevy"),
UTF8String.fromString("Vold"))))
assert(parsedCars === expectedCars)
}
```
---
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]