danny0405 commented on code in PR #9892:
URL: https://github.com/apache/hudi/pull/9892#discussion_r1371365038
##########
hudi-flink-datasource/hudi-flink/src/main/java/org/apache/hudi/sink/utils/PayloadCreation.java:
##########
@@ -60,34 +64,63 @@ public static PayloadCreation instance(Configuration conf)
throws Exception {
boolean needCombine = conf.getBoolean(FlinkOptions.PRE_COMBINE)
||
WriteOperationType.fromValue(conf.getString(FlinkOptions.OPERATION)) ==
WriteOperationType.UPSERT;
boolean shouldCombine = needCombine && preCombineField != null;
+ boolean shouldUsePropsForPayload = true;
- final Class<?>[] argTypes;
- final Constructor<?> constructor;
+ Class<?>[] argTypes;
+ Constructor<?> constructor;
if (shouldCombine) {
- argTypes = new Class<?>[] {GenericRecord.class, Comparable.class};
+ argTypes = new Class<?>[] {GenericRecord.class, Comparable.class,
Properties.class};
} else {
- argTypes = new Class<?>[] {Option.class};
+ argTypes = new Class<?>[] {Option.class, Properties.class};
}
final String clazz = conf.getString(FlinkOptions.PAYLOAD_CLASS_NAME);
- constructor = ReflectionUtils.getClass(clazz).getConstructor(argTypes);
- return new PayloadCreation(shouldCombine, constructor, preCombineField);
+ try {
+ constructor = ReflectionUtils.getClass(clazz).getConstructor(argTypes);
+ } catch (NoSuchMethodException e) {
+ shouldUsePropsForPayload = false;
+ if (shouldCombine) {
+ argTypes = new Class<?>[] {GenericRecord.class, Comparable.class};
+ } else {
+ argTypes = new Class<?>[] {Option.class};
+ }
+ constructor = ReflectionUtils.getClass(clazz).getConstructor(argTypes);
+ }
+ return new PayloadCreation(shouldCombine, shouldUsePropsForPayload,
constructor, preCombineField);
+ }
+
+ public static Properties extractPropsFromConfiguration(Configuration config)
{
+ Properties props = new Properties();
Review Comment:
Just set it up correctly in the code.
--
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]