YannByron commented on a change in pull request #3823: URL: https://github.com/apache/hudi/pull/3823#discussion_r736728472
########## File path: hudi-client/hudi-spark-client/src/main/java/org/apache/hudi/keygen/factory/HoodieSparkKeyGeneratorFactory.java ########## @@ -51,44 +49,70 @@ private static final Logger LOG = LoggerFactory.getLogger(HoodieSparkKeyGeneratorFactory.class); public static KeyGenerator createKeyGenerator(TypedProperties props) throws IOException { - // keyGenerator class name has higher priority - KeyGenerator keyGenerator = KeyGenUtils.createKeyGeneratorByClassName(props); - - return Objects.isNull(keyGenerator) ? createKeyGeneratorByType(props) : keyGenerator; + String keyGeneratorClass = getKeyGeneratorClassName(props); + try { + return (KeyGenerator) ReflectionUtils.loadClass(keyGeneratorClass, props); + } catch (Throwable e) { + throw new IOException("Could not load key generator class " + keyGeneratorClass, e); + } } - private static BuiltinKeyGenerator createKeyGeneratorByType(TypedProperties props) throws IOException { - // Use KeyGeneratorType.SIMPLE as default keyGeneratorType - String keyGeneratorType = - props.getString(HoodieWriteConfig.KEYGENERATOR_TYPE.key(), null); + public static String getKeyGeneratorClassName(TypedProperties props) { + String keyGeneratorClass = props.getString(HoodieWriteConfig.KEYGENERATOR_CLASS_NAME.key(), null); - if (StringUtils.isNullOrEmpty(keyGeneratorType)) { - LOG.info("The value of {} is empty, use SIMPLE", HoodieWriteConfig.KEYGENERATOR_TYPE.key()); - keyGeneratorType = KeyGeneratorType.SIMPLE.name(); + if (StringUtils.isNullOrEmpty(keyGeneratorClass)) { + String keyGeneratorType = props.getString(HoodieWriteConfig.KEYGENERATOR_TYPE.key(), KeyGeneratorType.SIMPLE.name()); Review comment: ok, i'll do this. -- 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: commits-unsubscr...@hudi.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org