Skip to content

Commit c7bf2c7

Browse files
authored
[HUDI-2709] Add more options when initializing table (#3939)
1 parent cf2ecd7 commit c7bf2c7

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

hudi-flink/src/main/java/org/apache/hudi/util/StreamerUtil.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import org.apache.hudi.common.engine.EngineType;
2929
import org.apache.hudi.common.fs.FSUtils;
3030
import org.apache.hudi.common.model.HoodieCleaningPolicy;
31+
import org.apache.hudi.common.table.HoodieTableConfig;
3132
import org.apache.hudi.common.table.HoodieTableMetaClient;
3233
import org.apache.hudi.common.table.log.HoodieLogFormat;
3334
import org.apache.hudi.common.table.timeline.HoodieActiveTimeline;
@@ -210,7 +211,6 @@ public static HoodieWriteConfig getHoodieClientConfig(
210211
.withPayloadOrderingField(conf.getString(FlinkOptions.PRECOMBINE_FIELD))
211212
.withPayloadEventTimeField(conf.getString(FlinkOptions.PRECOMBINE_FIELD))
212213
.build())
213-
.withKeyGenerator(conf.getString(FlinkOptions.KEYGEN_CLASS_NAME)) // needed by TwoToThreeUpgradeHandler
214214
.withEmbeddedTimelineServerEnabled(enableEmbeddedTimelineService)
215215
.withEmbeddedTimelineServerReuseEnabled(true) // make write client embedded timeline service singleton
216216
.withAutoCommit(false)
@@ -239,6 +239,8 @@ public static TypedProperties flinkConf2TypedProperties(Configuration conf) {
239239
Properties properties = new Properties();
240240
// put all the set options
241241
flatConf.addAllToProperties(properties);
242+
// ugly: table keygen clazz, needed by TwoToThreeUpgradeHandler
243+
properties.put(HoodieTableConfig.KEY_GENERATOR_CLASS_NAME.key(), conf.getString(FlinkOptions.KEYGEN_CLASS_NAME));
242244
// put all the default options
243245
for (ConfigOption<?> option : FlinkOptions.optionalOptions()) {
244246
if (!flatConf.contains(option) && option.hasDefaultValue()) {
@@ -268,9 +270,12 @@ public static HoodieTableMetaClient initTableIfNotExists(Configuration conf) thr
268270
.setTableName(conf.getString(FlinkOptions.TABLE_NAME))
269271
.setRecordKeyFields(conf.getString(FlinkOptions.RECORD_KEY_FIELD, null))
270272
.setPayloadClassName(conf.getString(FlinkOptions.PAYLOAD_CLASS_NAME))
273+
.setPreCombineField(OptionsResolver.getPreCombineField(conf))
271274
.setArchiveLogFolder(ARCHIVELOG_FOLDER.defaultValue())
272275
.setPartitionFields(conf.getString(FlinkOptions.PARTITION_PATH_FIELD, null))
273-
.setPreCombineField(conf.getString(FlinkOptions.PRECOMBINE_FIELD))
276+
.setKeyGeneratorClassProp(conf.getString(FlinkOptions.KEYGEN_CLASS_NAME))
277+
.setHiveStylePartitioningEnable(conf.getBoolean(FlinkOptions.HIVE_STYLE_PARTITIONING))
278+
.setUrlEncodePartitioning(conf.getBoolean(FlinkOptions.URL_ENCODE_PARTITIONING))
274279
.setTimelineLayoutVersion(1)
275280
.initTable(hadoopConf, basePath);
276281
LOG.info("Table initialized under base path {}", basePath);

0 commit comments

Comments
 (0)