Repository navigation
Fix reading a tuple element inside an array from Iceberg Parquet files with field ids - #128775
Open
josephperez3 wants to merge 1 commit into
Open
josephperez3 wants to merge 1 commit into
josephperez3 wants to merge 1 commit into
Conversation
…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
force-pushed
the
fix-iceberg-tuple-element-in-array
branch
from
November 2, 2026 23:06
1bbbcbb to
37f0385
Compare
Contributor
|
Workflow [PR], commit [37f0385] Summary: ❌
|
This branch has not been deployed
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.
Related: #102362
Changelog category (leave one):
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.uofarr 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.uonArray(Array(Tuple(...))),st.x.u, and these subcolumns inWHEREandPREWHERE. Reading the wholearr,tupleElement,arrayMap,ARRAY JOIN, plain tuples, andfile()/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 fieldsarr.element.u), which the writer needs. To resolve the mapped names of the element's fields,processSubtreeArrayInneralso replaced the reader-side name of the element node witharr.element. The leaf was then namedarr.element.u, the requestedarr.uwas not found, and it was filled with defaults.Fix:
SchemaConverterkeeps the reader-side name (arr.u, as for files without field ids) and tracks the path in the column mapper's names in a separateTraversalNode::column_mapper_path, used only to look up the mapped names of children.Test:
05483_iceberg_tuple_element_inside_array_subcolumnwrites anIcebergLocaltable with ClickHouse (so the files have field ids) and reads tuple elements inside arrays of several shapes, withoptimize_move_to_prewhereon 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]