-
Notifications
You must be signed in to change notification settings - Fork 2.5k
[HUDI-3204] Fixing partition-values being derived from partition-path instead of source columns #5364
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
Merged
Merged
[HUDI-3204] Fixing partition-values being derived from partition-path instead of source columns #5364
Changes from 23 commits
Commits
Show all changes
37 commits
Select commit
Hold shift + click to select a range
f3cad46
Scaffolded `Spark24HoodieParquetFileFormat` extending `ParquetFileFor…
e2c6ce6
Amended `SparkAdapter`s `createHoodieParquetFileFormat` API to be abl…
49fe4b4
Fixing usages
ed396fe
Fallback to append partition values in cases when the source columns …
5c7dda4
Tidying up
6aaf861
Fixing tests
ceb5add
Fixing `HoodieBaseRelation` incorreclty handling mandatory columns
8f6a7e1
Rely on `SparkHoodieParquetFileFormat` by default instead of Spark's …
c040d5c
Fixing tests
20bf6c9
`SparkHoodieParquetFileFormat` > `HoodieParquetFileFormat`;
a94bcce
Tidying up `Spark31HoodieParquetFileFormat`
5d8e15e
Cleaning up `Spark31HoodieParquetFileFormat` impl (required for repli…
3bee902
Added handling for configurable appending of partitioned values
c1009b9
Fixing `Spark31HoodieParquetFileFormat` init seq
595a6db
Fixing compilation
ff25a23
Fixing tests compilation
ee7f3ef
Fixing NPEs
27d58e9
Downgrade logging w/in `HoodiePartitionMetadata` reader to avoid flur…
3dc0bd1
Sync'd `Spark32HoodieParquetFileFormat` to Spark 3.2.1 impl
8a8f18b
Fixed `Spark32HoodieParquetFileFormat` init seq
d5b99e6
Replicated changes from Spark 3.1 to `Spark32HoodieParquetFileFormat`
1548335
Tidying up
f4eaa8e
Restoring back `Spark312HoodieParquetFileFormat` (to ease up code rev…
ccc1546
Extracted schema related utils into `AvroSchemaUtils`
87b30e0
Fixed `TableSchemaResolver` to correctly create nullable field
3ffdf87
Tidying up
5a168d6
Log exceptions in cases of failure to resolve schema from the table
61dc421
Properly append partition values in cases when source columns are dro…
9353c8d
Fixing compilation
4f6a098
Tidying up
5dab226
Tidying up
d7215bb
Cleaned up partition column pruning flow
dc18eb4
Project rows from the pruned schema back into required one
e3cb6f8
Fixed incorrect projection
e56dcad
Fixed non-serializable task
f9e166e
Fixed test
64dd7b1
Make sure schema-evolution code-paths are bypassed
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
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 |
|---|---|---|
|
|
@@ -27,7 +27,7 @@ import org.apache.hudi.hadoop.HoodieROTablePathFilter | |
| import org.apache.spark.sql.SQLContext | ||
| import org.apache.spark.sql.catalyst.expressions.Expression | ||
| import org.apache.spark.sql.execution.datasources._ | ||
| import org.apache.spark.sql.execution.datasources.parquet.ParquetFileFormat | ||
| import org.apache.spark.sql.execution.datasources.parquet.{HoodieParquetFileFormat, ParquetFileFormat} | ||
| import org.apache.spark.sql.hive.orc.OrcFileFormat | ||
| import org.apache.spark.sql.sources.{BaseRelation, Filter} | ||
| import org.apache.spark.sql.types.StructType | ||
|
|
@@ -114,16 +114,38 @@ class BaseFileOnlyRelation(sqlContext: SQLContext, | |
| * rule; you can find more details in HUDI-3896) | ||
| */ | ||
| def toHadoopFsRelation: HadoopFsRelation = { | ||
| // We're delegating to Spark to append partition values to every row only in cases | ||
| // when these corresponding partition-values are not persisted w/in the data file itself | ||
| val shouldAppendPartitionColumns = omitPartitionColumnsInFile | ||
|
|
||
| val (tableFileFormat, formatClassName) = metaClient.getTableConfig.getBaseFileFormat match { | ||
| case HoodieFileFormat.PARQUET => (new ParquetFileFormat, "parquet") | ||
| case HoodieFileFormat.PARQUET => | ||
| (sparkAdapter.createHoodieParquetFileFormat(shouldAppendPartitionColumns).get, HoodieParquetFileFormat.FILE_FORMAT_ID) | ||
| case HoodieFileFormat.ORC => (new OrcFileFormat, "orc") | ||
| } | ||
|
|
||
| if (globPaths.isEmpty) { | ||
| // NOTE: There are currently 2 ways partition values could be fetched: | ||
| // - Source columns (producing the values used for physical partitioning) will be read | ||
| // from the data file | ||
| // - Values parsed from the actual partition pat would be appended to the final dataset | ||
|
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. typo: "pat"
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. Addressed in a follow-up |
||
| // | ||
| // In the former case, we don't need to provide the partition-schema to the relation, | ||
| // therefore we simply stub it w/ empty schema and use full table-schema as the one being | ||
| // read from the data file. | ||
| // | ||
| // In the latter, we have to specify proper partition schema as well as "data"-schema, essentially | ||
| // being a table-schema with all partition columns stripped out | ||
| val (partitionSchema, dataSchema) = if (shouldAppendPartitionColumns) { | ||
| (fileIndex.partitionSchema, fileIndex.dataSchema) | ||
| } else { | ||
| (StructType(Nil), tableStructSchema) | ||
| } | ||
|
|
||
| HadoopFsRelation( | ||
| location = fileIndex, | ||
| partitionSchema = fileIndex.partitionSchema, | ||
| dataSchema = fileIndex.dataSchema, | ||
| partitionSchema = partitionSchema, | ||
| dataSchema = dataSchema, | ||
| bucketSpec = None, | ||
| fileFormat = tableFileFormat, | ||
| optParams)(sparkSession) | ||
|
|
||
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
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
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
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.
minor. instead of "omitPartitionColumnsInFile" (present tense), may be we can name the variable as "isPartitionColumnPersistedInDataFile" (past tense).
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 call!
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.
@nsivabalan on a second thought -- this flag is actually directing whether we should be omitting partition columns when we persist in data files, so kept it as
omitPartitionColumnsto be aligned with the config value