Repository navigation
Cast an ORC list, map or struct requested as another type instead of reading default values - #130171
Conversation
…reading default values `updateIncludeTypeIds` chooses the ORC columns to read by walking the requested type and the file type together. For a `list`, `map` or `struct` node whose requested type is of another kind it selected nothing, so the column was filled as a missing one (default values, or `THERE_IS_NO_COLUMN` with `input_format_orc_allow_missing_columns = 0`) and the cast to the requested type documented in ORC.mdx never ran. A map whose value was left unselected was read with a single child, and `readColumnFromORCColumn` indexed `getSubtype(1)` out of bounds (`std::out_of_range`, an abort in debug builds, a SIGSEGV on the releases). Such a node is now selected in full. `readColumnFromORCColumn` already reads a node whose hint is of another kind with its file type, and `castColumnToRequestedType` then converts it or throws the cast error, as the Arrow reader does. Same-kind requests, named-tuple field pruning, unions and genuinely missing columns are unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A map selected because its requested type is of another kind is read without a `Map` hint, so a dictionary-encoded string key arrives as `LowCardinality(Nullable(String))`, which `DataTypeMap` rejects (`BAD_ARGUMENTS`). Cast such a key to the same type without nullability, the key type schema inference gives the file, before the cast to the requested type runs. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Internal second-model review (2 rounds): 1 fixed, 4 noted
|
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-self-slot-57:20261108-144100 |
|
Workflow [PR], commit [aaf1887] Summary: ✅
AI ReviewSummaryThis PR reads ORC Missing context / blind spots
Final VerdictStatus: ✅ Approve. No code changes requested or new inline findings. CI validation remains outstanding. |
|
cc @alexey-milovidov @vitlibar, could you review this and add the |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units7 translation units recompiled, 14 s compile time in total, 7 of them have a recent master baseline. |
2aef13f
Backport #130171 to 26.9: Cast an ORC list, map or struct requested as another type instead of reading default values
Backport #130171 to 26.10: Cast an ORC list, map or struct requested as another type instead of reading default values
Backport #130171 to 26.8: Cast an ORC list, map or struct requested as another type instead of reading default values
Backport #130171 to 26.3: Cast an ORC list, map or struct requested as another type instead of reading default values
…s another type instead of reading default values
…s another type instead of reading default values
…s another type instead of reading default values
…as another type instead of reading default values
…ceberg-variant
Conflicts in `src/CMakeLists.txt` and `NativeORCBlockInputFormat.{cpp,h}`:
- Master builds `VariantEncoding.cpp` without Parquet for Avro too, so the
condition is now `elseif (USE_AVRO OR USE_ORC)`.
- `ORCColumnToCHColumn` gained the data lake arguments on master; it now
takes `FormatSettings` in place of the five settings it took from it,
keeping the new arguments.
- `decodeVariantColumn` takes `Parquet::VariantSettings` on master.
- The `updateIncludeTypeIds` hunk that selected a struct whole for a
`Dynamic` or `JSON` request is dropped: since ClickHouse#130171 every list, map or
struct requested as another kind is selected whole.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
… throwing Since ClickHouse#130171 an ORC struct requested as another kind is read whole and cast to the requested type, so `file('t.orc', ORC, 'v JSON')` over `struct<a:int,b:string>` returns `{"a":1,"b":"x"}` on master, as Parquet does. The variant reader threw `TYPE_MISMATCH` for every struct that is not exactly two binary fields `metadata` and `value`, which after the master merge would reject such input. Only a variant-shaped struct is decoded now; any other struct takes the cast path. The test checks the cast for a plain struct, a struct with other field names and a struct of `string` fields. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Related: #130020
Related: #130102
Related: #130116
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fixed reading an ORC
list,maporstructcolumn requested as a type of another kind, for example aTupleover a map, or a data lake table whose schema disagrees with an ORC data file: the column was silently returned as default values, and aMapwhose value had another kind crashed the server. Now the value is cast to the requested type, as the ORC format documentation describes, or the query fails with the cast error.Description
On 26.10.2.103,
SELECT * FROM file('m.orc', ORC, 'id Int64, payload Tuple(value Nullable(String))')over an ORC map columnpayloadreturns2 (NULL),payload Stringreturns2 '', andm Map(String, String)over amap<string, struct<...>>column is a SIGSEGV (an abort on master debug builds).updateIncludeTypeIdswalks the requested type and the file type together to choose the ORC columns to read. For alist,maporstructnode whose requested type is of another kind, it selected nothing. The column was then filled as a missing column (THERE_IS_NO_COLUMNwithinput_format_orc_allow_missing_columns = 0), so the cast to the requested type was never attempted; a map whose value was unselected was read with a single child and indexed out of bounds.Now such a node is selected in full: it is read with its file type and
castColumnToRequestedTypeconverts it (Map->String,Map->Array(Tuple(...)), a map value) or throws the cast error naming the column and both types, like the Arrow reader. A map read without aMaprequest now gets a valid key type (a dictionary-encoded string key wasLowCardinality(Nullable(String)), whichMaprejects). Same-kind requests, named-tuple field pruning and genuinely missing columns are unchanged.Not covered: a map value
Tuplethat shares no element with the file's struct still reads out of bounds (same kind, different trigger and fix site).Validation: the new test fails on master (defaults, two aborts) and passes with the fix, 50/50 with random settings; the 133 stateless tests that read ORC show no new failures.
🤖 Generated with Claude Code
Workflow [PR]
Sync PR [sync-upstream/pr/130171]
Version info
26.11.1.1701-master(included in26.11and later)