-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-25134][SQL] Csv column pruning with checking of headers throws incorrect error #22123
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 5 commits
dcd9ac4
c4179a9
09c986c
cd18ed2
f2eb1df
667db3c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1603,6 +1603,39 @@ class CSVSuite extends QueryTest with SharedSQLContext with SQLTestUtils with Te | |
| .exists(msg => msg.getRenderedMessage.contains("CSV header does not conform to the schema"))) | ||
| } | ||
|
|
||
| test("SPARK-25134: check header on parsing of dataset with projection and column pruning") { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also need a test case for checking enforceSchema works well when column pruning is on.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it seems enforceSchema always kind of "works" because it simply means it ignores the headers. |
||
| withSQLConf(SQLConf.CSV_PARSER_COLUMN_PRUNING.key -> "true") { | ||
| Seq(false, true).foreach { multiLine => | ||
| withTempPath { path => | ||
| val dir = path.getAbsolutePath | ||
| Seq(("a", "b")).toDF("columnA", "columnB").write | ||
| .format("csv") | ||
| .option("header", true) | ||
| .save(dir) | ||
|
|
||
| // schema with one column | ||
| checkAnswer(spark.read | ||
| .format("csv") | ||
| .option("header", true) | ||
| .option("enforceSchema", false) | ||
| .option("multiLine", multiLine) | ||
| .load(dir) | ||
| .select("columnA"), | ||
| Row("a")) | ||
|
|
||
| // empty schema | ||
| assert(spark.read | ||
| .format("csv") | ||
| .option("header", true) | ||
| .option("enforceSchema", false) | ||
| .option("multiLine", multiLine) | ||
| .load(dir) | ||
| .count() === 1L) | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| test("SPARK-24645 skip parsing when columnPruning enabled and partitions scanned only") { | ||
| withSQLConf(SQLConf.CSV_PARSER_COLUMN_PRUNING.key -> "true") { | ||
| withTempPath { path => | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: the following code style is preferred.