Repository navigation
Fix a filter on a Hive partition column pruning by the data file's column of the same name (revert of revert with a fix) - #124991
Conversation
Since `getFormatFilter` keeps the conjuncts on virtual and Hive partition columns out of the filter pushed into the format, the TopK key of `ReadFromFile::makeTopKQueryConditionCacheKey` was either not made at all (a filter only on `_file`, which broke `05243_query_condition_cache_top_k_parquet`) or made from the reduced filter, so queries that differ only in such a conjunct shared entries and lost rows of the result. The rows these conjuncts drop after the format decide the TopK threshold too, so the key must cover the whole filter of the step. Closes: #124975 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Workflow [PR], commit [975ae45] Summary: ✅
AI ReviewSummaryThis PR restores the Hive/virtual-column split for file-like format pushdown and fixes the Findings
Final VerdictNot ready to merge: the Iceberg row-lineage exception needs to be narrowed to the formats that really materialize those columns inside the reader. |
…ts on columns added after the format `indexHint` keeps its arguments in its own DAG, so `getFormatFilter` did not see that `indexHint(key = 9)` or `indexHint(_file = ...)` read a Hive partition or virtual column, and kept it in the filter pushed into the format, which could prune row groups by the data file's column of the same name. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…column` for the `indexHint` cases Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
🕵 The only CI failure, |
| /// Iceberg reads the row lineage columns from the data file. | ||
| auto format_filter_info = std::make_shared<FormatFilterInfo>( | ||
| info.formatReadsHivePartitionColumns() ? nullptr : filter_actions_dag, | ||
| info.getFormatFilter(filter_actions_dag, /*keep_row_lineage_columns=*/ configuration->isIcebergConfiguration()), |
There was a problem hiding this comment.
The keep_row_lineage_columns gate is too broad here. This now keeps _row_id / _last_updated_sequence_number in the pushed-down format filter for every Iceberg* table, but StorageObjectStorageSource::getMaterializedRowLineageColumns only treats those columns as format-read when the actual data file format is Parquet (object_info->getFileFormat().value_or(configuration->format) == "parquet").
For Iceberg tables backed by ORC / Avro (or mixed-format tables), those columns are still added after the format, so keeping their conjuncts in getFormatFilter can prune by a physical same-named column or by values the reader never materializes. That reintroduces the same wrong-results bug for row-lineage filters on non-Parquet files. Please gate this on the real file-format capability (or share a helper with getMaterializedRowLineageColumns) instead of isIcebergConfiguration().
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Object file sizes7 object files changed (+17.52 KiB total), 0 added.
719 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only Compile time of recompiled translation units146 translation units recompiled, 1485 s compile time in total, 146 of them have a recent master baseline. Median compile-time ratio to the baselines is ×1.06 (machine-speed difference or a change affecting every TU); per-TU deltas below are relative to that ratio. |
Bring in the Parquet query-condition-cache fix and the replicated query-log test correction. Related: ClickHouse#124991 Related: ClickHouse#124928 Related: ClickHouse#124490
Cherry pick #124991 to 26.8: Fix a filter on a Hive partition column pruning by the data file's column of the same name (revert of revert with a fix)
…ning by the data file's column of the same name (revert of revert with a fix)
…e conflicts The release branch lacks the prerequisites the original change was built on: the TopK query condition cache of `ReadFromFile` (`makeTopKQueryConditionCacheKey`) and `formatReadsHivePartitionColumns` from #123381. So only the fix itself is backported: - `ReadFromFormatInfo::getFormatFilter` drops the conjuncts on Hive partition and virtual columns from the filter passed to the format, and is used by `ReadFromFile`, `ReadFromURL` and `ReadFromObjectStorageStep`. `formatReadsHivePartitionColumns` is not needed: on 26.9 the format header never contains a Hive partition column. - `FormatFilterInfo::hasFilter` also covers the row-level filter and PREWHERE and is used for the row count cache of object storage reads. `FormatFilterInfo::computeConditionHash` and the test `05353_query_condition_cache_top_k_virtual_column_conjunct` only concern the TopK query condition cache, which does not exist on 26.9, so they are dropped. Original pull request: #124991 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Cherry pick #124991 to 26.9: Fix a filter on a Hive partition column pruning by the data file's column of the same name (revert of revert with a fix)
…ning by the data file's column of the same name (revert of revert with a fix)
Backport #124991 to 26.8: Fix a filter on a Hive partition column pruning by the data file's column of the same name (revert of revert with a fix)
Backport #124991 to 26.9: Fix a filter on a Hive partition column pruning by the data file's column of the same name (revert of revert with a fix)
Closes: #124975
Related: #123903
Related: #124977
Related: #123717
This reverts the revert #124977, which brings back #123903, and fixes the problem that broke
05243_query_condition_cache_top_k_parqueton master.#123903 keeps the conjuncts on Hive partition and virtual columns out of the filter pushed into the format.
ReadFromFile::makeTopKQueryConditionCacheKeybuilt the TopK query condition cache key from the format's filter, so:WHERE _file = 'b.parquet') the format got no filter, while the step had one, and no key was made: thefile_b_*lookups of05243_query_condition_cache_top_k_parquetstopped happening;key = 1 OR v > 450), the key was made from the reduced filter, so queries that differ only in that conjunct shared TopK entries and lost rows of the result (TopKFilereads skip result rows: cache key omits Hive/virtual conjuncts #124975).The rows these conjuncts drop after the format decide the TopK threshold too, so the key now covers the whole filter of the step (with the same determinism and PREWHERE checks, moved into
FormatFilterInfo::computeConditionHash). When the format gets the whole filter, the key does not change.The new test
05353_query_condition_cache_top_k_virtual_column_conjunctis the reproducer of #124975.Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fixed a
WHEREcondition or a row policy on a Hive partition column (use_hive_partitioning = 1) returning too few rows when the Parquet data file also has a column with that name and other values: Parquet row-group, page and dictionary pruning used the file's values instead of the path's. The same applied to a virtual column such as_filewhen the data file has a physical column with that name. Affectsfile,url,s3and other object storages.🤖 Generated with Claude Code
Workflow [PR]
Sync PR [sync-upstream/pr/124991]
Version info
26.10.1.2107-master(included in26.10and later)26.9.17.9,26.8.25.15