yihua commented on code in PR #20846:
URL: https://github.com/apache/hudi/pull/20846#discussion_r4722745300
##########
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/index/HoodieIndexUtils.java:
##########
@@ -464,6 +467,46 @@ private static <R> Option<HoodieRecord<R>>
mergeIncomingWithExistingRecord(
}
}
+ /**
+ * Keeps one incoming record per record key of the ones that wait for a
merged lookup, as
+ * {@link HoodieData#distinctWithKey} does, and fails with a {@link
HoodieMultipleMatchesException} when more than one
+ * incoming record matches one row. The index pairs every incoming record
with each row it locates the key at, and
+ * the rows of a key differ in file group or position, so more than one
incoming record shows as more than one pair
+ * for a row, while one record located at several rows does not fail. The
incoming records the index already tagged
+ * count as well, as one of them and one that waits for the merged lookup
can match the same row. See
+ * {@link HoodieWriteConfig#UPSERT_FAIL_ON_MULTIPLE_MATCHES}.
+ */
+ private static <R> HoodieData<HoodieRecord<R>>
distinctLocatedRecordsFailingOnMultipleMatches(
+ HoodieData<Pair<HoodieRecord<R>, Option<HoodieRecordGlobalLocation>>>
incomingRecordsAndLocations, int parallelism) {
+ return incomingRecordsAndLocations
+ .filter(p -> p.getRight().isPresent() ||
p.getLeft().isCurrentLocationKnown())
Review Comment:
Fixed: the matches of a row that the merged lookup reads are now checked
after the existing-record join, so the statement fails only when the row they
match is live. Two source rows for a key a log file deleted now insert it once,
covered by a two-source-row variant of the global index test next to it.
Matches of rows the index tags directly still fail before the write, as before.
--
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]