lokeshj1703 commented on code in PR #17834:
URL: https://github.com/apache/hudi/pull/17834#discussion_r2768820999
##########
hudi-client/hudi-spark-client/src/main/java/org/apache/hudi/keygen/ComplexKeyGenerator.java:
##########
@@ -47,6 +48,7 @@ public ComplexKeyGenerator(TypedProperties props) {
.filter(s -> !s.isEmpty())
.collect(Collectors.toList());
this.complexAvroKeyGenerator = new ComplexAvroKeyGenerator(props);
+ this.encodeSingleKeyFieldName =
KeyGenUtils.encodeSingleKeyFieldNameForComplexKeyGen(props);
Review Comment:
It will not throw NPE. It will throw an exception IllegalArgumentException
since the API checks for key existence.
`throw new IllegalArgumentException("Property " + property + " not found");`
##########
hudi-client/hudi-spark-client/src/main/java/org/apache/hudi/keygen/BuiltinKeyGenerator.java:
##########
@@ -233,23 +235,43 @@ private <S> S combineRecordKeyInternal(
}
private <S> S combineCompositeRecordKeyInternal(
+ boolean encodeSingleKeyFieldName,
Supplier<PartitionPathFormatterBase.StringBuilder<S>> builderFactory,
Function<Object, S> converter,
Function<S, S> emptyKeyPartHandler,
Predicate<S> isNullOrEmptyKeyPartPredicate,
Object... recordKeyParts
) {
- boolean hasNonNullNonEmptyPart = false;
+ if (recordKeyParts.length == 0) {
+ throw new HoodieKeyException(String.format("All of the values for (%s)
were either null or empty", recordKeyFields));
+ }
PartitionPathFormatterBase.StringBuilder<S> sb = builderFactory.get();
+
+ if (recordKeyParts.length == 1) {
+ // NOTE: If record-key part has already been a string [[toString]] will
be a no-op
+ S convertedKeyPart =
emptyKeyPartHandler.apply(converter.apply(recordKeyParts[0]));
+
+ if (encodeSingleKeyFieldName) {
+ sb.appendJava(recordKeyFields.get(0));
+ sb.appendJava(DEFAULT_COMPOSITE_KEY_FILED_VALUE);
Review Comment:
Addressed
--
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]