Repository navigation
Cherry pick #102628 to 26.2: Fix LOGICAL_ERROR crash in Parquet reader for nullable columns with filter - #105310
Merged
robot-ch-test-poll2 merged 4 commits intoMay 19, 2026
Conversation
…ilter Two bugs in the native Parquet V3 reader (Reader.cpp): 1. Inverted null_map check (primary fix): The memchr check at line 1422 searched for byte 0 (non-null marker) instead of byte 1 (null marker). The null_map uses standard ClickHouse convention: 1 = NULL, 0 = NOT NULL. When ALL values in a filtered subchunk were NULL and the output column was non-nullable with input_format_null_as_default=0, the check incorrectly cleared the null_map (instead of throwing CANNOT_INSERT_NULL_IN_ORDINARY_COLUMN), leaving the column with 0 rows while rows_pass was 1, triggering: "Logical error: Unexpected number of rows in column subchunk 0 1". The inverted check also caused the opposite bug: reading non-null data from a Parquet nullable column into a non-nullable ClickHouse column with null_as_default=0 would incorrectly throw CANNOT_INSERT_NULL even when no NULLs were present. 2. Disabled filter-in-decoder for nullable columns: The use_filter_in_decoder optimization reads ALL rows through processDefLevelsForInnermostColumn (populating the null_map for all rows, not just filtered ones) and then passes the filter to the decoder. With nullable columns, the decoder applies the filter at consecutive encoded-value indices, but null rows have no encoded values, so the filter-to-row mapping is wrong. Disable this optimization for nullable columns, falling back to the correct row-range iteration path. Closes #99019 Co-Authored-By: Claude Opus 4.6 <[email protected]>
Two issues fixed: 1. Pin input_format_parquet_use_native_reader_v3=1 in all queries — the test exercises V3 reader behavior (filter pushdown); the legacy Arrow-based reader has different semantics (reads ALL rows before casting, so null_as_default=0 errors even when WHERE excludes NULL rows). 2. Add '| head -1' to grep pipeline — CI's --send_logs_level=warning causes CANNOT_INSERT_NULL_IN_ORDINARY_COLUMN to appear in both a server log message and the exception, producing duplicate grep matches. 3. Replace section 4 (read only non-null rows from file with NULLs) with reading from a NULL-free file — the V3 reader processes data at subchunk granularity, so NULLs in the same subchunk as requested rows cause errors regardless of the WHERE filter. The new test validates the fix doesn't break the non-null case. Verified: 50/50 passes with full randomization. Co-Authored-By: Claude Opus 4.6 <[email protected]>
Fix LOGICAL_ERROR crash in Parquet reader for nullable columns with filter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Original pull-request #102628
Do not merge this PR manually
This pull-request is a first step of an automated backporting.
It contains changes similar to calling
git cherry-picklocally.If you intend to continue backporting the changes, then resolve all conflicts if any.
Otherwise, if you do not want to backport them, then just close this pull-request.
The check results does not matter at this step - you can safely ignore them.
Troubleshooting
If the conflicts were resolved in a wrong way
If this cherry-pick PR is completely screwed by a wrong conflicts resolution, and you want to recreate it:
pr-cherrypicklabel from the PRYou also need to check the Original pull-request for
pr-backports-createdlabel, and delete if it's presented thereThe PR source
The PR is created in the CI job