-
Notifications
You must be signed in to change notification settings - Fork 28.9k
[SPARK-26208][SQL] add headers to empty csv files when header=true #23173
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
koertkuipers
wants to merge
14
commits into
apache:master
from
tresata-opensource:feat-empty-csv-with-header
Closed
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
3192656
write headers to empty csv files when header=true
koertkuipers aad5f09
Merge branch 'master' into feat-empty-csv-with-header
koertkuipers 1f897be
add missing init overrides
koertkuipers bfadbf9
add missing init override
koertkuipers fd1ee62
Merge branch 'master' into feat-empty-csv-with-header
koertkuipers 258a1e4
provide default do-nothing implementation for OutputWriter.init
koertkuipers 088c710
cleanup test
koertkuipers 879be71
add repartition to test
koertkuipers 6f498a0
Merge branch 'master' into feat-empty-csv-with-header
koertkuipers 29fc6b8
remove init
koertkuipers 6165e1a
move code up so its clearer its part of constructor
koertkuipers 5e87e7e
dont check number of partitions
koertkuipers 238efa5
use lazy val for univocity generator
koertkuipers 9d5cb7b
Revert "use lazy val for univocity generator"
koertkuipers 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
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
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.
Wait .. is this going to create
UnivocityGeneratorfor each record?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.
Ah, it's
getOrElse. Okay but still can we simplify this logic? Looks a bit confusing. For instance, I think we can do this with lazy val.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.
@HyukjinKwon Do you mean creating generator in lazy val?
The problem is in the close method, you will have to call
univocityGenerator.close()in the method. If the lazy val wasn't instantiated before (empty partition and theheaderoption isfalse), the generator will be created and closed immediately. And as a result, you will get an empty file for the empty partition. That's why I prefer the approach withOption[UnivocityGenerator]in #23052.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 see the problem. OrcFileFormat uses a flag approach. For instance:
Should be okay to stick to it.
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.
ok i changed it to lazy val and flag
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.
Frankly speaking I don't see any reasons for this. For now we have 2 flags actually -
isGeneratorInitiatedand another one inside of lazy val. And 2 slightly different approaches - with theOptiontype in Json and Text, and lazy val + flag in Orc and CSV.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.
Yeah we have two different approaches, both of which are fine IMHO. I think it's reasonable to clean that up in a follow-up if desired. WDYT @HyukjinKwon ?
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 will revert this change to lazy val for now since it doesnt have anything to do wit this pullreq or jira: the Option approach was created in another pullreq.
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.
OK. Shouldn't be a big deal.