Repository navigation
Use the table's format settings in the Hive partition filter of stored file-like tables - #131571
Conversation
…e-like tables A stored `File`, `URL`, `S3`, `AzureBlobStorage` or `HDFS` table reads a Hive partition column with its own format settings (global settings plus its `SETTINGS` clause), but the `_path` / `_file` / Hive pre-filter converted the partition value with the query's settings: every iterator passed `std::nullopt` to `VirtualColumnUtils::getFilterByPathAndFileIndexes`, whose `format_settings` parameter (added in bb7556a) was only ever threaded into the reader. When the two differ, the filter computes a different value than the column holds, so `WHERE` on the column skips files whose rows match it (e.g. `bool_true_representation = 'false'`) or fails with `CANNOT_PARSE_BOOL` on a value only the table's settings can parse. Pass the reader's `std::optional<FormatSettings>` into the iterators that run the pre-filter: `StorageFileSource::FilesIterator` (immediate and deferred), `StorageURLSource::DisclosedGlobIterator`, and for object storage `createFileIterator` (brace expansion and explicit keys, immediate and the deferred `KeysIterator`) and `GlobIterator`, from `ReadFromObjectStorageStep` and from the initiator of a parallel-replicas read (`StorageObjectStorageCluster::getTaskIteratorExtension`). The new parameters default to `std::nullopt`, so table functions, `fileCluster` and `urlCluster`, which have no table format settings and already agree, are unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The `file, GLOBAL IN` query takes the same immediate filter in the `FilesIterator` constructor as the plain `file` query: `ReadFromFile` builds its `GLOBAL IN` sets in `applyFilters`, before plan optimization moves the subquery plans away, so the deferred filter in `FilesIterator::next` is not reached from a stored `File` table. 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) and my own review (2 nits).
Severity: ❌ blocker / Session id: cron:clickhouse-review-slot-9:20261114-083001 |
|
cc @nikitamikhaylov, could you review this? The Hive partition pre-filter of stored File, URL and object storage tables converted partition values with the query's format settings while the reader used the table's, so WHERE on a partition column skipped matching files or threw CANNOT_PARSE_BOOL; the iterators now pass the reader's format settings to getFilterByPathAndFileIndexes. |
|
Workflow [PR], commit [326c3e7] Summary: ✅
AI ReviewSummaryThe Hive partition path filters now use the reader's Final VerdictStatus: ✅ Approve |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units58 translation units recompiled, 762 s compile time in total, 58 of them have a recent master baseline. |
|
🕵️ @groeneai The description says |
|
It can't be reached: the
I reworded that sentence of the description. The probe found a different bug: a direct |
|
The fix for the direct |
Related: #131256
Related: #131256 (comment)
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fix a
WHEREon a Hive partition column of aFile,URL,S3,AzureBlobStorageorHDFStable skipping files whose rows match it, or failing withCANNOT_PARSE_BOOL, when the table's format settings (for examplebool_true_representationin itsSETTINGS) change how the column's values are parsed.Description
On 26.10.2.103 (and 26.8.34.13), a table
ENGINE = File(JSONEachRow, 'd/b=si/data.jsonl') SETTINGS bool_true_representation = 'si'reads its row withb = true, butSELECT * FROM t WHERE bfails withCANNOT_PARSE_BOOL. Withbool_true_representation = 'false', bool_false_representation = 'true'overd/b=false/data.jsonl,SELECT count() FROM t WHERE breturns 0 instead of 1.A stored table reads a Hive partition column with its own format settings, but every iterator that runs the
_path/_file/ partition-column pre-filter passedstd::nullopttoVirtualColumnUtils::getFilterByPathAndFileIndexes, so the filter converted the value with the query's settings. That function already takes the settings; only the readers passed them.The change passes the reader's
std::optional<FormatSettings>toStorageFileSource::FilesIterator,StorageURLSource::DisclosedGlobIteratorand, for object storage, tocreateFileIterator,GlobIteratorand the deferredKeysIterator, fromReadFromObjectStorageStepand from the initiator of a parallel-replicas read. The new parameters default tostd::nullopt, so table functions,fileClusterandurlCluster, which have no table settings, are unchanged. Data lakes do not filter on Hive columns;S3Queuebuilds its path filter without them. Most of the diff replaces/*format_settings=*/std::nulloptor extends a signature; it splits by storage family if preferred.The test has one case per changed call site: File, URL, S3 key, brace expansion, glob, the deferred
GLOBAL INfilters and parallel replicas. The deferred filter inFilesIterator::nextgets the same settings, but I found no query that reaches it for a storedFiletable (its sets are built inapplyFilters), so the test has no case for it. The test fails on master and passes with the fix (50/50 randomized); 25 related Hive and path-filter tests pass.Workflow [PR]
Sync PR [sync-upstream/pr/131571]
Version info
26.11.1.2468-master(included in26.11and later)