Repository navigation
Fix crash when reading Iceberg tables with ORC files and PREWHERE enabled - #101206
Conversation
…bled When an Iceberg table has data files in mixed formats (e.g. Parquet and ORC), PREWHERE support is determined at the table level based on the configuration format (typically Parquet). If the actual file being read is in ORC format, which doesn't support PREWHERE, the FormatFactory throws a LOGICAL_ERROR: "PREWHERE passed to format that doesn't support it". Fix by checking the actual per-file format in createReader() before passing format_filter_info to the FormatFactory. If the file's format doesn't support PREWHERE, strip prewhere_info and row_level_filter while preserving filter_actions_dag for general row filtering. Closes ClickHouse#96829 Co-Authored-By: Claude Opus 4.6 <[email protected]>
Pre-PR Validation Gatea) Deterministic repro? Yes. Create an Iceberg table with ORC data files, then read via b) Root cause explained? c) Fix matches root cause? Yes — checks per-file format against d) New test added? Yes — e) Both directions demonstrated? Yes — without fix: Session: |
|
cc @scanhex12 @kssenii — could you review this fix for the Iceberg ORC+PREWHERE crash (#96829)? The issue is in The fix checks each file's actual format via |
|
Workflow [PR], commit [35291c7] Summary: ✅
AI ReviewSummaryThis PR fixes mixed-format Iceberg reads where table-level Final VerdictStatus: ✅ Approve |
…urity Per @alesapin's review: moved the per-file format PREWHERE check directly into the lambda that constructs filter_info, eliminating the separate block that re-initialized the variable. Per bot review: when stripping PREWHERE-related fields for formats that don't support it, the row_level_filter is now preserved and applied as a fallback FilterTransform in the pipeline. FormatFactory::getInputImpl checks both prewhere_info and row_level_filter against format support (line 444-449), so both must be stripped from FormatFilterInfo. But the query planner only puts row policies into row_level_filter when storage->supportsPrewhere() is true (PlannerJoinTree.cpp:1012), with no fallback FilterStep — so without this explicit FilterTransform, row policies would be silently skipped for non-PREWHERE files in mixed-format Iceberg tables. Co-Authored-By: Claude Opus 4.6 <[email protected]>
|
Addressed both review points in the new commit: 1. @alesapin — code style (lambda refactoring): 2. Bot review — row_level_filter security concern: if (format_filter_info
&& (format_filter_info->prewhere_info || format_filter_info->row_level_filter)
&& (!creators.prewhere_support_checker || ...))
throw Exception(LOGICAL_ERROR, "... passed to format that doesn't support it");Both The correct fix is to strip both from Session: |
Refactored the lambda to compute format_supports_prewhere once and use it directly in each branch, eliminating the create-then-override pattern. Each branch now directly produces the final FormatFilterInfo. Co-Authored-By: Claude Opus 4.6 <[email protected]>
When reading mixed-format Iceberg tables (Parquet + ORC), our fix strips prewhere_info from FormatFilterInfo for ORC files to prevent a crash. But the stripped PREWHERE filter was not being applied at all, causing wrong results when explicit PREWHERE syntax was used. Fix: save the stripped prewhere_info and apply it as a regular FilterTransform in the pipeline after the format reader, similar to how we handle stripped row_level_filter. Also fix the regression test to use explicit PREWHERE syntax (the query plan optimizer cannot push PREWHERE for ObjectStorage tables because getColumnSizes() returns empty). Pin input_format_parquet_use_native_reader_v3=1 since PREWHERE support requires the native Parquet reader v3. Co-Authored-By: Claude Opus 4.6 <[email protected]>
|
New commit addresses two issues found during testing: 1. PREWHERE fallback for ORC files (correctness fix) 2. Bugfix validation fix (test reliability) Fix: use explicit Verified: 20/20 passes with full randomization. Session: cron:clickhouse-ci-task-worker:20260331-101500 |
|
@alesapin — gentle ping for re-review when you have a moment. The latest commit (v4, CI is green (136/160 success, 7 failures all pre-existing trunk bugs, 17 skipped). The bugfix validation test also passes now (explicit |
|
The Stress test (arm_msan) failure is fixed by #101239, which should be merged first. After it is merged, please update the branch to include the fix. |
Includes SimSIMD SVE MSan fix (PR ClickHouse#101239) and all recent master changes as requested by @alexey-milovidov.
|
Done — merged latest master (includes the SimSIMD SVE MSan fix from #101239) into the branch. CI should re-run cleanly now. |
|
The test |
The test uses explicit PREWHERE on Iceberg tables with mixed ORC/Parquet data files. This fails in two coverage-build CI configurations: 1. amd_llvm_coverage, old analyzer: NOT_FOUND_COLUMN_IN_BLOCK because the old analyzer evaluates PREWHERE through a different code path that doesn't go through FormatFilterInfo (where our per-file format check strips PREWHERE for ORC files). 2. amd_llvm_coverage, ParallelReplicas: ILLEGAL_PREWHERE because the parallel replicas coordinator validates PREWHERE support before our per-file handling runs, and rejects it for IcebergLocal storage. Fix: - Add no-parallel-replicas tag to skip in ParallelReplicas configs - Add enable_analyzer=1 to query SETTINGS to force the new analyzer pipeline where our FormatFilterInfo-based fix operates correctly Co-Authored-By: Claude Opus 4.6 <[email protected]>
|
@alesapin — fixed, pushed 15e99c72d2f. Root cause: The test uses explicit
These two configurations only exist in coverage builds (other build types don't have Fix:
|
|
The |
|
Found via ClickGap automated review. Please close or comment if this is incorrect or needs adjustment. TL;DRFix crash when reading Iceberg tables with ORC files and PREWHERE enabled ClickGap verified: reproduced it with the script below on ReproductionBisect
Affects
Suggested next stepThe fix has landed on master; the affected release branches above still need the backport. Component: ClickGap · Finding: |
Cherry pick #101206 to 26.3: Fix crash when reading Iceberg tables with ORC files and PREWHERE enabled
…ORC files and PREWHERE enabled
Cherry pick #101206 to 26.4: Fix crash when reading Iceberg tables with ORC files and PREWHERE enabled
…ORC files and PREWHERE enabled
Cherry pick #101206 to 26.5: Fix crash when reading Iceberg tables with ORC files and PREWHERE enabled
…ORC files and PREWHERE enabled
Backport #101206 to 26.5: Fix crash when reading Iceberg tables with ORC files and PREWHERE enabled
Backport #101206 to 26.4: Fix crash when reading Iceberg tables with ORC files and PREWHERE enabled
Backport #101206 to 26.3: Fix crash when reading Iceberg tables with ORC files and PREWHERE enabled
…bles with ORC files and PREWHERE enabled
…1206 Backport ClickHouse#101206 to 26.4: Fix crash when reading Iceberg tables with ORC files and PREWHERE enabled
When an Iceberg table has data files in mixed formats (e.g. Parquet and ORC), PREWHERE support is determined at the table level based on the configuration format (typically "Parquet"). If the actual file being read is in ORC format — which doesn't support PREWHERE — the
FormatFactory::getInputImpl()throws:This happens because
StorageObjectStoragesetssupports_prewhere = truebased onconfiguration->format(Parquet), causing the query planner to push PREWHERE conditions intoformat_filter_info. At read time,StorageObjectStorageSource::createReader()discovers the actual file format (ORC) viaobject_info->getFileFormat()but passesformat_filter_infowith PREWHERE info intact to the format reader.The fix checks the actual per-file format in
createReader()againstFormatFactory::checkIfFormatSupportsPrewhere()before passingfilter_infoto the format reader. If the format doesn't support PREWHERE,prewhere_infoandrow_level_filterare stripped while preservingfilter_actions_dagfor general row-level filtering.This was already noted as a known problem in the code comments at
StorageObjectStorage.cpp:256-257:Closes #96829
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fix crash (
LOGICAL_ERROR: 'PREWHERE passed to format that doesn't support it') when reading Iceberg tables containing ORC data files with PREWHERE optimization enabled.Documentation entry for user-facing changes
Version info
26.6.1.63626.5.3.23,26.4.5.33,26.3.14.26