-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-15264][SPARK-15274][SQL] CSV Reader Error on Blank Column Names #13041
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
Closed
Closed
Changes from 2 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
17b3c58
fix SPARK-15264, add test cases
85d0843
Rename test case
bllchmbrs 0ed0b4c
Fix according to @andrewor14 comments, rename C0 to _c0, fix null checks
e380f32
Merge branch 'master' of github.com:anabranch/spark
d665bea
fix tests
d983718
fix python test failure
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -61,7 +61,9 @@ class DefaultSource extends FileFormat with DataSourceRegister { | |
| val firstRow = new LineCsvReader(csvOptions).parseLine(firstLine) | ||
|
|
||
| val header = if (csvOptions.headerFlag) { | ||
| firstRow | ||
| firstRow.zipWithIndex.map { case (value, index) => | ||
| if (value == "" || value == null) s"C$index" else value | ||
| } | ||
| } else { | ||
| firstRow.zipWithIndex.map { case (value, index) => s"C$index" } | ||
|
||
| } | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| "",,make,customer,comment | ||
| 2012,"Tesla","S","bill","blank" | ||
| 2013,"Tesla","S","c","something" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I see Spark allows a empty string as a field. So, I wonder if we should rename this with the index and prefix,
C. Also, I think""will throw an NPE whereas empty string without quotes will produce a correct field because the default ofnullValueis"".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.
This code does rename it with the index and prefix,
C.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.
I mean if one of values in the header is a empty string then, I think the field name should be a empty string since apparently it works with fields named empty strings. I tested this by manually giving a schema.
Also, If the header is used for schema, then I think the names should be as they are. We don't really change field names specified in ORC, Parquet or JSON.