Github user marmbrus commented on a diff in the pull request: https://github.com/apache/spark/pull/13727#discussion_r67573034 --- Diff: sql/core/src/test/scala/org/apache/spark/sql/test/DataFrameReaderWriterSuite.scala --- @@ -228,4 +220,101 @@ class DataFrameReaderWriterSuite extends QueryTest with SharedSQLContext { } } } + + test("load API") { + spark.read.format("org.apache.spark.sql.test").load() + spark.read.format("org.apache.spark.sql.test").load(input) + spark.read.format("org.apache.spark.sql.test").load(input, input, input) + spark.read.format("org.apache.spark.sql.test").load(Seq(input, input): _*) + Option(input).map(spark.read.format("org.apache.spark.sql.test").load) + } + + test("text - API and common behavior") { + // Reader, without user specified schema + assert(spark.read.text().schema === textSchema) + assert(spark.read.text(input).schema === textSchema) + assert(spark.read.text(input, input, input).schema === textSchema) + assert(spark.read.text(Seq(input, input): _*).schema === textSchema) + assert(Option(input).map(spark.read.text).get.schema === textSchema) // SPARK-16009 + + // Reader, with user specified schema + assert(spark.read.schema(userSchema).text().schema === userSchema) + assert(spark.read.schema(userSchema).text(input).schema === userSchema) + assert(spark.read.schema(userSchema).text(input, input, input).schema === userSchema) + assert(spark.read.schema(userSchema).text(Seq(input, input): _*).schema === userSchema) + + // Writer + spark.read.text().write.text(output) + } + + test("textFile - API and common behavior") { + // Reader, without user specified schema + assert(spark.read.textFile().schema === textSchema) + assert(spark.read.textFile(input).schema === textSchema) + assert(spark.read.textFile(input, input, input).schema === textSchema) + assert(spark.read.textFile(Seq(input, input): _*).schema === textSchema) + assert(Option(input).map(spark.read.textFile).get.schema === textSchema) // SPARK-16009 + } + + test("csv - API and common behavior") { + // Reader, with user specified schema + // Refer to csv-specific test suites for behavior without user specified schema + assert(spark.read.schema(userSchema).csv().schema === userSchema) + assert(spark.read.schema(userSchema).csv(input).schema === userSchema) + assert(spark.read.schema(userSchema).csv(input, input, input).schema === userSchema) + assert(spark.read.schema(userSchema).csv(Seq(input, input): _*).schema === userSchema) + + // Test explicit calls to single arg method - SPARK-16009 + assert(Option(input).map(spark.read.schema(userSchema).csv).get.schema === userSchema) + + // Writer + spark.range(10).write.csv(output) + } + + test("json - API and common behavior") { + // Reader, with user specified schema + // Refer to csv-specific test suites for behavior without user specified schema + assert(spark.read.schema(userSchema).json().schema === userSchema) + assert(spark.read.schema(userSchema).json(input).schema === userSchema) + assert(spark.read.schema(userSchema).json(input, input, input).schema === userSchema) + assert(spark.read.schema(userSchema).json(Seq(input, input): _*).schema === userSchema) + + // Test explicit calls to single arg method - SPARK-16009 + assert(Option(input).map(spark.read.schema(userSchema).json).get.schema === userSchema) + + // Writer + spark.range(10).write.json(output) + } + + test("parquet - API and common behavior") { + // Reader, with user specified schema + // Refer to csv-specific test suites for behavior without user specified schema + assert(spark.read.schema(userSchema).parquet().schema === userSchema) + assert(spark.read.schema(userSchema).parquet(input).schema === userSchema) + assert(spark.read.schema(userSchema).parquet(input, input, input).schema === userSchema) + assert(spark.read.schema(userSchema).parquet(Seq(input, input): _*).schema === userSchema) + + // Test explicit calls to single arg method - SPARK-16009 + assert(Option(input).map(spark.read.schema(userSchema).parquet).get.schema === userSchema) + + // Writer + spark.range(10).write.parquet(output) --- End diff -- should we checkAnswer on these there possible? a lot of errors only manifest on `collect()`
--- 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