Skip to content

Fix reading structs inside arrays and maps of Delta Lake tables with column mapping - #129103

Merged
alexey-milovidov merged 1 commit into
masterfrom
delta-lake-column-mapping-nested
Nov 5, 2026
Merged

alexey-milovidov merged 1 commit into
masterfrom
delta-lake-column-mapping-nested

Conversation

@alexey-milovidov

@alexey-milovidov alexey-milovidov commented Nov 3, 2026 •

Copy link
Copy Markdown
Member

With column mapping (delta.columnMapping.mode = id or name), the fields of a struct inside an array or a map of a Delta Lake table were read incorrectly without an error: an Array(Tuple(...)) column was read as [] and the values of a Map(..., Tuple(...)) column as (NULL), because the logical names of the struct fields were translated to physical names only for structs that are columns or fields of other structs. A subcolumn like array_of_structs.field failed with INCORRECT_DATA.

The names are now translated inside arrays and maps as well, and a subcolumn of an array or a map is resolved through the physical type of its column.

The test uses the golden tables table-with-columnmapping-mode-id and table-with-columnmapping-mode-name of delta-kernel-rs (written by Spark), and compares the result with their expected data. The fix also makes the column-mapped tables of the Delta corpus of #129100 (written by Spark 4.1 and 3.5) and the spark_nested_*_mode fixtures of duckdb-delta from #129094 read the same as their writers read them.

Related: #129093
Related: #129094
Related: #129100

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 structs inside arrays and maps of Delta Lake tables with column mapping: such columns were read as empty arrays or default values, and their subcolumns failed with INCORRECT_DATA.

🤖 Generated with Claude Code


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

Version info

  • Merged into: 26.11.1.1387-master (included in 26.11 and later)

…column mapping

With column mapping (`delta.columnMapping.mode` = `id` or `name`), the fields of a struct are
stored in data files under their physical names. The names were translated only for structs
that are columns or fields of other structs, but not inside `Array` and `Map`, so such fields
were not found in the Parquet file and an `Array(Tuple(...))` column was read as `[]`, and the
values of a `Map(..., Tuple(...))` column as `(NULL)`, without an error. A subcolumn like
`array_of_structs.field` failed with `INCORRECT_DATA`.

Translate the names inside arrays and maps (the schema visitor already records them under the
names of the kernel for an array element and a map key and value), and resolve a requested
subcolumn of an array or a map through the physical type of its column.

The tables of the test are the golden tables `table-with-columnmapping-mode-id` and
`table-with-columnmapping-mode-name` of delta-kernel-rs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [fca1c7f]

Summary: ✅


AI Review

Summary

PR #129103, at fca1c7f3342ba3f35bdb1f4ea2986d1b4b9cdb5c, extends Delta Lake column mapping through arrays and maps and resolves their subcolumns using physical types. The regression test covers both mapping modes, projections, filtering, and full-content comparison with Spark-generated expected data. No actionable findings identified.

Missing context / blind spots
  • ⚠️ Runtime validation remains pending: no built ClickHouse binary is available locally, and targeted stateless CI and bugfix validation have not completed. Their results are needed to confirm execution of the new regression test.
Final Verdict

Status: ✅ Approve based on source review and the supplied regression coverage; runtime validation remains subject to CI.

@clickhouse-gh clickhouse-gh Bot added pr-bugfix Pull request with bugfix, not backported by default comp-datalake Data lake table formats (Iceberg/Delta/Hudi) integration. labels Nov 3, 2026
@clickhouse-gh

clickhouse-gh Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing fca1c7f33 with master 0a399a7ff (stripped binary size, per-symbol sizes and ThinLTO time; compile times per translation unit against the most recent warmup build that recompiled it).

✅ No significant changes.

Binary sizes

programs/clickhouse-stripped: smaller than the master baseline by the known offset between the two builds, so the difference is not shown. A delta that differs from the offset by more than 50% of it is shown, in either direction.

The official master build is compiled with -g and a pull request build is not, and XRay counts debug instructions towards its instrumentation threshold, so master instruments thousands of functions more and its binary is ~0.4% larger no matter what the pull request does.

Compile time of recompiled translation units

7 translation units recompiled, 13 s compile time in total, 7 of them have a recent master baseline.

Job report

@alexey-milovidov alexey-milovidov left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Looks good.

@alexey-milovidov alexey-milovidov self-assigned this Nov 4, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Nov 4, 2026
Merged via the queue into master with commit 965a1d4 Nov 5, 2026
185 checks passed
@alexey-milovidov
alexey-milovidov deleted the delta-lake-column-mapping-nested branch November 5, 2026 00:09
@robot-clickhouse robot-clickhouse added the pr-synced-to-cloud The PR is synced to the cloud repo label Nov 5, 2026
alexey-milovidov added a commit that referenced this pull request Nov 5, 2026
…fixtures

The columns `ls` (`Array(Tuple(...))`) and `m` (`Map(..., Tuple(...))`) of `spark_nested_name_mode` and
`spark_nested_id_mode` were not queried because ClickHouse read them incorrectly; it is fixed now. The results
are the same as expected by duckdb-delta.

Related: #129103

Co-Authored-By: Claude Opus 5.5 <[email protected]>
alexey-milovidov added a commit that referenced this pull request Nov 5, 2026
…g fix

The column-mapped tables (`column_mapping_id`, `delta332_column_mapping_id`, `iceberg_compat_v2`) are now read
the same as their writers read them, including structs inside arrays and maps and their subcolumns.

Related: #129103

Co-Authored-By: Claude Opus 5.5 <[email protected]>
alexey-milovidov added a commit that referenced this pull request Nov 5, 2026
The tables `table-with-columnmapping-mode-id` and `table-with-columnmapping-mode-name` were added with
the fix of reading structs inside arrays and maps under column mapping.

Related: #129103

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@clickhouse-gh clickhouse-gh Bot added comp-delta-lake Delta Lake tables: reading Delta metadata through delta-kernel-rs (table snapshots, schema and ty... and removed comp-datalake Data lake table formats (Iceberg/Delta/Hudi) integration. labels Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp-delta-lake Delta Lake tables: reading Delta metadata through delta-kernel-rs (table snapshots, schema and ty... pr-bugfix Pull request with bugfix, not backported by default pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants