Repository navigation
Fix filtering and reading a Hive partition column that some paths of a glob do not have - #125024
Conversation
…a glob do not have Hive partition columns of a file-like table are fixed from one sample path, but the `_path`/`_file` pre-filter and the virtual-column reader materialize them for every other path. The pre-filter appended a value only for the keys a path carries, so a path without the key left that column one row short: `checkFunctionArgumentSizes` threw LOGICAL_ERROR when the predicate read the column, `IColumn::filter` threw SIZES_OF_COLUMNS_DOESNT_MATCH when it did not. The reader silently skipped a missing key (and every key when `use_hive_partitioning = 0` at query time), leaving the chunk a column short of its header. Both now take the value of every Hive column from the path through `HivePartitioningUtils::getPartitionValueFromPath`, which throws the INCORRECT_DATA error the schema Hive reader already raised (message unchanged, moved into the helper). The pre-filter materializes only the columns its split expression reads, so a filter on `_file` never needs a Hive value, and the path is parsed only when a Hive column is needed. Found by the AST fuzzer (STID 2959-3490): `url` derives Hive columns from the whole sample URI, query string included, while it filters on the URI path, so the fuzzer's `x(?i)/.../key=9/data.orc` reached the pre-filter with a path that has no `key`. Co-Authored-By: Claude Opus 5.5 <[email protected]>
State the required-columns filter comment as a domain invariant instead of design narration. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Internal second-model review: adjudication log (click to expand)Pre-publication review by an independent model (engine: codex; 2 findings; 1 full pass, no fix round needed).
Severity: ❌ blocker / Session id: cron:clickhouse-review-slot-9:20261010-004900 |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-4:20261009-222400 |
|
Workflow [PR], commit [4896111] Summary: ❌
AI ReviewSummaryThis PR fixes the two broken Hive-partition paths consistently: the listing-time Final Verdict
|
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units20 translation units recompiled, 158 s compile time in total, 20 of them have a recent master baseline. |
With parallel replicas the `s3` read becomes `s3Cluster`, and each replica
runs its part of the query in its default database. There `currentDatabase()`
in `filename` names another prefix, the replica's glob lists nothing, so `a`
is not a column and the query fails with UNKNOWN_IDENTIFIER instead of
INCORRECT_DATA. `{CLICKHOUSE_DATABASE:String}` is substituted on the
initiator, so all replicas list the same files.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
The path filter block fills `_path` and `_file` with the object path and the file name. A Hive column with one of these names, listed in the structure so that it shadows the virtual column, landed in the same block, so the filter compared the path or the file name with its value and dropped matching files: the query returned no rows (on master it is a LOGICAL_ERROR). Such a column is now left out of the path filter and is filtered after it is read from the path. Co-Authored-By: Claude Opus 5.5 <[email protected]>
CI finish ledger - 4896111Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
Session id: cron:our-pr-ci-monitor:20261010-120003 |
9de8a78
|
@groeneai @alexey-milovidov — ClickGap found the following in this PR:
Close anything that's wrong or already addressed. |
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fixed
SIZES_OF_COLUMNS_DOESNT_MATCHandLOGICAL_ERRORwhen afile,url,s3,azureBlobStorageorhdfsglob matches paths that do not all contain a Hive partition column: a filter on_pathor_filenow works, and filtering on or reading such a column fails withINCORRECT_DATAnaming the path. The Hive partition columns of a table created withuse_hive_partitioning = 1are now also read when the query runs withuse_hive_partitioning = 0.Description
On 26.8.18.2,
SELECT x FROM file('d/*/a.csv', CSV, 'x UInt8') WHERE _file = 'a.csv'overd/key=1/a.csvandd/b/a.csvfails withSIZES_OF_COLUMNS_DOESNT_MATCH, and... WHERE key = 1throwsLOGICAL_ERROR(Expected the argument №1 ('key' of type Int64) to have 2 rows, but it has 1), an abort in debug builds. Found byAST fuzzer (amd_debug, targeted, old_compatibility), STID 2959-3490 (the sameLOGICAL_ERRORfromVirtualColumnUtils::getFilterByPathAndFileIndexes): https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=123788&sha=88a61f2ec658a76a0060fdac4f9ce522fa75f1c2&name_0=PR&name_1=AST%20fuzzer%20%28amd_debug%2C%20targeted%2C%20old_compatibility%29Hive partition columns are taken from one sample path. The
_path/_filepre-filter then appended a value only for the keys a path has, so a path withoutkeyleft thekeycolumn one row short. The virtual-column reader likewise skipped a missing key (and every key whenuse_hive_partitioning = 0at query time), so the chunk had fewer columns than its header.Now both take each Hive value from the path through one helper that throws the existing
INCORRECT_DATAerror the schema Hive reader already used, and the pre-filter materializes only the columns its expression reads. Paths that carry every key behave exactly as before. A Hive column named_pathor_file(listed in the structure) is no longer used by the pre-filter, which put the path or the file name there (LOGICAL_ERRORon master).Out of scope:
urltakes Hive columns from the whole sample URI, query string included, while it reads them from the URI path. That is how the fuzzer query reached the filter, and it now fails withINCORRECT_DATA.Validation: the new test fails on master on every assertion and passes with the fix (100/100 randomized runs); related stateless and Hive integration tests show no difference from master.
Workflow [PR]
Sync PR [sync-upstream/pr/125024]
Version info
26.11.1.387-master(included in26.11and later)