leesf commented on code in PR #9199:
URL: https://github.com/apache/hudi/pull/9199#discussion_r1277119817
##########
hudi-client/hudi-spark-client/src/main/java/org/apache/hudi/keygen/factory/HoodieSparkKeyGeneratorFactory.java:
##########
@@ -117,6 +119,29 @@ public static String
getKeyGeneratorClassNameFromType(KeyGeneratorType type) {
}
}
+ /**
+ * Instantiate {@link BuiltinKeyGenerator}.
+ *
+ * @param properties properties map.
+ * @return the key generator thus instantiated.
+ */
+ public static Option<BuiltinKeyGenerator> getKeyGenerator(Properties
properties) {
+ TypedProperties typedProperties = new TypedProperties();
+ typedProperties.putAll(properties);
+ if
(Option.ofNullable(properties.get(HoodieWriteConfig.KEYGENERATOR_CLASS_NAME.key()))
+ .map(v ->
v.equals(NonpartitionedKeyGenerator.class.getName())).orElse(false)) {
+ return Option.empty(); // Do not instantiate NonPartitionKeyGen
+ } else {
+ try {
+ return Option.of((BuiltinKeyGenerator)
HoodieSparkKeyGeneratorFactory.createKeyGenerator(typedProperties));
+ } catch (ClassCastException cce) {
+ throw new HoodieIOException("Only those key generators implementing
BuiltInKeyGenerator interface is supported with virtual keys");
Review Comment:
also throw the `cce` here?
--
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]