Skip to content

fix: validate schema type compatibility when reading parquet files - #447

Open
jiaqizho wants to merge 1 commit into
milvus-io:mainfrom
jiaqizho:schema-type-not-match
Open

fix: validate schema type compatibility when reading parquet files#447
jiaqizho wants to merge 1 commit into
milvus-io:mainfrom
jiaqizho:schema-type-not-match

Conversation

@jiaqizho

Copy link
Copy Markdown
Collaborator

When reading parquet files, we weren't checking whether the caller's read schema has compatible field types with the actual file schema. This could lead to subtle issues — for example, if someone passes a struct type for a field that's actually int64 in the file, Arrow's C Data Interface would happily import it with the wrong memory layout, which can cause memory corruption or ASAN violations.

This adds a ValidateSchemaCompatibility check in ParquetFormatReader::open() that compares each field in the read schema against the file schema. If a field exists in both but has a different type, we now fail early with a clear error message instead of silently misinterpreting the data.

The read_schema is threaded through from FormatReader::create() down to ParquetFormatReader so the validation happens right after we read the file's actual schema. Fields that only exist in the read schema (schema evolution case) are skipped.

@sre-ci-robot

Copy link
Copy Markdown
Collaborator

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: jiaqizho
To complete the pull request process, please assign shaoting-huang after the PR has been reviewed.
You can assign the PR to them by writing /assign @shaoting-huang in a comment when ready.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@codecov

codecov Bot commented Mar 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 73.07%. Comparing base (fd3757b) to head (bba363a).
⚠️ Report is 30 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #447      +/-   ##
==========================================
- Coverage   73.07%   73.07%   -0.01%     
==========================================
  Files         130      130              
  Lines       12940    12939       -1     
  Branches     1902     1902              
==========================================
- Hits         9456     9455       -1     
  Misses       3484     3484              
Flag Coverage Δ
python 44.79% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

When reading parquet files, we weren't checking whether the caller's read schema has compatible field types with the actual file schema. This could lead to subtle issues — for example, if someone passes a struct type for a field that's actually int64 in the file, Arrow's C Data Interface would happily import it with the wrong memory layout, which can cause memory corruption or ASAN violations.

This adds a ValidateSchemaCompatibility check in ParquetFormatReader::open() that compares each field in the read schema against the file schema. If a field exists in both but has a different type, we now fail early with a clear error message instead of silently misinterpreting the data.

The read_schema is threaded through from FormatReader::create() down to ParquetFormatReader so the validation happens right after we read the file's actual schema. Fields that only exist in the read schema (schema evolution case) are skipped.

Signed-off-by: jiaqizho <jiaqi.zhou@zilliz.com>
@jiaqizho
jiaqizho force-pushed the schema-type-not-match branch from 55e70aa to bba363a Compare April 3, 2026 04:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants