Skip to content
Permalink
Browse files
[HUDI-4260] Change KEYGEN_CLASS_NAME without default value (#5877)
* Change KEYGEN_CLASS_NAME without default value

Co-authored-by: 854194341@qq.com <loukey_7821>
  • Loading branch information
loukey-lj committed Jun 24, 2022
1 parent 30ebdc7 commit 59978ef4a91fab67c4bb028f13de54fe8234a40d
Showing 3 changed files with 6 additions and 6 deletions.
@@ -363,7 +363,7 @@ private FlinkOptions() {
public static final ConfigOption<String> KEYGEN_CLASS_NAME = ConfigOptions
.key(HoodieWriteConfig.KEYGENERATOR_CLASS_NAME.key())
.stringType()
.defaultValue("")
.noDefaultValue()
.withDescription("Key generator class, that implements will extract the key out of incoming record");

public static final ConfigOption<String> KEYGEN_TYPE = ConfigOptions
@@ -116,7 +116,7 @@ private RowDataKeyGen(

public static RowDataKeyGen instance(Configuration conf, RowType rowType) {
Option<TimestampBasedAvroKeyGenerator> keyGeneratorOpt = Option.empty();
if (conf.getString(FlinkOptions.KEYGEN_CLASS_NAME).equals(TimestampBasedAvroKeyGenerator.class.getName())) {
if (TimestampBasedAvroKeyGenerator.class.getName().equals(conf.getString(FlinkOptions.KEYGEN_CLASS_NAME))) {
try {
keyGeneratorOpt = Option.of(new TimestampBasedAvroKeyGenerator(StreamerUtil.flinkConf2TypedProperties(conf)));
} catch (IOException e) {
@@ -189,7 +189,7 @@ void testSetupHoodieKeyOptionsForSource() {
assertThat(conf1.get(FlinkOptions.KEYGEN_CLASS_NAME), is("dummyKeyGenClass"));

// definition with complex primary keys and partition paths
this.conf.setString(FlinkOptions.KEYGEN_CLASS_NAME, FlinkOptions.KEYGEN_CLASS_NAME.defaultValue());
this.conf.removeConfig(FlinkOptions.KEYGEN_CLASS_NAME);
ResolvedSchema schema2 = SchemaBuilder.instance()
.field("f0", DataTypes.INT().notNull())
.field("f1", DataTypes.VARCHAR(20).notNull())
@@ -204,7 +204,7 @@ void testSetupHoodieKeyOptionsForSource() {
assertThat(conf2.get(FlinkOptions.KEYGEN_CLASS_NAME), is(ComplexAvroKeyGenerator.class.getName()));

// definition with complex primary keys and empty partition paths
this.conf.setString(FlinkOptions.KEYGEN_CLASS_NAME, FlinkOptions.KEYGEN_CLASS_NAME.defaultValue());
this.conf.removeConfig(FlinkOptions.KEYGEN_CLASS_NAME);
final MockContext sourceContext3 = MockContext.getInstance(this.conf, schema2, "");
final HoodieTableSource tableSource3 = (HoodieTableSource) new HoodieTableFactory().createDynamicTableSource(sourceContext3);
final Configuration conf3 = tableSource3.getConf();
@@ -328,7 +328,7 @@ void testSetupHoodieKeyOptionsForSink() {
assertThat(conf1.get(FlinkOptions.KEYGEN_CLASS_NAME), is("dummyKeyGenClass"));

// definition with complex primary keys and partition paths
this.conf.setString(FlinkOptions.KEYGEN_CLASS_NAME, FlinkOptions.KEYGEN_CLASS_NAME.defaultValue());
this.conf.removeConfig(FlinkOptions.KEYGEN_CLASS_NAME);
ResolvedSchema schema2 = SchemaBuilder.instance()
.field("f0", DataTypes.INT().notNull())
.field("f1", DataTypes.VARCHAR(20).notNull())
@@ -343,7 +343,7 @@ void testSetupHoodieKeyOptionsForSink() {
assertThat(conf2.get(FlinkOptions.KEYGEN_CLASS_NAME), is(ComplexAvroKeyGenerator.class.getName()));

// definition with complex primary keys and empty partition paths
this.conf.setString(FlinkOptions.KEYGEN_CLASS_NAME, FlinkOptions.KEYGEN_CLASS_NAME.defaultValue());
this.conf.removeConfig(FlinkOptions.KEYGEN_CLASS_NAME);
final MockContext sinkContext3 = MockContext.getInstance(this.conf, schema2, "");
final HoodieTableSink tableSink3 = (HoodieTableSink) new HoodieTableFactory().createDynamicTableSink(sinkContext3);
final Configuration conf3 = tableSink3.getConf();

0 comments on commit 59978ef

Please sign in to comment.