voonhous commented on code in PR #20844:
URL: https://github.com/apache/hudi/pull/20844#discussion_r4681279751
##########
hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/spark/sql/hudi/dml/others/TestMergeIntoTable.scala:
##########
@@ -474,6 +474,69 @@ class TestMergeIntoTable extends HoodieSparkSqlTestBase
with ScalaAssertionSuppo
}
}
+ test("Test MergeInto with global index into a small file group of a MOR
table") {
Review Comment:
`HoodieWriteMergeHandle` might still have the bug, it's opt-in through
`hoodie.write.merge.handle.class` and the new tests uses plain `test()`, soi
they never run it. Could we register both tests with `testWithMergeHandles` to
ensure that we cover that case too?
##########
hudi-common/src/main/java/org/apache/hudi/common/table/read/BufferedRecordMergerFactory.java:
##########
@@ -384,13 +386,26 @@ public Option<BufferedRecord<T>>
deltaMergeRecords(BufferedRecord<T> newRecord,
*/
private static class ExpressionPayloadRecordMerger<T> extends
CustomPayloadRecordMerger<T> {
private final HoodieRecordMerger deltaMerger;
+ private Integer mergedRecordSchemaId;
public ExpressionPayloadRecordMerger(RecordContext<T> recordContext,
Option<HoodieRecordMerger> recordMerger, String incomingPayloadClass,
HoodieSchema readerSchema,
TypedProperties props) {
super(recordContext, recordMerger, incomingPayloadClass, readerSchema,
props);
this.deltaMerger =
HoodieRecordUtils.mergerToPreCombineMode(recordMerger.get());
}
+ @Override
+ public BufferedRecord<T> finalMerge(BufferedRecord<T> olderRecord,
BufferedRecord<T> newerRecord) throws IOException {
+ if (mergedRecordSchemaId == null) {
+ mergedRecordSchemaId =
recordContext.encodeSchema(HoodieSchemaCache.intern(HoodieSchemaUtils.removeMetadataFields(readerSchema)));
Review Comment:
non-blocking: the "already merged" marker is now derived in three places
(here, `PayloadUpdateProcessor` and the loader), and the global-index merge
only stays out of this branch because of the comment in `HoodieIndexUtils`; if
that path ever buffered its incoming record in `writeSchema`, the MERGE clauses
would be skipped without an error. Could the loader set the merged-record
schema once, e.g. on the schema handler next to `setSchemaForUpdates`, and have
the merger and update processor read it from there? A merger built outside the
merge handle would then never take this branch.
--
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]