-
Notifications
You must be signed in to change notification settings - Fork 28.9k
[SPARK-8848] [SQL] Refactors Parquet write path to follow parquet-format #8988
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
liancheng
wants to merge
12
commits into
apache:master
from
liancheng:spark-8848/standard-parquet-write-path
Closed
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
d1583f8
Refactors Parquet write path to follow parquet-format
liancheng 6fd20f7
Optimizes writing low precision decimals
liancheng d395bfd
Fixes bug in reading UDTs under standard mode
liancheng a680f09
Stops using MutableRow when writing maps to avoid boxing
liancheng 5b08a20
Removes more dead code
liancheng f03ef93
Fixes a bug when writing small decimals coming from rows that are not…
liancheng 2bc5ebc
Addresses comments
liancheng c542ae9
Fixes comment typo and removes an unused import
liancheng af50f9c
One more dead code :)
liancheng e67d0b1
Fixes test cases
liancheng db79fb6
Addresses comments
liancheng fb6ee9f
Removes redundant test case
liancheng 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -95,7 +95,9 @@ private[parquet] class CatalystReadSupport extends ReadSupport[InternalRow] with | |
| """.stripMargin | ||
| } | ||
|
|
||
| new CatalystRecordMaterializer(parquetRequestedSchema, catalystRequestedSchema) | ||
| new CatalystRecordMaterializer( | ||
| parquetRequestedSchema, | ||
| CatalystReadSupport.expandUDT(catalystRequestedSchema)) | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -110,7 +112,10 @@ private[parquet] object CatalystReadSupport { | |
| */ | ||
| def clipParquetSchema(parquetSchema: MessageType, catalystSchema: StructType): MessageType = { | ||
| val clippedParquetFields = clipParquetGroupFields(parquetSchema.asGroupType(), catalystSchema) | ||
| Types.buildMessage().addFields(clippedParquetFields: _*).named("root") | ||
| Types | ||
| .buildMessage() | ||
| .addFields(clippedParquetFields: _*) | ||
| .named(CatalystSchemaConverter.SPARK_PARQUET_SCHEMA_NAME) | ||
| } | ||
|
|
||
| private def clipParquetType(parquetType: Type, catalystType: DataType): Type = { | ||
|
|
@@ -271,4 +276,30 @@ private[parquet] object CatalystReadSupport { | |
| .getOrElse(toParquet.convertField(f)) | ||
| } | ||
| } | ||
|
|
||
| def expandUDT(schema: StructType): StructType = { | ||
| def expand(dataType: DataType): DataType = { | ||
| dataType match { | ||
| case t: ArrayType => | ||
| t.copy(elementType = expand(t.elementType)) | ||
|
|
||
| case t: MapType => | ||
| t.copy( | ||
| keyType = expand(t.keyType), | ||
| valueType = expand(t.valueType)) | ||
|
|
||
| case t: StructType => | ||
| val expandedFields = t.fields.map(f => f.copy(dataType = expand(f.dataType))) | ||
| t.copy(fields = expandedFields) | ||
|
|
||
| case t: UserDefinedType[_] => | ||
| t.sqlType | ||
|
|
||
| case t => | ||
| t | ||
| } | ||
| } | ||
|
|
||
| expand(schema).asInstanceOf[StructType] | ||
| } | ||
|
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. Not sure whether this method is useful enough to be added as methods of all complex data types.
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. Maybe not. |
||
| } | ||
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
Oops, something went wrong.
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.
Expands UDTs early so that
CatalystRowConverteralways receive a Catalyst schema without UDTs.