Skip to content

fix(blob): allow blob files with different schema ids in a bunch#402

Open
duanyyyyyyy wants to merge 1 commit into
alibaba:mainfrom
duanyyyyyyy:fix/blob-bunch-schema-id
Open

fix(blob): allow blob files with different schema ids in a bunch#402
duanyyyyyyy wants to merge 1 commit into
alibaba:mainfrom
duanyyyyyyy:fix/blob-bunch-schema-id

Conversation

@duanyyyyyyy

@duanyyyyyyy duanyyyyyyy commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Purpose

DataEvolutionSplitRead::BlobBunch::Add rejected a bunch whose blob files
carry different schema ids ("All files in a blob bunch should have the same
schema id.").
Linked issue: close #xxx

After schema evolution that adds/drops OTHER columns, a single blob field's
contiguous files can legitimately have different schema ids — e.g. an old
appended file (schema N) followed by a compacted file (schema M) covering the
next row range. MergeRangesAndSort groups them into one bunch purely by row
id, so the check fires and a normal read fails.

Paimon Java SpecialFieldBunch.add guards this exact check with
if (!isBlobFile(file)) — blob files are exempt because a blob column's on-disk
layout is schema-independent, and the bunch is read with the first file's schema
regardless. That guard was dropped when porting to C++.

What this PR does

  • Restore the if (!IsBlobFile(file)) guard so blob files may span schema ids;
    the write_cols (field identity) check is unchanged.
  • Add TestAddBlobFilesWithDifferentSchemaId.

Tests

API and Format

Documentation

Generative AI tooling

ASSERT_OK(blob_bunch->Add(blob_tail));
ASSERT_EQ(blob_bunch->Files().size(), 2);
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Could you add an integration test in blob_table_inte_test.cpp that uses WriteNextSchema to simulate an ALTER TABLE scenario?

// bunch. The Java guard `if (!isBlobFile(file))` around this check was dropped
// when porting, which turned that legitimate case into a spurious error.
if (!BlobUtils::IsBlobFile(file->file_name)) {
if (file->schema_id != files_[0]->schema_id) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

BlobBunch::Add already rejects non-blob files at the beginning, so the new if (!BlobUtils::IsBlobFile(file->file_name)) guard around the schema-id check is unreachable. Functionally this is fine, but it may confuse readers. Could we remove the schema-id check entirely for BlobBunch and replace the comment with something like: “BlobBunch only contains blob files. Unlike vector-store files, blob files may span schema ids as long as they belong to the same blob field.”

@duanyyyyyyy duanyyyyyyy force-pushed the fix/blob-bunch-schema-id branch from 9666fb4 to 58a6ee5 Compare July 7, 2026 12:44
@CLAassistant

CLAassistant commented Jul 7, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@duanyyyyyyy duanyyyyyyy force-pushed the fix/blob-bunch-schema-id branch 2 times, most recently from 1a5cdde to 41044f1 Compare July 7, 2026 12:55
])")
.ValueOrDie());
ASSERT_OK(ScanAndRead(table_path, schema->field_names(), expected_array));
}

@lxy-9602 lxy-9602 Jul 8, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I tested this integration test locally against the unmodified/pre-fix code, and it still passes. So I don’t think this test actually hits the regression scenario.

The test creates two f1 blob files with adjacent row ranges: [0, 0] under schema 0 and [1, 1] under schema 1. However, RangeHelper::MergeOverlappingRanges only merges overlapping ranges, not adjacent ranges. As a result, these two files are split into different need_merge_files groups, and each group creates its own BlobBunch with only one blob file. The old schema-id check is therefore never exercised.

To cover the real scenario, the integration test needs to ensure that two blob files with different schema ids are added to the same BlobBunch, for example all with first row id 0.

@duanyyyyyyy duanyyyyyyy force-pushed the fix/blob-bunch-schema-id branch from 41044f1 to 7ebab5a Compare July 8, 2026 02:48
BlobBunch::Add required every file in a bunch to share the same schema id. After
schema evolution that adds/drops OTHER columns, a single blob field's contiguous
files can carry different schema ids (an old appended file plus a compacted one).
MergeRangesAndSort groups them into one bunch by row id, so the check raised a
spurious "All files in a blob bunch should have the same schema id."

A blob column's on-disk layout is schema-independent and the bunch is read with
the first file's schema regardless, so blob files may span schema ids. BlobBunch
only ever holds blob files (non-blob files are rejected up front), so the check is
removed. This matches Paimon Java, whose SpecialFieldBunch.add guards the same
check with if (!isBlobFile(file)).

Adds a unit test (TestAddBlobFilesWithDifferentSchemaId) and an integration test
(TestBlobBunchSpanningSchemaIds, which uses the existing WriteNextSchema helper to
simulate an ALTER TABLE between two appends of the same blob field).
@duanyyyyyyy duanyyyyyyy force-pushed the fix/blob-bunch-schema-id branch from a40c2b9 to f47b53f Compare July 8, 2026 11:13
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.

3 participants