-
Notifications
You must be signed in to change notification settings - Fork 28.9k
[SPARK-30338][SQL] Avoid unnecessary InternalRow copies in ParquetRowConverter #26993
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
JoshRosen
wants to merge
9
commits into
apache:master
from
JoshRosen:joshrosen/faster-parquet-nested-scan-by-avoiding-copies
Closed
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
d831414
Add new "array of struct" test case to ParquetIOSuite
joshrosen-stripe ed894b4
Avoid unnecessary copy of nested internal rows.
JoshRosen 2ed8ea9
Add comments.
JoshRosen 3fb3391
More specific cast; add braces.
JoshRosen e67327a
Update tests to match existing style; strengthen map test
JoshRosen fffe72b
Add test for struct as map key type
JoshRosen e6945e8
Add JIRA number to comment
JoshRosen 4651b2f
Re-word code comment based on review feedback.
joshrosen-stripe 0f1af94
Add test case for array of nested struct
joshrosen-stripe 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -204,6 +204,42 @@ class ParquetIOSuite extends QueryTest with ParquetTest with SharedSparkSession | |
| } | ||
| } | ||
|
|
||
| testStandardAndLegacyModes("array of struct") { | ||
|
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. Do we have a test for array of struct of struct?
Contributor
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. I added a new test case for this in 0f1af94 |
||
| val data = (1 to 4).map { i => | ||
| Tuple1( | ||
| Seq( | ||
| Tuple1(s"1st_val_$i"), | ||
| Tuple1(s"2nd_val_$i") | ||
| ) | ||
| ) | ||
| } | ||
| withParquetDataFrame(data) { df => | ||
| // Structs are converted to `Row`s | ||
| checkAnswer(df, data.map { case Tuple1(array) => | ||
| Row(array.map(struct => Row(struct.productIterator.toSeq: _*))) | ||
| }) | ||
| } | ||
| } | ||
|
|
||
| testStandardAndLegacyModes("array of nested struct") { | ||
| val data = (1 to 4).map { i => | ||
| Tuple1( | ||
| Seq( | ||
| Tuple1( | ||
| Tuple1(s"1st_val_$i")), | ||
| Tuple1( | ||
| Tuple1(s"2nd_val_$i")) | ||
| ) | ||
| ) | ||
| } | ||
| withParquetDataFrame(data) { df => | ||
| // Structs are converted to `Row`s | ||
| checkAnswer(df, data.map { case Tuple1(array) => | ||
| Row(array.map { case Tuple1(Tuple1(str)) => Row(Row(str))}) | ||
| }) | ||
| } | ||
| } | ||
|
|
||
| testStandardAndLegacyModes("nested struct with array of array as field") { | ||
| val data = (1 to 4).map(i => Tuple1((i, Seq(Seq(s"val_$i"))))) | ||
| withParquetDataFrame(data) { df => | ||
|
|
@@ -214,9 +250,34 @@ class ParquetIOSuite extends QueryTest with ParquetTest with SharedSparkSession | |
| } | ||
| } | ||
|
|
||
| testStandardAndLegacyModes("nested map with struct as key type") { | ||
| val data = (1 to 4).map { i => | ||
| Tuple1( | ||
| Map( | ||
| (i, s"kA_$i") -> s"vA_$i", | ||
| (i, s"kB_$i") -> s"vB_$i" | ||
| ) | ||
| ) | ||
| } | ||
| withParquetDataFrame(data) { df => | ||
| // Structs are converted to `Row`s | ||
| checkAnswer(df, data.map { case Tuple1(m) => | ||
| Row(m.map { case (k, v) => Row(k.productIterator.toSeq: _*) -> v }) | ||
| }) | ||
| } | ||
| } | ||
|
|
||
| testStandardAndLegacyModes("nested map with struct as value type") { | ||
| val data = (1 to 4).map(i => Tuple1(Map(i -> ((i, s"val_$i"))))) | ||
| val data = (1 to 4).map { i => | ||
| Tuple1( | ||
| Map( | ||
| s"kA_$i" -> ((i, s"vA_$i")), | ||
| s"kB_$i" -> ((i, s"vB_$i")) | ||
| ) | ||
| ) | ||
| } | ||
| withParquetDataFrame(data) { df => | ||
| // Structs are converted to `Row`s | ||
| checkAnswer(df, data.map { case Tuple1(m) => | ||
| Row(m.mapValues(struct => Row(struct.productIterator.toSeq: _*))) | ||
| }) | ||
|
|
||
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.
@JoshRosen, no big deal at all but how about we put the JIRA ID somewhere in the comment?
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.
Good idea: I added a JIRA reference in e6945e8