nsivabalan commented on code in PR #13046:
URL: https://github.com/apache/hudi/pull/13046#discussion_r2019628251
##########
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/table/upgrade/EightToSevenDowngradeHandler.java:
##########
@@ -161,19 +166,27 @@ static void unsetInitialVersion(HoodieTableConfig
tableConfig, Map<ConfigPropert
tableConfig.getProps().remove(HoodieTableConfig.INITIAL_VERSION.key());
}
- static void unsetRecordMergeMode(HoodieTableConfig tableConfig,
Map<ConfigProperty, String> tablePropsToAdd) {
- Triple<RecordMergeMode, String, String> mergingConfigs =
- HoodieTableConfig.inferCorrectMergingBehavior(
- tableConfig.getRecordMergeMode(), tableConfig.getPayloadClass(),
- tableConfig.getRecordMergeStrategyId(),
tableConfig.getPreCombineField(),
- tableConfig.getTableVersion());
- if (StringUtils.nonEmpty(mergingConfigs.getMiddle())) {
- tablePropsToAdd.put(HoodieTableConfig.PAYLOAD_CLASS_NAME,
mergingConfigs.getMiddle());
- }
- if (StringUtils.nonEmpty(mergingConfigs.getRight())) {
- tablePropsToAdd.put(HoodieTableConfig.RECORD_MERGE_STRATEGY_ID,
mergingConfigs.getRight());
+ static List<ConfigProperty> unsetRecordMergeMode(HoodieWriteConfig config,
HoodieTableConfig tableConfig, Map<ConfigProperty, String> tablePropsToAdd) {
+ String payloadClass = tableConfig.getPayloadClass();
+ if (StringUtils.isNullOrEmpty(payloadClass)) {
+ RecordMergeMode mergeMode = tableConfig.getRecordMergeMode();
+ switch (mergeMode) {
+ case EVENT_TIME_ORDERING:
+ tablePropsToAdd.put(HoodieTableConfig.PAYLOAD_CLASS_NAME,
DefaultHoodieRecordPayload.class.getName());
+ break;
+ case COMMIT_TIME_ORDERING:
+ tablePropsToAdd.put(HoodieTableConfig.PAYLOAD_CLASS_NAME,
OverwriteWithLatestAvroPayload.class.getName());
+ break;
+ case CUSTOM:
+ throw new HoodieUpgradeDowngradeException("Custom payload class must
be available for downgrading custom merge mode");
+ default:
+ throw new HoodieUpgradeDowngradeException("Downgrade is not handled
for " + mergeMode);
+ }
}
- tableConfig.getProps().remove(HoodieTableConfig.RECORD_MERGE_MODE.key());
+ tablePropsToAdd.put(
+ HoodieTableConfig.RECORD_MERGE_STRATEGY_ID,
Review Comment:
this is going to be tricky.
when we downgrade from table version 8 to 6, how do we know which
writer/binary user might be using.
is it 1.0, or 0.15.0 or 0.14.2.
so, may not be easy to set the right config key here.
from what I see
in 0.14.1, 0.14.2 and 0.15.0, we use
"hoodie.compaction.record.merger.strategy"
and in 1.0 v6, we use HoodieTableConfig.RECORD_MERGE_STRATEGY_ID ie
"hoodie.record.merge.strategy.id".
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]