You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hudi.apache.org by "linliu-code (via GitHub)" <gi...@apache.org> on 2026/02/04 04:16:13 UTC
Re: [PR] [HUDI-9666] Fix the record key encoding with a single record key field and add a guard for complex key generator [hudi]
linliu-code commented on code in PR #17834:
URL: https://github.com/apache/hudi/pull/17834#discussion_r2762093752
##########
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:
nit: FILED -> FIELD
--
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-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org