Skip to content

Fix time-travel row filters to use the snapshot schema - #4158

Open
rich7420 wants to merge 2 commits into
apache:mainfrom
rich7420:fix/4138-snapshot-filter-schema
Open

rich7420 wants to merge 2 commits into
apache:mainfrom
rich7420:fix/4138-snapshot-filter-schema

Conversation

@rich7420

Copy link
Copy Markdown

Closes #4138

Rationale for this change

Time-travel scans project the snapshot's schema but bind row filters to the current schema. Dropping and re-adding a same-named column therefore makes historical filters use the wrong field ID and silently return no rows.

Use the scan's full schema for file planning and Arrow filtering, including filter columns excluded from the output. Transaction scans use the transaction's current schema for both filtering and projection, including staged schema changes. Partition inspection without an explicit snapshot continues to use the current schema.

Are these changes tested?

On Python 3.12, make test PYTEST_ARGS='-q --tb=short' passes with 4,413 passed, 5 skipped and 126 deselected. Applying the complete patch to upstream 042165a gives 4,444 passed, 5 skipped and 127 deselected. make lint passes on both trees.

Nine historical-read regression cases fail without the original fix. Removing the transaction schema override makes five upsert/delete cases fail; restoring it makes all five pass. The issue's standalone repro returns 50 rows from both to_arrow() and count(), instead of zero. Spark/Docker integration suites were not run.

Are there any user-facing changes?

Historical filters resolve names and field IDs using the snapshot's schema, matching projection. Names introduced after that snapshot raise a field lookup error. Ordinary and incremental scans retain their current-schema behavior. Upserts can also update matching rows after a non-key column is added in the same transaction.

Bind scan planning and Arrow filters to the same full schema as projection.
Keep current-schema binding for deletes and unpinned partition inspection.
Use the transaction schema for both filtering and projection so schema
changes do not bind upsert joins to an older branch snapshot. Share this
scan behavior with deletes and cover added or replaced join columns,
branch writes, staged writes, and updates after a staged schema change.
Copilot AI balanced review requested due to automatic review settings October 26, 2026 05:53

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

This branch has not been deployed

No deployments
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.

Time-travel scan binds row_filter to the current schema and returns no rows after a column is dropped and re-added

2 participants