Skip to content

Fix reading a tuple element inside an array from Iceberg Parquet files with field ids - #128775

Open
josephperez3 wants to merge 1 commit into
ClickHouse:masterfrom
josephperez3:fix-iceberg-tuple-element-in-array
Open

josephperez3 wants to merge 1 commit into
ClickHouse:masterfrom
josephperez3:fix-iceberg-tuple-element-in-array

Conversation

@josephperez3

@josephperez3 josephperez3 commented Nov 2, 2026 •

Copy link
Copy Markdown

Related: #102362

Changelog category (leave one):

  • Bug Fix (user-visible misbehavior in an official stable release)

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

Fix reading a tuple element inside an array (e.g. arr.u of arr Array(Tuple(u ..., v ...))) from Iceberg tables whose Parquet files have field ids, which returned empty arrays since 26.5. Such files are written by Spark, Flink, pyiceberg and ClickHouse itself.

Description

Since #102362, SELECT arr.u FROM <iceberg table> returns [] for every row when the Parquet data file carries field ids. The same holds for any tuple element reached through a list: deep.s.p, aa.u on Array(Array(Tuple(...))), st.x.u, and these subcolumns in WHERE and PREWHERE. Reading the whole arr, tupleElement, arrayMap, ARRAY JOIN, plain tuples, and file()/s3() on the same Parquet file are not affected. 26.4 returns the right values; 26.5, 26.10 and current master return [].

Cause: #102362 made the Iceberg column mapper name a list element arr.element (and its fields arr.element.u), which the writer needs. To resolve the mapped names of the element's fields, processSubtreeArrayInner also replaced the reader-side name of the element node with arr.element. The leaf was then named arr.element.u, the requested arr.u was not found, and it was filled with defaults.

Fix: SchemaConverter keeps the reader-side name (arr.u, as for files without field ids) and tracks the path in the column mapper's names in a separate TraversalNode::column_mapper_path, used only to look up the mapped names of children.

Test: 05483_iceberg_tuple_element_inside_array_subcolumn writes an IcebergLocal table with ClickHouse (so the files have field ids) and reads tuple elements inside arrays of several shapes, with optimize_move_to_prewhere on and off. It fails on master and passes with the fix. Other Iceberg/Parquet/data lake stateless tests that run locally (477) and the *Iceberg*:*Parquet* gtests (120) give the same results with and without the change.

Since this is a silent wrong result in 26.5 and later, could it be backported to 26.8 LTS and 26.10?

Not covered here: two-level (legacy) Parquet lists with field ids. Iceberg requires three-level lists, and I haven't tested writers that produce two-level ones.


Workflow [PR]
Sync PR [sync-upstream/pr/128775]

@CLAassistant

CLAassistant commented Nov 2, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

…s with field ids

`SELECT arr.u FROM <iceberg table>` with `arr Array(Tuple(u ..., v ...))` returned empty arrays
since ClickHouse#102362 (26.5) when the Parquet data file has field ids, as files written by Spark, Flink,
pyiceberg and ClickHouse itself do. The same held for `deep.s.p`, `aa.u`, `st.x.u` and any other
tuple element reached through a list, also inside WHERE.

ClickHouse#102362 made the Iceberg column mapper name the element of a list `arr.element` (and its fields
`arr.element.u`), which the writer needs. To keep resolving the names of the element's fields in
the Parquet reader, it replaced the reader-side name of the element node with `arr.element`. So
the leaf was named `arr.element.u`, the requested `arr.u` was not found in the file, and it was
filled with defaults.

Keep the reader-side name (`arr.u`, as for files without field ids and in `file()`) and track the
path in the column mapper's names separately, to strip the parent's prefix from the mapped names
of the children.
@josephperez3
josephperez3 force-pushed the fix-iceberg-tuple-element-in-array branch from 1bbbcbb to 37f0385 Compare November 2, 2026 23:06
@clickhouse-gh clickhouse-gh Bot added comp-parquet-reader-v3 Issues related to the native Parquet reader. external Author is not a member of the ClickHouse organization labels Nov 2, 2026
@alexey-milovidov alexey-milovidov added the can be tested Allows running workflows for external contributors label Nov 14, 2026
@clickhouse-gh

clickhouse-gh Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [37f0385]

Summary: ❌

job_name test_name status info comment
Code Review FAIL

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

can be tested Allows running workflows for external contributors comp-parquet-reader-v3 Issues related to the native Parquet reader. external Author is not a member of the ClickHouse organization pr-bugfix Pull request with bugfix, not backported by default

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants