Skip to content

Read the Iceberg initial-default of fields absent from older data files - #130101

Merged
alexey-milovidov merged 40 commits into
ClickHouse:masterfrom
groeneai:iceberg-initial-default-129992
Nov 18, 2026
Merged

alexey-milovidov merged 40 commits into
ClickHouse:masterfrom
groeneai:iceberg-initial-default-129992

Conversation

@groeneai

@groeneai groeneai commented Nov 8, 2026 •

Copy link
Copy Markdown
Collaborator

Closes: #129992
Related: #130028
Related: #130010

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):

Fixed reading Iceberg tables with columns added with an initial-default: rows of data files written before such a column was added now return the default instead of NULL, also in filters and for fields added inside a struct, and a required column added with a default no longer makes the table unreadable.

Description

On 26.10.2.103, SELECT * FROM icebergLocal('iceberg_v3/iceberg_v3_default_value') (Impala test table, j added with "initial-default": -1) returns 1 \N instead of 1 -1, and WHERE j = -1 returns nothing.

ClickHouse never parsed initial-default. A field absent from a data file is synthesized with the type default in two places: the schema evolution DAG, for a file read under its own older schema, and the format reader, for a file read under the schema that has the field.

The default is now parsed once in IcebergSchemaProcessor (the spec's JSON single-value serialization, all types), used by the DAG, and passed through ColumnMapper to the Parquet, ORC and Avro readers. A reader fills a field with its default only if the file has field ids at that level and none is the field's id (the rule of #126879); ORC and Avro no longer bind it to a same-named field of the file (a dropped and re-added column). An identity partition value of the file, even NULL, still comes before the default (NULL partition values are now applied). The query condition cache key of a table function and the Parquet columns cache key include the defaults. A metadata.json schema replaces an identical manifest-header copy, which lacks the defaults.

Test: the Impala and DuckDB tables of #130028 and #130010, as written and under the newer schema, plus ClickHouse-written Parquet, ORC and Avro tables evolved with nested, required, struct, list and malformed defaults; fails on master, passes with the fix (50/50 randomized).

Unchanged: write-default on INSERT, Vortex (no field ids), a field missing inside an Avro record on the newer schema (still an error), equality deletes on absent fields (#129997). A struct that is NULL in a row reads its added fields' defaults (an Iceberg struct is read as a non-Nullable Tuple).


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

Version info

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

groeneai and others added 5 commits November 8, 2026 03:26
An Iceberg field added with an `initial-default` must read as that default in
every data file written before it was added (spec, "Column Projection"). The
key was never parsed, so such rows read as NULL, filters on the column missed
them, and a required field added with a default made the table unreadable.

A field absent from a data file is synthesized in two places, and both now use
the default:
- the schema evolution DAG, for a file read under its own older schema: the
  constant of a new top-level field, and `AddingTransform` for a field added
  inside a struct (also inside list elements and map values);
- the format reader, for a file read under the schema that has the field (its
  manifest was rewritten under the newer schema and the old snapshot expired,
  or a stale ClickHouse INSERT): Parquet (top level, struct elements at any
  depth, requested subcolumns), ORC (top level and struct elements) and Avro
  (top level), through a new `ColumnMapper` map of defaults.

The JSON single-value serialization (spec Appendix D) of every type is parsed
once in `IcebergSchemaProcessor`; a malformed default, or a non-null one for a
type that must default to null, fails with ICEBERG_SPECIFICATION_VIOLATION
instead of being ignored. A struct field's own default can only be `{}`, which
stands for the defaults of its fields.

A reader fills a field with its default only when the data file identifies
the fields at that level by field id and none of them has the field's id, the
rule ClickHouse#126879 introduced for Avro: a field missing only by name may be in the
file under another name. With that proof, ORC and Avro no longer read such a
column from a same-named field of the file (a dropped column re-added under
the same name), and ORC builds no search argument for that file, because it
resolves predicate columns by name.

The query condition cache key of UUID-less tables and the Parquet columns cache
identity now include the defaults, since the value read for an absent field
depends on them. A metadata.json schema replaces an identical copy registered
from a manifest header, which does not carry `initial-default`.

The new test reads the Apache Impala and DuckDB Iceberg tables of ClickHouse#130028 and
ClickHouse#130010 (identical files) as written and with their older data files bound to
the newer schema, and ClickHouse-written Parquet, ORC and Avro tables evolved
with nested, required, struct, list and malformed defaults.

Closes ClickHouse#129992

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…tamp defaults

A field whose value comes from an identity partition of the data file must
read as that value, even when it is NULL, before its `initial-default` applies
(spec, "Column Projection"). NULL identity values were skipped, so the reader
filled the default instead; and a struct read as a whole got the defaults of
its nested identity sources. NULL identity values are now applied, and the
per-file column mapper drops the defaults of the file's identity partition
columns (the shared mapper is replaced by the per-file one for such files).

A `timestamp` / `timestamp_ns` default must be an ISO-8601 local date-time and
a `timestamptz` / `timestamptz_ns` default the same with `+00:00`; the lenient
parser accepted any offset (and shifted the value), a missing offset, a space
separator. Other shapes now fail with ICEBERG_SPECIFICATION_VIOLATION.

With `input_format_parquet_allow_missing_columns = 0`, a field proven absent by
field id that has a default is not a missing column (ORC and Avro already
exempt it).

Adds the DuckDB `partition_values_missing_edge_cases/default/mixed` table of
ClickHouse#130010 (identical files); it is not read by a test yet, since its
`final.metadata.json` name is rejected (ClickHouse#129988).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ity precedence

A data lake read hands tuple-element columns (`t.x`) to the ORC reader whenever the table's
format supports PREWHERE, and an Iceberg table function defaults to Parquet. The absence check
compared such a column's field id with the ids of the root struct only, so every nested id
looked absent: `SELECT t.x` on an Iceberg ORC table read NULL, and a field of an absent struct
without a struct default got its own default. The check now walks the structs on the column's
path by field id and applies the default inside an absent struct only when every struct from
the absent one down has a struct default, as the Parquet reader does.

The identity partition precedence is tested on a copy of DuckDB's `mixed` table whose metadata
file is renamed, because `final.metadata.json` is not read as a metadata version (ClickHouse#129988).

The per-file column mapper replaces the shared one only when an identity partition column of
the file has a default, the only case where the two differ.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…fix struct

The ORC absence check treated every prefix of a column name that names a field of the data lake
schema as a struct on the column's path. A top-level field `a.b` next to a struct `a` was thus
looked up inside `a`, not found, and read as absent, so `SELECT a.b` returned NULL instead of
the file's value. Field ids are unique in an Iceberg schema, so a struct on the way that has
the column's own id holds the column itself: the walk now stops there and reads the field.

The parsed `iceberg.id` attributes of a struct are cached per file, since the check now looks
each struct up twice per header column.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Shorten two design comments (schema copy replacement, ORC same-named field) to one line each.

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

groeneai commented Nov 8, 2026

Copy link
Copy Markdown
Collaborator Author
Internal second-model review (4 rounds)
  • ❌ NULL identity partition value overridden by initial-default (own review r0): AGREE, fixed in r1; test in r2.
  • ❌ ORC tuple-element columns proven absent against the root struct only, so SELECT t.x read NULL (gate r1): AGREE, fixed in r2.
  • ❌ ORC top-level field named a.b next to a struct a walked as a field of a and read NULL (gate r2): AGREE, fixed in r3.
  • ⚠️ timestamp default text shape not validated (gate r0): AGREE, fixed in r1.
  • ⚠️ Parquet throws for a proven-absent field with a default under input_format_parquet_allow_missing_columns = 0 (gate r0): AGREE, fixed in r1.
  • ⚠️ a NULL struct's absent field reads its default (gate r2): DISAGREE as a code change here; an Iceberg struct is read as a non-Nullable Tuple, so a NULL struct and a struct of NULL fields are the same value after the read; noted in the description.
  • 💡 per-file mapper rebuilt for every identity-partitioned file (own + gate r1): AGREE, narrowed in r2.
  • 💡 ORC field ids re-parsed per column (own r2): AGREE, cached per file in r3.
  • 💡 nested identity value not injected into a whole-struct read (gate r2): DISAGREE, same result on master; that is Iceberg: identity partition value is not used for a nested struct field missing from the data file (NULL instead of the value) #129995.
  • 💡 microsecond timestamp default with 7-9 fraction digits is truncated (gate r2): DISAGREE, Iceberg's SingleValueParser parses and truncates it the same way.
  • 💡 table-function query condition cache id of an ORC/Avro-configured table lacks the defaults (gate r2): DISAGREE, it lacks the field ids on master as well, and initial-default cannot change.
  • 💡 required complex field without a default reads its type default (gate r0): DISAGREE, unchanged master behaviour.
  • 💡 named-table query condition cache id ignores the defaults (gate r0): DISAGREE, a named table's id is its UUID on master for the field ids as well.
  • 💡 a top-level a.b with a default next to a struct a, both absent from a file, reads NULL (own + gate r3): noted, not blocking; master reads NULL as well, and the readers' flat name encoding does not carry the parent of a dotted name.
  • 💡 the default parser accepts a non-ISO date, an undashed UUID and an over-scale decimal, and rejects a time with 7-9 fraction digits (gate r3): DISAGREE, no Iceberg writer emits these; spec-shaped text parses as in Iceberg, and the time case fails with an error, never a wrong value.
  • 💡 cache arms only assert results (gate r0): DISAGREE, the salt-removal mutations change the output, so both caches are written and served.

@groeneai

groeneai commented Nov 8, 2026

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes: SELECT * FROM icebergLocal('iceberg_v3/iceberg_v3_default_value') from data_iceberg/impala returns 1 \N on master and on 26.10.2.103 every time; WHERE j = -1 returns nothing.
b Root cause explained? initial-default was never parsed. A field absent from a data file is synthesized by the schema evolution DAG (file read under its own older schema) and by the format reader (file read under the newer schema); both used the type default.
c Fix matches root cause? Yes: the default is parsed once in the Iceberg schema layer and materialized at exactly those two places (DAG constant, AddingTransform, Parquet/ORC/Avro readers through ColumnMapper). No setting, no guard.
d Test intent preserved / new tests added? New stateless test 05568_iceberg_initial_default (external Impala/DuckDB tables, both read paths, nested, required, struct, list, malformed defaults, both caches) and a gtest for the manifest-header schema replacement. No existing test changed.
e Both directions demonstrated? The test fails on master (NULLs, an exception for the required field and for Parquet with input_format_parquet_allow_missing_columns = 0, the dropped column's data on ORC/Avro, malformed timestamps accepted) and passes with the fix, 50/50 randomized. Removing each part of the fix separately reddens its own lines.
f Fix is general across code paths? DAG top-level and nested (struct, list element, map value), Parquet (in-reader PREWHERE and min/max from statistics included), ORC (top level and structs, by field id at every struct level, also for tuple-element columns and for a top-level dotted name next to a struct, filter push-down), Avro (top level), query condition cache, Parquet columns cache, manifest-header registration; an identity partition value of the file, even NULL, keeps precedence over the default on the reader and filter paths. Vortex has no field ids, so absence cannot be proven; unchanged.
g Fix generalizes across inputs (params/datatypes/wrappers)? Every Iceberg primitive type (incl. long minimum, float, negative-epoch timestamp, timestamptz, time, uuid, fixed, binary), struct with {} and without a default, a list with a NULL element, a required field, Nullable and non-Nullable ClickHouse types; the malformed defaults in the test (incl. a timestamp with an offset, a timestamptz without +00:00) fail with code 743.
h Backward compatible? (maintainer-approved exception only) No setting or format change. Results change only for tables whose fields have a non-null initial-default (NULL becomes the spec value) and tables with a required added field (an exception becomes a result); a default the parser rejects now fails instead of being ignored.
i Invariants and contracts preserved? Same columns and types (defaults converted with convertFieldToTypeOrThrow), full columns, the missing-values bits are not set for a defaulted column so AddingDefaultsTransform does not overwrite it, and cached transformation DAGs of a replaced schema copy are dropped under the same exclusive lock.

Session id: cron:clickhouse-impl-slot-6:20261108-072400

@groeneai

groeneai commented Nov 8, 2026

Copy link
Copy Markdown
Collaborator Author

cc @SmitaRKulkarni @al13n321, could you review this and add the can be tested label so CI runs? It parses the Iceberg initial-default once in IcebergSchemaProcessor and uses it instead of NULL for fields absent from older data files: as a constant in the schema evolution DAG, and in the Parquet, ORC and Avro readers through ColumnMapper when the file proves the field absent by field id.

@clickhouse-gh

clickhouse-gh Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [f3036d9]

Summary: ✅


AI Review

Summary

This fixes Iceberg initial-default handling during schema evolution and missing-field reads in Parquet, ORC, and Avro, preserving identity-partition precedence and separating cached results by defaults. Reviewed head f3036d959a3da71378897e01680ad0261600bb77, including every prior discussion and the subsequent fixes. No new actionable findings; the previously deferred limitations and accepted tradeoffs do not require new threads. Regression coverage and CI reports were inspected; tests were not rerun locally.

Final Verdict

Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added pr-bugfix Pull request with bugfix, not backported by default can be tested Allows running workflows for external contributors comp-datalake Data lake table formats (Iceberg/Delta/Hudi) integration. labels Nov 8, 2026
@clickhouse-gh

clickhouse-gh Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing f3036d959 with master 59e76b2ee (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.

Object file sizes

24 object files changed (+516.20 KiB total), 0 added.

Object file Master PR Δ
src/CMakeFiles/dbms.dir/Storages/ObjectStorage/DataLakes/Iceberg/SchemaProcessor.cpp.o 734.07 KiB 881.07 KiB +147.00 KiB (+20.03%)
src/CMakeFiles/dbms.dir/Processors/Formats/Impl/NativeORCBlockInputFormat.cpp.o 1.03 MiB 1.17 MiB +145.28 KiB (+13.81%)
src/CMakeFiles/dbms.dir/Formats/FormatFilterInfo.cpp.o 177.67 KiB 268.04 KiB +90.37 KiB (+50.86%)
src/CMakeFiles/dbms.dir/Processors/Formats/Impl/Parquet/SchemaConverter.cpp.o 680.53 KiB 727.69 KiB +47.16 KiB (+6.93%)
src/CMakeFiles/dbms.dir/Processors/Formats/Impl/AvroRowInputFormat.cpp.o 1.26 MiB 1.30 MiB +44.21 KiB (+3.43%)

711 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only clickhouse-bundle) and not compared.

Slowest function optimization changes (ThinLTO)

Median per-function time ratio to the master baseline: programs/clickhouse ×0.81 (each binary is linked separately, on a different machine and with different build flags); deltas below are relative to it.

Binary Function Master PR Δ vs median
programs/clickhouse DB::registerFunctionConversion(DB::FunctionFactory&) 7.2 s 15.3 s +9.5 s (+162%)
Compile time of recompiled translation units

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

Job report

…ld with another id

The ORC search argument resolves a predicate column by name. The guard that
skipped it for an absent column with a same-named field of the file looked only
at the header columns, so a predicate on a tuple element (`t.j`, where `t` is in
the header and its field `j` was dropped and re-added) was still built against
the dropped field's statistics, and the stripe holding a row whose `t.j` reads
its `initial-default` was skipped: `SELECT t ... WHERE t.j = 9` returned nothing
while `SELECT t` returned `(9)`.

The guard now also checks every column the filter requires, resolved by field
id through the current-schema mapper (the filter names columns of the current
schema, also when the file is read under its own older schema). This also covers
an added field without a default (`WHERE t.j IS NULL` lost the row the same way).

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

@alexey-milovidov alexey-milovidov left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is interesting - a default that has to be processed and filled within the format. Ok.

@alexey-milovidov alexey-milovidov self-assigned this Nov 8, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Nov 8, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch Nov 8, 2026
# Conflicts:
#	src/Storages/ObjectStorage/DataLakes/Iceberg/tests/gtest_iceberg_schema_processor.cpp
alexey-milovidov and others added 2 commits November 9, 2026 14:07
Resolve conflicts with the migration of `src/Processors/Formats` to
`-WithMemoryTracking` containers, the Iceberg schema validation
(`findSchemaViolation`) and the ORC map key type fix: keep both sides, and
use `VectorWithMemoryTracking`, `UnorderedMapWithMemoryTracking` and
`UnorderedSetWithMemoryTracking` in the code added by this PR under
`src/Processors/Formats`, as the style check now requires.
@alexey-milovidov

Copy link
Copy Markdown
Member

🕵 Merged master to resolve the conflicts with the -WithMemoryTracking container migration of src/Processors/Formats, the Iceberg schema validation and the ORC map key fix; the PR's code under src/Processors/Formats now uses -WithMemoryTracking containers as the style check requires. 05568_iceberg_initial_default passes locally. The previous red was only Build profile diff failing with LogClusterNotReady (CI logs cluster outage), unrelated to this PR; a classification fix is in progress in #129675.

A requested element of a struct, such as `t.s` with `optimize_functions_to_subcolumns = 1`,
is read through the `nested_tables` branch of `orcColumnsToCHChunk`, which passed neither
the mapper path nor a type hint of the struct itself, so the field-id matching and the
`initial-default` handling of `readColumnFromORCColumn` did not apply: a dropped field
`t.s.j` was read instead of the default of the re-added one. Build the hint of the struct
from the requested elements and pass the mapper path.

Address review: ClickHouse#130101 (comment)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Comment thread src/Formats/FormatFilterInfo.cpp Resolved
…cestors

A subcolumn path of a query never names the element of a list or the key or
value of a map: `l.element` of `l Array(Tuple(element ...))` is the field
`element` of the elements of `l` (Iceberg path `l.element.element`).
`getIcebergFieldPath` took the longest prefix found in the storage encoding,
here the list's element node `l.element`, which has no default, so an absent
`l` read `l.element` as `[]` on Parquet, ORC and Avro while the whole `l` and
`tupleElement(l, 'element')` read the default. It now takes only fields
reached from the top level through structs. Parquet's missing tuple element
path names its field by the Iceberg path (`l.element.y`), so it passes that
field explicitly instead of resolving it.

Avro filled the default of an absent `n.x` without looking at `n`: an absent
`n` with no struct default is NULL, and so is `n.x`, as Parquet and ORC read
it. An Avro data file is read through tuple subcolumns whenever the table's
format is Parquet (the table function's default), so `SELECT n.x` returned the
default of `x` where master returns NULL. `getColumnsAbsentFromIcebergFile`
now also returns the absent columns inside an absent struct without a struct
default, and these get no default.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
`getColumnsAbsentFromIcebergFile` looked up the exact column name in the
storage encoding. A subcolumn of a list member is not there: for `l.y` of
`l Array(Tuple(y ...))` the encoding has `l` and `l.element.y`, so `l.y` of a
list absent from an Avro file was never marked absent. With the table's format
Parquet (the table function's default) the file is read through subcolumns,
and `SELECT l.y` threw `THERE_IS_NO_COLUMN`, or read `[]` with
`input_format_avro_allow_missing_fields = 1`, where Parquet and ORC read the
member of the list's default. The absence is now tested on the field that has
the column, `getIcebergFieldPath`, like the default lookup already does.

A flattened nested read of an Avro array also skips those columns now: a list
dropped and added again under a new id read `p.y` from the dropped list while
`p` read the default.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Comment thread src/Formats/FormatFilterInfo.cpp Resolved
`ColumnMapper::getIcebergInitialDefault(path, type)` first looked `path` up as
an exact storage path. A query subcolumn can spell another field's storage
path: in `q Array(Tuple(element Tuple(y Nullable(Int32)), y Array(Nullable(Int32))))`
the subcolumn `q.element.y` (member `y` of member `element`) is also the
storage path of the sibling member `y` of the list elements. Reading
`q.element.y` from a file without `q` returned that sibling's own default
(`[9]`) instead of the subcolumn of `q`'s default (`[5,6]`), and
`WHERE has(q.element.y, 5)` lost the row, on Parquet, ORC and Avro.

The getter now takes the field explicitly (the readers already resolve it
with `getIcebergFieldPath`) and extracts the subcolumn from that field's
default; the ORC nested synthesis keeps passing the storage path as both.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…uld have it

Address review: `getColumnsAbsentFromIcebergFile` required field ids only on the
top-level fields and then looked the field id up in the ids of the whole file. A
nested field stored without a `field-id` was therefore taken as absent, and its
`initial-default` (or NULL) was read instead of its value: `SELECT n.x` and
`WHERE n.x = 100` disagreed with `SELECT n`.

The field is now absent only if the record that would have it (found by the id of
the struct, list element or map value) identifies all its fields by id and none
of them has the field's id, or if that container is absent itself, like in the ORC
and Parquet readers.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
clickhouse-gh[bot]
clickhouse-gh Bot previously approved these changes Nov 17, 2026
`Poco::Dynamic::Var::extract` returns a const reference, so the copy of the
`Poco::JSON::Object::Ptr` is unnecessary; `Build (arm_tidy)` rejects it with
`performance-unnecessary-copy-initialization`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@clickhouse-gh
clickhouse-gh Bot dismissed their stale review November 17, 2026 23:23

AI review of a later commit does not approve the PR, see the AI Review comment.

groeneai and others added 2 commits November 18, 2026 00:22
…en they are pruned

Whether the fields of an ORC struct are matched by Iceberg field id is decided on
the struct of the file when the fields are selected, but the conversion decided
it again on the selected struct, which has only the requested fields. If a field
without a field id was not requested, the selected struct had field ids on all
its fields, so the conversion matched by field id a field that was selected by
name, did not find it, and filled in the `initial-default` of the field added
again under that name: in an ORC file with `t.j` (field id 2) and `t.k` (no field
id), read under a schema where `j` was dropped and added again with a default,
`SELECT t` returned `(7,100)` but `SELECT t.j` returned the default `9`, and both
`WHERE t.j = 100` and `WHERE t.j = 9` matched nothing with filter push-down.

The reader now passes the structs of the file with a field without a field id to
the conversion, which matches their fields by name, as the selection does, so
`t.j` reads `100` as on master.

Reported in ClickHouse#130101 (comment)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The ORC filter push-down guard resolved a filter column by Iceberg field id at
every struct on its way and gave up at a struct with a field without a field id,
so push-down stayed enabled. The reader matches such a struct by name and the
structs below it by field id, so the two could disagree one struct deeper: in an
ORC file with `t.s.j` (field id 4) and `t.k` (no field id), read under a schema
where `t.s.j` was dropped and added again with `initial-default = 9`, `SELECT t`
returned `((9),7)` but `WHERE t.s.j = 9` matched nothing with push-down, because
the search argument was built on the old physical `j`.

The guard now resolves a struct with a field without a field id by name, as the
reader selects it, so it sees that `t.s.j` is absent from the file while a field
of that name is in it, and disables push-down.

Reported in ClickHouse#130101 (comment)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Nov 18, 2026
Merged via the queue into ClickHouse:master with commit 396cfed Nov 18, 2026
563 of 565 checks passed
@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added the pr-synced-to-cloud The PR is synced to the cloud repo label Nov 18, 2026
groeneai added a commit to groeneai/ClickHouse that referenced this pull request Nov 18, 2026
One conflict, in NativeORCBlockInputFormat.cpp: master (ClickHouse#130101) selects and reads the fields of a struct by Iceberg field id
when all of them have one, and this branch pairs them by name with DataTypeTuple::matchElementsByName. Both are kept: the
field id first, else the name pairing; findORCStructFieldByName, which the new master code still calls, is the one-name
case of that pairing. The missing-column fill keeps master's absent-column default before createMissingColumn.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@clickhouse-gh clickhouse-gh Bot added comp-iceberg Apache Iceberg tables: reading and writing Iceberg metadata (snapshots, manifests, schema evoluti... and removed comp-datalake Data lake table formats (Iceberg/Delta/Hudi) integration. labels Nov 22, 2026
groeneai added a commit to groeneai/ClickHouse that referenced this pull request Nov 23, 2026
…the name mapping

Since ClickHouse#130101 a field that a Parquet data file proves absent (every field of its level has a
field id, none of them the field's) reads as its `initial-default`. A file without field ids
never proved that, so a field added with an `initial-default` read as NULL from the files read
through `schema.name-mapping.default`. Their ids come from the mapping, and an element the
mapping does not name is not in the table, so the absence check now takes the ids from
`getFieldId` and skips such elements, like Iceberg Java's readers after `ApplyNameMapping`.

The test also covers the JOIN runtime filter file pruner of the merge: with the names of `id` and
`b` swapped in the mapping, pruning by the manifest bounds of `id` lost the row of `id` 50.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
groeneai added a commit to groeneai/ClickHouse that referenced this pull request Nov 23, 2026
…apper path

The `initial-default` code of ClickHouse#130101 keyed the field ids of a struct, and looked up the default
of a missing tuple element, by `TraversalNode::name`, which master sets to the ColumnMapper path
(`l.element`) inside a list. This PR keeps `name` the ClickHouse name (`l`) and the mapper path in
`column_mapper_path`, so after the merge a field added with an `initial-default` to the element
struct of a list read as NULL, or threw THERE_IS_NO_COLUMN (05568_iceberg_initial_default). Both
lookups now use `getColumnMapperPath()`, as does the map key/value check of ClickHouse#130102.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
groeneai added a commit to groeneai/ClickHouse that referenced this pull request Nov 23, 2026
…rquet-list-element-subcolumn

The `initial-default` code of ClickHouse#130101 (merged 2026-11-18) relies on the list element node being named
with the column mapper path, which this PR changes: 05568_iceberg_initial_default fails on the merge
of this PR with master. The fix in the next commit uses that code, so it needs master.
groeneai added a commit to groeneai/ClickHouse that referenced this pull request Nov 23, 2026
…column mapper path

ClickHouse#130101 keyed the field ids of a struct, and looked up the default of a missing tuple element, by
`TraversalNode::name`, which master set to the column mapper path (`l.element`) inside a list. This
PR keeps `name` the ClickHouse name (`l`), so on the merge with master a field added with an
`initial-default` to the element struct of a list was read as NULL, or threw THERE_IS_NO_COLUMN
with `input_format_parquet_allow_missing_columns = 0` (05568_iceberg_initial_default). Both lookups
now use `getColumnMapperPath()`.

The subcolumn `l.y` of such a field, read without the rest of `l` (addMissingElementOfTupleInArray),
now takes the `initial-default` of `l.element.y` instead of NULL, keeping the sizes of `l`, also with
`input_format_parquet_allow_missing_columns = 0`, which now only rejects it when there is no default.
Requested on ClickHouse#130023 (issuecomment-6935263914). ORC already read these values.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
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-iceberg Apache Iceberg tables: reading and writing Iceberg metadata (snapshots, manifests, schema evoluti... 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.

Iceberg v3 initial-default is not implemented: columns added with a default are read as NULL from older data files

3 participants