Skip to content

[core][spark] Keep vector-store files of touched ranges in Data Evolution MERGE - #11458

Open
LuciferYang wants to merge 3 commits into
apache:masterfrom
LuciferYang:fix/de-merge-vector-file-pruning
Open

LuciferYang wants to merge 3 commits into
apache:masterfrom
LuciferYang:fix/de-merge-vector-file-pruning

Conversation

@LuciferYang

@LuciferYang LuciferYang commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Purpose

close #11456

A Data Evolution MERGE keeps only the files of touched row-id ranges. Vector-store files roll like blob files, so a range can hold several, but only blob files were mapped to their range. Vector files starting inside a touched range were dropped: updating another column failed the row-count check, and updating the vector column wrote NULL into the rest of the range.

MergeIntoPaimonDataEvolutionTable maps vector-store files and keeps the range start, since the vector column may be backfilled from a later row. DataEvolutionSplitRead drops vector-store files holding no read field when the group has a normal file.

For vector-store-only groups, incremental reads read by range when the files cover different rows; delta scans, and scans without deletion vectors, keep the group instead of failing to plan.

#11156 keeps this mapping blob-only, in DataEvolutionMergeMetadata.summarize and both inline fallbacks; whichever PR merges second adds vector-store files to all three.

Tests

  • RowTrackingTestBase, each with ON _ROW_ID and ON id, setting a normal or the vector column:

    • "merge into keeps vector files that start inside a touched range": a 4000-row range whose vector file rolls at 1 kb, merged on row 1000; checks the other 3999 rows' vectors.
    • "merge into a range whose vector column is backfilled from a later row": the layout from the review.
  • VectorStoreTableTest:

    • testReadWithoutAVectorColumnBackfilledFromALaterRow: reads id and id, embedding from splits planned for all columns, and _ROW_ID.
    • testReadOfARenamedVectorColumnNextToABackfilledOne: files are matched by field id.
    • testIncrementalRowIdReadOfVectorOnlyChanges, testIncrementalReadOfVectorOnlyChangesWithAPartialUnreadColumn: every row of the range is read, with and without a pushed-down row range.
    • testStreamingReadOfANormalColumnOverVectorOnlyChanges, with and without deletion vectors: the next plan reads four rows with NULL id, and rows 2 and 3 for embedding_v2.
    • testFileCreationTimeScanOfVectorOnlyChangesWithDeletionVectors: planning fails, as on master.
  • DataEvolutionFileStoreScanTest.testReadTypePruningKeepsVectorOnlyGroupWithoutReadField: delta scans, or any scan without deletion vectors, keep both vector files; with deletion vectors, other scans still throw.

@JingsongLi JingsongLi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All 76 RowTrackingTest cases passed on Spark 3.5.9. I reproduced the case below with a local Data Evolution table and compared it with the base MERGE implementation.

.filter(file => isBlobFile(file.fileName()))
// Blob and vector-store files roll on their own size, so a range may hold several of
// them, starting at row ids that are not the first row id of any normal file.
.filter(file => isBlobFile(file.fileName()) || isVectorStoreFile(file.fileName()))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P1] Preserve the normal file when a vector backfill starts later in its range

I wrote one normal file for RowIDs 0–3, added a nullable vector column and backfilled only RowIDs 2–3 into one vector file. A MERGE on _ROW_ID = 0 updating an ordinary column succeeds on the base and preserves both vectors. On this revision it fails with First row ID 0 not found in partition map. findRelatedFirstRowIds replaces the normal start with the dedicated starts whenever the map contains an entry, so the newly mapped vector start 2 removes start 0 from the target scan. Please keep the normal start alongside the dedicated starts in both Spark implementations and cover a partial vector backfill.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. findRelatedFirstRowIds now keeps the range start next to the dedicated starts, in both copies.

Keeping the start exposed a second failure in your layout. The split then carries the vector file for rows 2 and 3, and a MERGE that sets x reads it with a read type without the vector column, so the file becomes its own bunch and fails "All files in a field merge split should have the same row count". DataEvolutionSplitRead now drops vector-store files that hold no read field when the group has a normal file.

Tests: "Data Evolution: merge into a range whose vector column is backfilled from a later row" in RowTrackingTestBase runs your case on both _ROW_ID and id, setting x or the vector column. VectorStoreTableTest.testReadWithoutAVectorColumnBackfilledFromALaterRow covers the read path alone.

@JingsongLi JingsongLi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The focused Core suites passed. The streaming delta path changes which rows are delivered when a reader selects a partially backfilled vector column.

&& kept.stream().allMatch(e -> isDedicatedFile(e.file()))) {
kept.add(retrieveAnchorFile(group, ManifestEntry::file));
}
if (!kept.isEmpty()) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P1] Preserve row coverage when projecting a vector-only delta

VectorStoreTableTest.testStreamingReadOfANormalColumnOverVectorOnlyChanges reproduces this on a real deletion-vector-enabled Data Evolution table. One delta contains embedding over RowIDs 0–3 and embedding_v2 over 2–3. Reading id, _ROW_ID returns 0–3. Adding embedding_v2 to the projection returns only 2–3, with no row predicate. ReadBuilder.withProjection is also used by the Flink streaming source, so projecting a column can silently omit two change rows after this change makes the delta readable. When no normal file exists, preserve the group's complete RowID coverage during pruning and let the range reader fill the uncovered projected values with NULL.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Data Evolution MERGE drops vector-store files that start inside a touched range

2 participants