Repository navigation
Fix empty arrays for missing elements of a Parquet list of structs - #131125
alexey-milovidov merged 3 commits into
Conversation
… field in the file The Parquet v3 reader returned empty arrays for a list of structs when none of the requested elements under the list are in the file, e.g. the structure `l Array(Tuple(a Nullable(Int32), d Nullable(Int32)))` over a file without `d` gave `l.d` = [] instead of [NULL], and `ARRAY JOIN l.d` gave no rows. Repetition and definition levels are stored only in the leaf column chunks, and no leaf under such an array was read. Read one leaf under such an array only for its levels: its values are decoded as stored, without the logical type, and then dropped, and the existing per-element missing fill runs inside the array. This covers both a whole tuple whose requested elements are all missing, and a requested `arr.missing` subcolumn that matches no schema element. This is the carrier reviewed on ClickHouse#130259, split out of it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…lready computed processSubtreePrimitive records every leaf under an array with its levels, so the leaves of a subtree are a contiguous range, and addLevelsOnlyPrimitive picks from that range instead of walking the subtree again. It keeps the cheapest leaf whose physical type it can decode in a single pass, with the same cost order and the same leaf as before, without throwing and catching per leaf. A requested `arr.missing` column is handled inside the existing loop over the missing columns of prepareForReading, so the found columns are not computed twice. The test reads a NULL in a Nullable leaf of a file written by ClickHouse instead of a GEOMETRY leaf written by pyarrow: the leaf is decoded by its physical type, so both are the same case. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Internal second-model review: adjudication log (click to expand)Pre-publication review by an independent model (engine: codex; 1 finding).
Severity: ❌ blocker / Session id: cron:clickhouse-review-slot-9:20261112-200800 |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-40:20261111-165500 |
|
Workflow [PR], commit [4ae85f6] Summary: ✅
AI ReviewSummaryPreserves Parquet list sizes when all requested struct fields are missing by reading a physical leaf for its repetition and definition levels, then filling the requested fields with defaults. Reviewed head Missing context / blind spots
Final Verdict✅ Approve. No new inline findings. |
…e fast test ClickHouse#126477 builds Parquet in the fast test and removed `no-fasttest` from 03548, so the cases this PR added to it ran there and failed: the fast test has neither pyarrow nor the IcebergLocal engine. They now live in 03548_parquet_missing_tuple_elements_pyarrow_iceberg, tagged `no-fasttest`; the cases that only use files written by ClickHouse stay in 03548 and keep running in the fast test. The moved cases and their expected output are unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Object file sizes8 object files changed (+36.90 KiB total), 0 added.
711 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only Slowest function optimization changes (ThinLTO)Median per-function time ratio to the master baseline:
Compile time of recompiled translation units16 translation units recompiled, 157 s compile time in total, 16 of them have a recent master baseline. |
Related: #130259
Related: #130279
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fixed reading a Parquet list of structs with an explicit structure or a data lake schema that requests only elements the file does not have:
l.dandl Array(Tuple(d ...))returned empty arrays, soARRAY JOINandlengthsaw no elements, instead of arrays of default values with the sizes of the list in the file.Description
On 26.10.2.103 (also 26.8.21.12 and 26.3.33.24),
SELECT l.d FROM file('f.parquet', Parquet, 'l Array(Tuple(a Nullable(Int32), d Nullable(Int32)))')over a file whoselhas nodreturns[]instead of[NULL], andARRAY JOIN l.dreturns no rows.l Array(Tuple(d Nullable(Int32)))returns[]for every row. The same happens to an Iceberg list read under a schema in which none of its element's fields are in the file.Parquet stores the array sizes only in the leaf column chunks, and the reader reads a leaf only if a requested element maps to it. When no requested element is in the file, no leaf under the list is read, so the arrays come out empty.
Now one leaf under such a list is read only for its levels: the cheapest one (preferring fixed width, then no arrays of its own, then not already read for another column), decoded by its physical type and then dropped, so no value can be rejected. The requested elements are filled with defaults inside the arrays, and a
DEFAULTexpression of a missingl.dstill applies. The candidate leaves are recorded during the existing schema traversal.This changes what
03548_parquet_missing_tuple_elementspinned ([]): the new results are what the whole-column read, the Arrow reader and the ORC reader (#130279) return. The test is extended with nested lists, tuples in elements, dotted subcolumns withARRAY JOIN,WHEREandPREWHERE, and NULL leaf values. Out-of-range leaf values, Iceberg and the columns cache are in the new03548_parquet_missing_tuple_elements_pyarrow_iceberg, which needs pyarrow and so skips the fast test. Both fail on master in the changed lines and pass with the change.This part is split out of #130259, so that that PR only unifies the readers.
Workflow [PR]
Sync PR [sync-upstream/pr/131125]
Version info
26.11.1.2226-master(included in26.11and later)