xushiyan commented on code in PR #6333:
URL: https://github.com/apache/hudi/pull/6333#discussion_r940540624


##########
hudi-sync/hudi-sync-common/src/main/java/org/apache/hudi/sync/common/HoodieSyncConfig.java:
##########
@@ -79,24 +82,29 @@ public class HoodieSyncConfig extends HoodieConfig {
   public static final ConfigProperty<String> META_SYNC_BASE_FILE_FORMAT = 
ConfigProperty
       .key("hoodie.datasource.hive_sync.base_file_format")
       .defaultValue("PARQUET")
-      .withInferFunction(cfg -> 
Option.ofNullable(cfg.getString(HoodieTableConfig.BASE_FILE_FORMAT)))
+      .withInferFunction(cfg -> 
Option.ofNullable(cfg.getString(BASE_FILE_FORMAT)))
       .withDocumentation("Base file format for the sync.");
 
   public static final ConfigProperty<String> META_SYNC_PARTITION_FIELDS = 
ConfigProperty
       .key("hoodie.datasource.hive_sync.partition_fields")
       .defaultValue("")
-      .withInferFunction(cfg -> 
Option.ofNullable(cfg.getString(KeyGeneratorOptions.PARTITIONPATH_FIELD_NAME)))
+      .withInferFunction(cfg -> 
Option.ofNullable(cfg.getString(PARTITIONPATH_FIELD_NAME))
+          .or(() -> Option.ofNullable(cfg.getString(PARTITION_FIELDS))))
       .withDocumentation("Field in the table to use for determining hive 
partition columns.");
 
   public static final ConfigProperty<String> 
META_SYNC_PARTITION_EXTRACTOR_CLASS = ConfigProperty
       .key("hoodie.datasource.hive_sync.partition_extractor_class")
       .defaultValue("org.apache.hudi.hive.MultiPartKeysValueExtractor")
       .withInferFunction(cfg -> {
-        if 
(StringUtils.nonEmpty(cfg.getString(KeyGeneratorOptions.PARTITIONPATH_FIELD_NAME)))
 {
-          int numOfPartFields = 
cfg.getString(KeyGeneratorOptions.PARTITIONPATH_FIELD_NAME).split(",").length;
+        if (cfg.contains(PARTITION_FIELDS) && 
!cfg.getString(PARTITION_FIELDS).equals(cfg.getString(PARTITIONPATH_FIELD_NAME)))
 {
+          LOG.warn(String.format("%s and %s have different values. Setting 
default partition extractor that is MultiPartKeysValueExtractor", 
PARTITION_FIELDS.key(), PARTITIONPATH_FIELD_NAME));
+          return Option.of("org.apache.hudi.hive.MultiPartKeysValueExtractor");

Review Comment:
   Should use `Objects.equals()` and because we want to abort inferring, need 
to return `Option.empty()`



-- 
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]

Reply via email to