Skip to content

fix: read full-zip pages that pad each value with a zero control word - #10669

Merged
Xuanwo merged 11 commits into
lance-format:mainfrom
LuciferYang:fix/fullzip-control-word
Nov 20, 2026
Merged

Xuanwo merged 11 commits into
lance-format:mainfrom
LuciferYang:fix/fullzip-control-word

Conversation

@LuciferYang

@LuciferYang LuciferYang commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Closes #10668.

Writers before 13.0.0 could store a 0x00 control-word byte before each value of a full-zip page whose layout records no control-word bits. The reader takes that layout as NIL, so variable-width columns fail to read and fixed-width columns read shifted values. The decoder now marks such pages as padded and skips that byte:

  • Fixed width: a page with no repetition index that holds exactly rows * (bytes_per_value + 1) bytes.
  • Variable width: the NIL walk is retried with padding only after it fails. If the retry fails too, the original error is returned.

Value reads reject a non-zero padding byte. A padded variable-width page whose NIL walk happens to succeed is still read as NIL, as before. For example, a read range holding one value of length L (L < 2^24) followed by exactly 255·L − 1 empty values returns the first value as 256·L bytes.

array_length on NIL pages

The list structure path from #10759 built an empty def buffer for a full-zip FixedSizeList page with nullable layers and a NIL control word, so array_length failed with Incorrect length of values buffer for FixedSizeListArray. The current writer emits such a page whenever a page of such a column has no nulls, and the padded pages have the same shape. That path now reads a NIL page as all valid, as the value path does.

Tests

  • test_v4_0_1_merge_insert_padded_control_words scans a binary column that pylance 4.0.1 wrote through a merge_insert updating only some columns (Data corruption with sub-schema merge_insert on data_storage_version=2.2 #6338). test_v11_0_0_fullzip_padded_control_words reads pylance 11.0.0 FixedSizeList<Struct> columns with a large_binary or a FixedSizeList<float32, 128> child through scan, 3-row batches and take. The generators assert the defect is still written. Without the recovery, both tests fail with a corrupt-file error. test_v11_0_0_fullzip_padded_control_words_list_length runs array_length on the 11.0.0 columns.
  • test_list_structure_fixed_outer gains two full-zip cases from the current writer whose second file has no nulls. They fail without the list structure change.
  • variable_full_zip_reads_nil_page, variable_full_zip_rejects_nonzero_padding, fixed_full_zip_reads_padded_nil_page, test_has_padded_fixed_control_words: pages read whole or in parts, non-zero padding, and the fixed-width size check.

I also checked by hand that this branch reads padded files written by pylance 2.0.0, 4.0.1, 6.0.1, 11.0.0 and 12.0.0, which 14.0.2 can't read or reads wrong.

🤖 Generated with Claude Code

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

lance-gatekeeper[bot]

This comment was marked as outdated.

@lance-gatekeeper lance-gatekeeper Bot added K-approved Latest Gatekeeper recommendation permits acceptance. K-risk Latest Gatekeeper recommendation includes a non-blocking risk. labels Nov 3, 2026
@LuciferYang

Copy link
Copy Markdown
Contributor Author

The padding is now a private flag on FullZipDecodeDetails (94d605d), so ControlWordParser is unchanged and this no longer needs breaking-change.

@lance-gatekeeper lance-gatekeeper Bot removed K-risk Latest Gatekeeper recommendation includes a non-blocking risk. K-approved Latest Gatekeeper recommendation permits acceptance. labels Nov 3, 2026
lance-gatekeeper[bot]

This comment was marked as outdated.

@lance-gatekeeper lance-gatekeeper Bot added K-approved Latest Gatekeeper recommendation permits acceptance. K-risk Latest Gatekeeper recommendation includes a non-blocking risk. labels Nov 3, 2026
@github-actions github-actions Bot added the critical-fix Bugs that cause crashes, security vulnerabilities, or incorrect data. label Nov 5, 2026
@lance-gatekeeper lance-gatekeeper Bot removed K-risk Latest Gatekeeper recommendation includes a non-blocking risk. K-approved Latest Gatekeeper recommendation permits acceptance. labels Nov 16, 2026
lance-gatekeeper[bot]

This comment was marked as outdated.

@lance-gatekeeper lance-gatekeeper Bot added K-approved Latest Gatekeeper recommendation permits acceptance. K-risk Latest Gatekeeper recommendation includes a non-blocking risk. labels Nov 16, 2026
@lance-gatekeeper lance-gatekeeper Bot removed the K-risk Latest Gatekeeper recommendation includes a non-blocking risk. label Nov 18, 2026
@lance-gatekeeper lance-gatekeeper Bot removed the K-approved Latest Gatekeeper recommendation permits acceptance. label Nov 18, 2026
lance-gatekeeper[bot]

This comment was marked as outdated.

@lance-gatekeeper lance-gatekeeper Bot added K-approved Latest Gatekeeper recommendation permits acceptance. K-risk Latest Gatekeeper recommendation includes a non-blocking risk. and removed K-risk Latest Gatekeeper recommendation includes a non-blocking risk. K-approved Latest Gatekeeper recommendation permits acceptance. labels Nov 18, 2026
lance-gatekeeper[bot]

This comment was marked as outdated.

@lance-gatekeeper lance-gatekeeper Bot added K-approved Latest Gatekeeper recommendation permits acceptance. K-risk Latest Gatekeeper recommendation includes a non-blocking risk. labels Nov 19, 2026
@lance-gatekeeper lance-gatekeeper Bot removed K-risk Latest Gatekeeper recommendation includes a non-blocking risk. K-approved Latest Gatekeeper recommendation permits acceptance. labels Nov 20, 2026

@lance-gatekeeper lance-gatekeeper Bot 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.

⚠️ Gate recommendation: approve with a non-blocking risk.

The author has accepted the known ambiguity. Some historical variable-width pages can still silently return incorrect values; compare suspect data with its source before treating a rewritten copy as repaired.

The recovery and NIL list-length handling remain acceptable. Padding remains private decoder state, so the earlier breaking-change request remains withdrawn.

@lance-gatekeeper lance-gatekeeper Bot added K-approved Latest Gatekeeper recommendation permits acceptance. K-risk Latest Gatekeeper recommendation includes a non-blocking risk. labels Nov 20, 2026
@Xuanwo
Xuanwo merged commit 537acfd into lance-format:main Nov 20, 2026
44 of 50 checks passed
@LuciferYang

Copy link
Copy Markdown
Contributor Author

Thank you @Xuanwo

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

Labels

A-encoding Encoding, IO, file reader/writer bug Something isn't working critical-fix Bugs that cause crashes, security vulnerabilities, or incorrect data. K-approved Latest Gatekeeper recommendation permits acceptance. K-risk Latest Gatekeeper recommendation includes a non-blocking risk.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: full-zip pages written before 13.0.0 with a zero control-word byte per value fail to read or read wrong values

2 participants