Skip to content

Commit 7307ff3

Browse files
authored
[HUDI-4447] fix no partitioned path extractor error when sync meta (apache#6263)
1 parent 3042b2c commit 7307ff3

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

hudi-sync/hudi-sync-common/src/main/java/org/apache/hudi/sync/common/HoodieSyncConfig.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public class HoodieSyncConfig extends HoodieConfig {
8686
.key("hoodie.datasource.hive_sync.partition_extractor_class")
8787
.defaultValue("org.apache.hudi.hive.SlashEncodedDayPartitionValueExtractor")
8888
.withInferFunction(cfg -> {
89-
if (cfg.contains(KeyGeneratorOptions.PARTITIONPATH_FIELD_NAME)) {
89+
if (StringUtils.nonEmpty(cfg.getString(KeyGeneratorOptions.PARTITIONPATH_FIELD_NAME))) {
9090
int numOfPartFields = cfg.getString(KeyGeneratorOptions.PARTITIONPATH_FIELD_NAME).split(",").length;
9191
if (numOfPartFields == 1
9292
&& cfg.contains(KeyGeneratorOptions.HIVE_STYLE_PARTITIONING_ENABLE)

hudi-sync/hudi-sync-common/src/test/java/org/apache/hudi/sync/common/TestHoodieSyncConfig.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,12 @@ void testInferPartitonExtractorClass() {
100100
HoodieSyncConfig config3 = new HoodieSyncConfig(new Properties(), new Configuration());
101101
assertEquals("org.apache.hudi.hive.NonPartitionedExtractor",
102102
config3.getStringOrDefault(META_SYNC_PARTITION_EXTRACTOR_CLASS));
103+
104+
Properties props4 = new Properties();
105+
props4.setProperty(KeyGeneratorOptions.PARTITIONPATH_FIELD_NAME.key(), "");
106+
HoodieSyncConfig config4 = new HoodieSyncConfig(props4, new Configuration());
107+
assertEquals("org.apache.hudi.hive.NonPartitionedExtractor",
108+
config4.getStringOrDefault(META_SYNC_PARTITION_EXTRACTOR_CLASS));
103109
}
104110

105111
@Test

0 commit comments

Comments
 (0)