danny0405 commented on code in PR #9892:
URL: https://github.com/apache/hudi/pull/9892#discussion_r1371109726
##########
hudi-flink-datasource/hudi-flink/src/main/java/org/apache/hudi/sink/utils/PayloadCreation.java:
##########
@@ -43,14 +44,17 @@ public class PayloadCreation implements Serializable {
private static final long serialVersionUID = 1L;
private final boolean shouldCombine;
+ private final boolean shouldUsePropsForPayload;
private final Constructor<?> constructor;
private final String preCombineField;
private PayloadCreation(
boolean shouldCombine,
+ boolean shouldUsePropsForPayload,
Constructor<?> constructor,
@Nullable String preCombineField) {
this.shouldCombine = shouldCombine;
+ this.shouldUsePropsForPayload = shouldUsePropsForPayload;
Review Comment:
`shouldUsePropsForPayload` should be always true?
##########
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:
If all we want is payload properties, you can use
`StreamerUtil.getPayloadConfig`.
--
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]