[HUDI-6804] Fix hive read schema evolution MOR table#9573
Merged
danny0405 merged 2 commits intoapache:masterfrom Sep 5, 2023
Merged
[HUDI-6804] Fix hive read schema evolution MOR table#9573danny0405 merged 2 commits intoapache:masterfrom
danny0405 merged 2 commits intoapache:masterfrom
Conversation
Contributor
|
@Zouxxyy |
Contributor
Author
The core change is hudi 0.11 may not have this patch #6989 and #6358 /**
* Get final Read Schema for support evolution.
* step1: find the fileSchema for current dataBlock.
* step2: determine whether fileSchema is compatible with the final read internalSchema.
* step3: merge fileSchema and read internalSchema to produce final read schema.
*
* @param dataBlock current processed block
* @return final read schema.
*/
private Option<Pair<Function<HoodieRecord, HoodieRecord>, Schema>> composeEvolvedSchemaTransformer(
HoodieDataBlock dataBlock) {
if (internalSchema.isEmptySchema()) {
return Option.empty();
}
long currentInstantTime = Long.parseLong(dataBlock.getLogBlockHeader().get(INSTANT_TIME));
InternalSchema fileSchema = InternalSchemaCache.searchSchemaAndCache(currentInstantTime,
hoodieTableMetaClient, false);
InternalSchema mergedInternalSchema = new InternalSchemaMerger(fileSchema, internalSchema,
true, false).mergeSchema();
Schema mergedAvroSchema = AvroInternalSchemaConverter.convert(mergedInternalSchema, readerSchema.getFullName());
return Option.of(Pair.of((record) -> {
return record.rewriteRecordWithNewSchema(
dataBlock.getSchema(),
this.hoodieTableMetaClient.getTableConfig().getProps(),
mergedAvroSchema,
Collections.emptyMap());
}, mergedAvroSchema));
} |
xiarixiaoyao
approved these changes
Aug 30, 2023
Collaborator
prashantwason
pushed a commit
that referenced
this pull request
Sep 13, 2023
leosanqing
pushed a commit
to leosanqing/hudi
that referenced
this pull request
Sep 13, 2023
TheR1sing3un
pushed a commit
to TheR1sing3un/hudi
that referenced
this pull request
Feb 12, 2025
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Change Logs
Current hive read schema evolution MOR table will error, e.g. :
Impact
Fix above
Risk level (write none, low medium or high below)
low
Documentation Update
None
Contributor's checklist