-
Notifications
You must be signed in to change notification settings - Fork 2.5k
[HUDI-9248] Unify code paths for all write operations about bulk_insert #13360
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
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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 |
|---|---|---|
|
|
@@ -841,17 +841,9 @@ class HoodieSparkSqlWriterInternal { | |
| val instantTime = executor.getInstantTime | ||
|
|
||
| try { | ||
| val (writeSuccessful, compactionInstant, clusteringInstant) = mode match { | ||
| case _ if overwriteOperationType == null => | ||
| val syncHiveSuccess = metaSync(sqlContext.sparkSession, writeConfig, basePath, df.schema) | ||
| (syncHiveSuccess, HOption.empty().asInstanceOf[HOption[String]], HOption.empty().asInstanceOf[HOption[String]]) | ||
| case _ => | ||
| try { | ||
| commitAndPerformPostOperations(sqlContext.sparkSession, df.schema, writeResult, parameters, writeClient, tableConfig, jsc, | ||
| TableInstantInfo(basePath, instantTime, executor.getCommitActionType, executor.getWriteOperationType), Option.empty) | ||
|
|
||
| } | ||
| } | ||
| val (writeSuccessful, compactionInstant, clusteringInstant) = commitAndPerformPostOperations( | ||
|
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. is the change because of
Member
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. |
||
| sqlContext.sparkSession, df.schema, writeResult, parameters, writeClient, tableConfig, jsc, | ||
| TableInstantInfo(basePath, instantTime, executor.getCommitActionType, executor.getWriteOperationType), Option.empty) | ||
| (writeSuccessful, HOption.ofNullable(instantTime), compactionInstant, clusteringInstant, writeClient, tableConfig) | ||
| } finally { | ||
| // close the write client in all cases | ||
|
|
@@ -993,11 +985,13 @@ class HoodieSparkSqlWriterInternal { | |
| ): (Boolean, HOption[java.lang.String], HOption[java.lang.String]) = { | ||
| if (writeResult.getWriteStatuses.rdd.filter(ws => ws.hasErrors).count() == 0) { | ||
| log.info("Proceeding to commit the write.") | ||
| val metaMap = parameters.filter(kv => | ||
| kv._1.startsWith(parameters(COMMIT_METADATA_KEYPREFIX.key))) | ||
| // get extra metadata from props | ||
| // 1. properties starting with commit metadata key prefix | ||
| // 2. properties related to checkpoint in spark streaming | ||
| val extraMetadataOpt = common.util.Option.of(DataSourceUtils.getExtraMetadata(parameters.asJava)) | ||
| val commitSuccess = | ||
| client.commit(tableInstantInfo.instantTime, writeResult.getWriteStatuses, | ||
| common.util.Option.of(new java.util.HashMap[String, String](metaMap.asJava)), | ||
| extraMetadataOpt, | ||
| tableInstantInfo.commitActionType, | ||
| writeResult.getPartitionToReplaceFileIds, | ||
| common.util.Option.ofNullable(extraPreCommitFn.orNull)) | ||
|
|
@@ -1012,7 +1006,7 @@ class HoodieSparkSqlWriterInternal { | |
| val asyncCompactionEnabled = isAsyncCompactionEnabled(client, tableConfig, parameters, jsc.hadoopConfiguration()) | ||
| val compactionInstant: common.util.Option[java.lang.String] = | ||
| if (asyncCompactionEnabled) { | ||
| client.scheduleCompaction(common.util.Option.of(new java.util.HashMap[String, String](metaMap.asJava))) | ||
| client.scheduleCompaction(extraMetadataOpt) | ||
| } else { | ||
| common.util.Option.empty() | ||
| } | ||
|
|
@@ -1022,7 +1016,7 @@ class HoodieSparkSqlWriterInternal { | |
| val asyncClusteringEnabled = isAsyncClusteringEnabled(client, parameters) | ||
| val clusteringInstant: common.util.Option[java.lang.String] = | ||
| if (asyncClusteringEnabled) { | ||
| client.scheduleClustering(common.util.Option.of(new java.util.HashMap[String, String](metaMap.asJava))) | ||
| client.scheduleClustering(extraMetadataOpt) | ||
| } else { | ||
| common.util.Option.empty() | ||
| } | ||
|
|
||
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.
can you elaborate why logic is customized before for this executor?
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 think the timeline is like this.

First, there was a normal bulk insert logic, and at that time, the interface of data source v2 was directly used to perform writes.
Later, boneanxs proposed to use bulk insert to perform other operations such as overwrite, but the code path was not integrated at that time. Instead, the logic of this part was retained.
You can refer to: #8076