Repository navigation
Conversation
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-worker-slot-3:20260708-075500 |
|
Workflow [PR], commit [6dc8c25] Summary: ❌
AI ReviewSummaryThis PR replaces Findings❌ Blockers
Tests
Final VerdictChanges requested. LLVM Coverage ReportMeasured on commit 6dc8c25.
Changed lines: Changed C/C++ lines covered: 359/367 (97.82%) · Uncovered code |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-worker-slot-5:20260708-085700 |
|
Pushed 774106b: the new regression test 04401 was failing on |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-worker-slot-1:20260708-095500 |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-worker-slot-13:20260708-111900 |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-worker-slot-6:20260708-131600 |
CI finish ledger — d7a69cdAll gating checks passed (Finish Workflow + Mergeable Check green, 0 failed checks). CH Inc sync still running (private, exempt).
Session id: cron:our-pr-ci-monitor:20260708-180000 |
There was a problem hiding this comment.
The following query throws logical error:
SET allow_experimental_nullable_tuple_type = 1;
INSERT INTO FUNCTION file('e.arrow', 'Arrow')
SELECT CAST(tuple(), 'Nullable(Tuple())') AS s;
SET input_format_arrow_allow_missing_columns = 1;
SELECT * FROM file('e.arrow', 'Arrow', '`s.x` Int32');In NestedUtils, the null-free fast path is now gone.
Since ORC is affected, let's add comprehensive test for that format as well.
You can simplify the code a lot by using existing helpers:
- The null-map merge loop →
ColumnNullable::applyNullMap - The default-materializing insertFrom loop →
filter + IColumn::expand - The merge semantics →
applyParentNullMapToExtractedSubcolumn
|
Thanks @nihalzp — addressed all four in eb279c2. 1. Empty 2. Null-free fast path. Restored: 3. Simplified via the existing helpers.
4. ORC coverage. Added the full Arrow case set through the ORC reader, plus the empty- Verified: empty-tuple gtest fails on the pre-fix code and passes after; |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-worker-slot-0:20260710-133500 |
|
Pushed Root cause (not our Fix: gate the |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-worker-slot-0:20260710-172200 |
|
Follow-up on the 14:22Z review (comment Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-worker-slot-7:20260710-224400 |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-worker-slot-3:20260711-000400 |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-worker-slot-0:20260711-010700 |
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 206/211 (97.63%) · Uncovered code |
CI finish ledger — a117a4aEvery failure below has an owner (a fixing PR). Only
Session id: cron:our-pr-ci-monitor:20260711-053000 |
|
@groeneai Fix conflicts. |
…mn-109726 Conflict: src/Processors/Formats/Impl/ArrowIPC/ArrowIPCBlockInputFormat.cpp, in buildChunk's nested-extractor block. This branch deletes that block, because the extractor now addresses tuple elements by name through the type system and reshaping the decoded column onto the `Nested::collect` type has no job left; master meanwhile replaced the block's `realignStructFieldsToRequested` call with `reinterpretRawByteColumns` plus `prepareArrowColumnForCast` against that same intermediate type. Resolved by taking master's file and re-applying this branch's two edits to it, so every unrelated master change in the file survives verbatim. The added-line sets of both diffs are identical (834 lines, empty symmetric difference in both directions); the deleted sets differ only by master's five lines inside the removed block. Dropping those two calls with the block loses nothing. They reconciled raw-byte leaves before the intermediate cast that no longer exists, and the per-column tail already runs `reinterpretRawByteColumns(column, header_column.type)`, `prepareArrowColumnForCast` and `castColumn` against the requested type on every path, nested or not. Measured on this merge (build id 45d85137): `05023_arrow_type_hints_reordered_wrapped_nested`, whose `n Nested(v Int128)` and `n Nested(d Int32)` arms are that reconciliation's guardians, returns [1234567890123456789] and [2932996] and passes; 04401 passes; the 11 NestedUtils gtests pass; and the issue ClickHouse#109726 repro still returns 42 (0 before the fix).
|
Conflicts resolved in 880f3f6; the PR is The only conflict was in Those two calls reconciled raw-byte leaves before the intermediate cast that no longer exists, and the per-column tail still runs One thing I would like your call on, found while re-checking the resolver contract. ORC prunes before the helper sees the request:
ORC's answer is identical before and after, so it is pre-existing rather than something this PR changes (its entire ORC diff is the one changed call at line 3002). The fix would be to make ORC's path selection exact-first, then case-insensitive, with an end-to-end ORC case. I can do that here, or keep this PR on its single root cause and send it separately. Whichever you prefer. |
|
Fix ORC bug in this PR. |
With `input_format_orc_case_insensitive_column_matching = 1` a request for a
struct field was resolved by lower-casing both sides and taking the first match,
so a struct holding two fields whose names differ only by case (`A` and `a`)
answered every request with whichever field the file happens to list first.
Three places did this, and they did not even agree with each other:
- `traverseDownORCTypeByName` took the first case-folded field, so a flattened
subcolumn read of `c0.a` walked into `A`;
- `updateIncludeTypeIds` keyed its field map on the folded name, so a collision
overwrote the earlier entry and the include list selected the last folded
field for every colliding element, leaving the other element's stream unread;
- `readColumnFromORCColumn` bound each ORC field to the first case-folded
element of the type hint, so both colliding fields claimed the same element.
Measured on `Tuple(A Nullable(Tuple(b UInt32)), a Tuple(b UInt32))` written to
ORC (3 rows, middle row a struct NULL) and read with the setting on:
read before after
`c0.a` flattened (11),(0),(13) (21),(22),(23)
whole column ((21),(0)),((22),(0)),.. ((11),(21)),(NULL,(22)),((13),(23))
Both were silent wrong results: the flattened read returned the sibling
element's data, and the whole-column read moved `a`'s data into `A`, filled `a`
with defaults and lost the row's NULL. What the reader now returns is what
`SELECT c0.a` over the same file returns, and what it already returned with the
setting off.
Each site resolves the exact spelling first and falls back to the folded match
only when nothing matches exactly, so a request that matches no field exactly is
still answered case-insensitively, and the include-list pruning and the read
path agree on which field answers a name. Fixing only the two pruning sites is
not enough: the whole-column read then fails with `DUPLICATE_COLUMN` because
both fields still claim element `A`.
`orcTableToCHChunk` keyed its field map on the lower-cased file name, so with
`input_format_orc_case_insensitive_column_matching = 1` two top-level columns
whose names differ only by case collapsed onto one entry and the map kept
whichever came last. A header requesting both then read the same column twice,
and which one it was depended on the order the file lists them in:
file requested `A, a` before after
`SELECT 10 AS A, 20 AS a` 10, 20 20, 20 10, 20
`SELECT 20 AS a, 10 AS A` 10, 20 10, 10 10, 20
The map now holds the file's own spellings and the lookup resolves a request
exactly before folding, which is the rule the struct-field selection already
follows. A request that matches no column exactly still folds onto one, and
among several such candidates the first in file order answers, so the choice no
longer depends on hash iteration or on which entry overwrote which.
|
Fixed here, in 53ed54d. The rule is now that a name resolves to the field spelled exactly like it, and falls back to a case-folded match only when nothing matches exactly. It is applied at every place the ORC reader resolves a name against a struct: the path traversal ( Measured on
The whole-column read also lost the row's NULL, and the top-level answer depended on the order the file lists the columns in (reversing it returned Regression arms are in Three adjacent cases of the same collapse that I measured and deliberately left alone, since each is pre-existing master behaviour outside the resolution path you asked about:
Each is a separate change with its own tests. Tell me if you want any of them in this PR and I will add them, otherwise I will leave them out of scope here. |
The comment claimed that the field spelled exactly like the request wins for the whole column in every reader that resolves a name against a struct. Measured on this branch, a whole-column `Arrow` or `ArrowStream` read of a struct whose two fields differ only by case is rejected instead: `alignStructFieldNamesCaseInsensitive` aligns the file's tuple type onto the requested one by folded name, both fields claim the first spelling, and `DataTypeTuple` refuses the duplicate with `DUPLICATE_COLUMN`. That is byte-identical to master at the merge base and is not touched here. The arms below assert the flattened read in both readers and the whole column in ORC, whose name resolution this PR makes exact-first, so the comment now says exactly that and no more.
A tuple element name may itself contain a dot, so `c0.a.b` names both the element `a.b` and the path from `a` to `b`. The Arrow reader has coverage for that pair; the ORC reader, which resolves the name against the file's struct itself in traverseDownORCTypeByName, had none, and the flattened ORC read of such a name returns column defaults without this branch. Which of the two candidates a request resolves to follows the order the schema declares them in, both in the type system and in the reader, so the reversed-order arm compares the flattened read with the direct subcolumn read rather than pinning either candidate's values.
| auto nested_column = nested_tables[search_nested_table_name].second->extractColumn(search_column_name); | ||
| /// The requested spelling, not the lower-cased one: the helper matches names | ||
| /// case-insensitively itself, and an exact element name outranks a folded match. | ||
| auto nested_column = nested_tables[search_nested_table_name].second->extractColumn(header_column.name); |
There was a problem hiding this comment.
Passing the requested spelling into NestedColumnExtractHelper does not finish the case-insensitive fix for ArrowColumnToCHColumn.
This branch still builds nested_table_type from the exact name.starts_with(nested_table_name + ".") scan above, so on a DeltaLake/TableChanges projection like `C0.x`, `c0.y` only the C0.* half of the header reaches the hint. readColumnFromArrowColumn then rematches the whole struct against that partial named-tuple hint at 2256 and 2332-2363, so y is dropped before the helper ever sees the root. The same lossy rematch is what still breaks a case-colliding pair like `c0.A`, `c0.a` here: both file fields bind to the first hint element and the second one is default-filled.
So the library reader path can still return defaults / the wrong sibling for flattened reads under case-insensitive matching even though the native Arrow and ORC paths are fixed. Can we normalize the collected sibling roots here as well, and make the struct-field hint binding exact-first (or otherwise avoid rebuilding the helper root through a lossy named-tuple hint)?
There was a problem hiding this comment.
I read the three entry points and the collection scan before deciding. The mechanism is real, two of the three entry points cannot reach it, and the first lossy step is earlier than 2256.
The change at :2911 only chooses which spelling the helper resolves; nested_table_type is built above it and is unchanged from master, so nothing here was meant to finish that part.
Which callers can take the folded path at all. readColumnFromArrowColumn is static in this file (:1817, :2517) and arrowColumnsToCHChunk is private (ArrowColumnToCHColumn.h:81), so this code is reachable only through arrowTableToCHChunk, which has exactly three callers:
| caller | case_insensitive_matching |
|---|---|
ArrowFlightSource.cpp:202 |
argument not passed, so false (ArrowColumnToCHColumn.h:34) |
DeltaLakeMetadata.cpp:565 |
/* case_insensitive_column_matching */false |
TableChanges.cpp:201 |
format_settings.parquet.case_insensitive_column_matching |
ArrowFlight and the Delta checkpoint reader cannot enter the folded branch, so the "returns defaults / the wrong sibling" outcome is available to the delta-kernel CDF read with input_format_parquet_case_insensitive_column_matching = 1, and to nothing else.
The lossy hint needs one more precondition. nested_table_type is Nested::collect(nested_columns).front().type (:2885), and collect unites only Array-typed dotted entries (getSubcolumnsOfNested, NestedUtils.cpp:467-519, gated on typeid_cast<const DataTypeArray *>). For a plain projection like `C0.x`, `c0.y` the entries pass through untouched, .front().type is the leaf type, typeid_cast<const DataTypeTuple *> at :2244 is null, and there is no named-tuple hint to rematch against: the helper receives the natively read struct whole, and :2961 casts the extracted subcolumn to the header type. The same holds for `c0.A`, `c0.a` while they are plain. The hint exists only for classic Nested (array of struct) entries, and there the grouping key in getSubcolumnsOfNested is the exact root spelling, so folding the starts_with prefix alone would not merge C0.x with c0.y: .front() would pick one of two groups instead. Canonicalizing the root spelling before collect is the part that fixes that half.
The hint binding. Agreed on shape, and this is the last unguarded site of that family. tryGetPositionByName is a single boost::iequals scan (DataTypeTuple.cpp:271-287), read_positions.emplace keeps the first (:2342), and the element that loses is filled with defaults (:2363). ORC in this PR already tries the exact spelling first and folds only as a fallback (NativeORCBlockInputFormat.cpp:2940-2942); the V3 Parquet reader runs the same folded scan but raises DUPLICATE_COLUMN when two file elements claim one hint element (Parquet/SchemaConverter.cpp:785-788); the native Arrow whole-column read ends in DUPLICATE_COLUMN as well, measured for the previous thread.
Not pushed in this round. The only consumer that can set the flag is the CDF read, and I have no carrier for it here (no Flight server, no CDF table), so the change would go in without a repro in either direction. The fix-here-or-separately question for these adjacent pre-existing cases is already open on this PR. The three line ORC mirror plus the root canonicalization is ready and goes in as soon as that is answered.
CI finish ledger - 87ffa16Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task whose fixing-PR link will be posted here when it opens.
Not counted as failures, recorded for completeness:
Both stateless failures ran at 06:39Z, before this branch contained #118390. With the fix present on master the pair is 14 for 14 green (05:59Z to 07:35Z), and fleet-wide the last failure of either test is 06:39:57Z, so the master merge above is expected to clear both. Session id: cron:our-pr-ci-monitor:20260909-090115 |
CI finish ledger - 38fda70Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task whose fixing-PR link will be posted here when it opens. Only
Session id: cron:our-pr-ci-monitor:20260909-150301 |
e80499d
The conflicts come from the `-WithMemoryTracking` containers of #126530 and from `findORCStructFieldByName` of #109741, which 26.8 does not have: the new code uses std::unordered_set and std::vector, and the recursive call keeps the name lookup of 26.8. The test enables `enable_nullable_tuple_type`, which is off by default on 26.8, and drops the five queries that read a subcolumn through a list (`tb.l.b`, `an.x.v`): 26.8 returns empty arrays for such a path even for a field that is in the file, with or without this change. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Closes: #109726
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fix reading a flattened
Tuplesubcolumn (e.g.`s.v`) from anArrow/ArrowStreamfile whose column is a nullable struct returning column defaults instead of the actual data whenallow_experimental_nullable_tuple_typeis enabled. Also fixORCreads resolving a column or struct field name to the first case-folded match underinput_format_orc_case_insensitive_column_matching, which returned another field's data when two names differ only by case.Description
Since #101272 the Arrow reader hands a nullable struct to
NestedColumnExtractHelperasNullable(Tuple(...)). The helper reached a subcolumn by flattening the parent column, andNested::flattendoes not descend intoNullable(Tuple), so a flattened read such as`s.v`silently returned type defaults.The helper is now a name resolver in front of the type system: the requested name is cut at the first dot, the head names a block column, and the tail is resolved as a subcolumn of its type, so a flattened read yields whatever
SELECT <head>.<tail>yields for that column. The flatten step, the nested-table cache, the in-path unwrap and the reader-side reshape inArrowIPCBlockInputFormatare gone, and each root's subcolumns are listed once on first request.Two further defects were found and fixed while addressing review comments on that resolver:
size0onArray(Tuple(...)),NullagainstNullable'snull) now resolves the way the direct spelling does;input_format_arrow_case_insensitive_column_matchingor its ORC counterpart, a subcolumn was reachable only through a lower-cased key, so a sibling differing by case shadowed it and the read returned the parent's null map instead of the declared element. The readers now pass the requested spelling through, asStorageHive::readalready did, and an exact subcolumn name outranks a case-folded match.Also fixed here, on review request: ORC resolved a name to the first case-folded field, so with
input_format_orc_case_insensitive_column_matchingtwo names differing only by case were both answered by whichever field the file listed first, in a struct and at top level alike. A flattened read returned the sibling's data and a whole-column read also lost the row's NULL. Resolution now prefers the exact spelling and folds only when nothing matches exactly.Readers affected:
ArrowIPCBlockInputFormat(Arrow, ArrowStream),NativeORCBlockInputFormat(ORC),ArrowColumnToCHColumn(ArrowFlight, DeltaLake) andStorageHive.Related: #101272
Related: #109185
Workflow [PR]
Sync PR [sync-upstream/pr/109741]
Version info
26.9.1.1100(included in26.9and later)