wuwenchi commented on code in PR #6320:
URL: https://github.com/apache/hudi/pull/6320#discussion_r941074122
##########
hudi-flink-datasource/hudi-flink/src/main/java/org/apache/hudi/table/HoodieTableFactory.java:
##########
@@ -235,6 +235,11 @@ private static void setupHoodieKeyOptions(Configuration
conf, CatalogTable table
conf.setString(FlinkOptions.KEYGEN_CLASS_NAME,
ComplexAvroKeyGenerator.class.getName());
LOG.info("Table option [{}] is reset to {} because record key or
partition path has two or more fields",
FlinkOptions.KEYGEN_CLASS_NAME.key(),
ComplexAvroKeyGenerator.class.getName());
+ } else if (!conf.getOptional(FlinkOptions.KEYGEN_CLASS_NAME).isPresent()) {
+ String keyGenName = FlinkOptions.getKeyGenClassNameByType(conf);
+ conf.setString(FlinkOptions.KEYGEN_CLASS_NAME, keyGenName);
+ LOG.info("Table option [{}] is reset to {} because of {}",
+ FlinkOptions.KEYGEN_CLASS_NAME.key(), keyGenName,
FlinkOptions.KEYGEN_TYPE);
Review Comment:
Here is the logic to create the real KeyGenerator
`HoodieAvroKeyGeneratorFactory#createKeyGenerator `:
https://github.com/apache/hudi/blob/75f6266594245cee998a5530711f929023d87a44/hudi-client/hudi-client-common/src/main/java/org/apache/hudi/keygen/factory/HoodieAvroKeyGeneratorFactory.java#L51
If KEYGENERATOR_CLASS_NAME is not configured, it will be created according
to KEYGENERATOR_TYPE.
So, I'm afraid there will be an error here:
If we use your modification method above, assuming that the user sets the
type to complex, the class saved in the table properties is
`SimpleAvroKeyGenerator`, but the `ComplexAvroKeyGenerator` is actually used.
Used and saved are not the same.
--
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]