Skip to content

Fix flaky test 04146_iceberg_orc_row_policy_prewhere on release branches - #107970

Merged
alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:groeneai/fix-04146-iceberg-prewhere-pin-native-reader-v3
Jul 14, 2026
Merged

alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:groeneai/fix-04146-iceberg-prewhere-pin-native-reader-v3

Conversation

@groeneai

@groeneai groeneai commented Jun 19, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #101206

Changelog category (leave one):

  • CI Fix or Improvement (changelog entry is not required)

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

...

Description

04146_iceberg_orc_row_policy_prewhere fails deterministically (~1 in 6 runs)
on the 26.3 and 26.4 release branches, breaking ReleaseBranchCI and every
backport PR's stateless suite. It is clean on master.

Root cause: StorageObjectStorage caches supportsPrewhere() at
table-construction time. For format Parquet the prewhere-support checker
returns the value of input_format_parquet_use_native_reader_v3. The test
creates an Iceberg table with format Parquet and uses PREWHERE, but the
CREATE TABLE block did not pin that setting. A randomized session with
input_format_parquet_use_native_reader_v3 = 0 therefore baked
supports_prewhere = false into the storage object, and the later
SELECT ... PREWHERE failed at analysis time with ILLEGAL_PREWHERE (Code
182) — even though those SELECTs pin = 1, which is too late because the
storage was already constructed.

On master input_format_parquet_use_native_reader_v3 is obsolete and was
removed from clickhouse-test randomization (commit 80f3bb8, "Remove old
Parquet writer and reader implementations"), so the failing value never
occurs there. On 26.3/26.4 the setting is still live and still randomized,
so the table is sometimes built with the old reader and the test fails.

Fix: pin input_format_parquet_use_native_reader_v3 = 1 in the CREATE TABLE
block, matching the sibling test
04147_iceberg_orc_schema_evolution_row_policy. This is a no-op on master
(the setting is already effectively always 1 there).

Verification (debug build, branch base backport/26.4/106349, commit
a477775):

  • Without the fix, forcing input_format_parquet_use_native_reader_v3=0 via
    the runner: 206 FAIL / 17 OK (ILLEGAL_PREWHERE).
  • With the fix, randomization on, clickhouse-test --test-runs 40: 40/40 OK.
  • Direct repro: CREATE under session v3=0 throws ILLEGAL_PREWHERE; with the
    pin the three queries return the reference values 139 / 144 / 11120.

Report:
https://s3.amazonaws.com/clickhouse-test-reports/json.html?REF=26.4&sha=d4d44a390d59339d45f76829011eedc123ddcf5b&name_0=ReleaseBranchCI

Version info

  • Merged into: 26.7.1.960 (included in 26.7 and later)
  • Backported to: 26.6.2.70, 26.5.6.42, 26.4.5.130, 26.3.17.47

@groeneai

Copy link
Copy Markdown
Collaborator Author

Pre-PR validation gate

# Question Answer
a Deterministic repro? Yes. CREATE TABLE ... ENGINE=IcebergLocal(...,'Parquet') under a session with input_format_parquet_use_native_reader_v3=0, then SELECT count() FROM t PREWHERE c0 > 10 throws Code 182 ILLEGAL_PREWHERE every time. Via the runner with --client-option input_format_parquet_use_native_reader_v3=0: 206 FAIL / 17 OK.
b Root cause explained? StorageObjectStorage caches supportsPrewhere() at table-construction time; for format Parquet the checker returns input_format_parquet_use_native_reader_v3. The CREATE TABLE block did not pin it, so a session with =0 baked supports_prewhere=false into the storage object, and the later SELECT ... PREWHERE failed at analysis time (CollectTableExpressionData.cpp storage->supportsPrewhere() check) regardless of the =1 pinned on the SELECTs (too late). On master the setting is obsolete and removed from randomization, so =0 never occurs; on 26.3/26.4 it is still live and randomized.
c Fix matches root cause? Yes. Pin input_format_parquet_use_native_reader_v3 = 1 in the CREATE TABLE block, so supports_prewhere is always computed as true at construction. This targets the exact mechanism, not a symptom.
d Test intent preserved / new tests added? Preserved. The test still exercises Iceberg ORC PREWHERE with a row policy and the transform-ordering / column-propagation behavior it was written for. The pin only fixes which reader the storage is constructed with; it does not relax any assertion. The reference output (139 / 144 / 11120) is unchanged.
e Both directions demonstrated? Yes. Without fix (session v3=0): 206 FAIL / 17 OK, ILLEGAL_PREWHERE. With fix (randomization on, --test-runs 40): 40/40 OK. Direct repro returns 139 / 144 / 11120 with the pin.
f Fix is general, not a narrow patch? Yes. Swept all stateless tests that create an Iceberg Parquet-format storage and use PREWHERE: only 04146 and 04147 match. 04147 already pins the setting at CREATE (this fix makes 04146 match it). The ORC-format sibling 04071_iceberg_orc_prewhere_crash is unaffected (engine format is 'ORC', not 'Parquet') and shows 0 failures on release branches. No other test needs the pin.

Session id: cron:clickhouse-worker-slot-2:20260619-120900

@groeneai

Copy link
Copy Markdown
Collaborator Author

cc @divanik — could you review this test-only fix? 04146_iceberg_orc_row_policy_prewhere fails ~1/6 runs on the 26.3/26.4 release branches because the Iceberg Parquet-format table is created without pinning input_format_parquet_use_native_reader_v3; StorageObjectStorage caches supportsPrewhere() at CREATE time, so a randomized =0 session bakes supports_prewhere=false and the later PREWHERE throws ILLEGAL_PREWHERE. Pinning it at CREATE matches sibling test 04147. No-op on master.

@nikitamikhaylov nikitamikhaylov added the can be tested Allows running workflows for external contributors label Jun 19, 2026
@clickhouse-gh

clickhouse-gh Bot commented Jun 19, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [4aef3f8]

Summary: ✅


AI Review

Summary

This PR adds SET input_format_parquet_use_native_reader_v3 = 1 to the CREATE TABLE block in 04146_iceberg_orc_row_policy_prewhere.sh so the Iceberg Parquet table is constructed with PREWHERE enabled on the release branches where that setting still affects supportsPrewhere. I reviewed the diff, the current StorageObjectStorage / CollectTableExpressionData path, the sibling 04147 test, and the prior PR discussion, and I did not find any new issues in the current change.

Final Verdict

Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Jun 19, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finished on 46520703f777. One unrelated failure, not caused by this PR:

No PR-caused failures.

StorageObjectStorage caches supportsPrewhere() at table-construction time
from input_format_parquet_use_native_reader_v3 (Parquet's prewhere-support
checker returns that setting's value). The test creates an Iceberg table with
format Parquet and relies on PREWHERE, but the CREATE TABLE block did not pin
the setting, so a randomized session with native_reader_v3=0 baked
supports_prewhere=false into the storage object. Subsequent SELECT ... PREWHERE
then failed at analysis time with ILLEGAL_PREWHERE, even though the SELECTs
pinned native_reader_v3=1 (too late, the storage was already constructed).

On master the setting is obsolete and removed from clickhouse-test
randomization, so the test never sees native_reader_v3=0 there; on the 26.3 and
26.4 release branches the setting is still live and still randomized, so the
test failed deterministically about 1 in 6 runs in ReleaseBranchCI and every
backport PR. Pin native_reader_v3=1 in the CREATE TABLE block, matching the
sibling test 04147_iceberg_orc_schema_evolution_row_policy. No-op on master.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@groeneai
groeneai force-pushed the groeneai/fix-04146-iceberg-prewhere-pin-native-reader-v3 branch from 4652070 to 4aef3f8 Compare July 3, 2026 14:25
@groeneai

groeneai commented Jul 3, 2026

Copy link
Copy Markdown
Collaborator Author

Rebased on master and re-triggered CI (head 4aef3f83c4df8).

@alexey-milovidov asked about this exact flaky test on #109279 today; this is the in-progress fix. It is a test-only +3-line change (pin input_format_parquet_use_native_reader_v3 = 1 at CREATE, so the storage caches supportsPrewhere = true regardless of the release-branch randomization that flips it to 0). No-op on master (setting obsolete), carries to 26.3/26.4 via the normal backport flow.

cc @scanhex12 — could you review?

@clickhouse-gh

clickhouse-gh Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 85.90% 85.91% +0.01%
Functions 91.52% 91.52% +0.00%
Branches 78.36% 78.39% +0.03%

Changed lines: No C/C++ source files changed — skipping uncovered code analysis.

Newly covered by added/modified tests: 67 line(s), 3 function(s) across 31 file(s) · Details

Top files
  • src/Functions/FunctionsNumericIndexedVector.h: 5 line(s)
  • src/Storages/System/StorageSystemRemoteDataPaths.cpp: 5 line(s)
  • src/Functions/FunctionsExternalDictionaries.h: 4 line(s)
  • src/Functions/h3HexAreaM2.cpp: 4 line(s)
  • src/Common/threadPoolCallbackRunner.h: 3 line(s)

Full report

@groeneai

groeneai commented Jul 3, 2026

Copy link
Copy Markdown
Collaborator Author

CI finish ledger — 4aef3f83c4df8c1e6a1f3e0f7e0e4f8b (revived head)

Test-only PR (+3 lines in 04146_iceberg_orc_row_policy_prewhere.sh, pinning input_format_parquet_use_native_reader_v3 = 1 at CREATE TABLE). CI fully finished, Mergeable Check passed. The only red check is the private ClickHouse Inc sync.

Check / test Reason Owner / fixing PR
CH Inc sync — CH Inc sync (private, not actionable)

Session id: cron:our-pr-ci-monitor:20260703-190000

@alexey-milovidov alexey-milovidov left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok... just for release branches.

@alexey-milovidov alexey-milovidov self-assigned this Jul 14, 2026
@alexey-milovidov alexey-milovidov added the pr-must-backport Pull request should be backported intentionally. Use this label with great care! label Jul 14, 2026
@alexey-milovidov
alexey-milovidov merged commit 02e029d into ClickHouse:master Jul 14, 2026
173 of 174 checks passed
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR label Jul 14, 2026
@robot-clickhouse robot-clickhouse added the pr-synced-to-cloud The PR is synced to the cloud repo label Jul 15, 2026
clickhouse-gh Bot pushed a commit that referenced this pull request Jul 15, 2026
clickhouse-gh Bot added a commit that referenced this pull request Jul 15, 2026
Backport #107970 to 26.6: Fix flaky test 04146_iceberg_orc_row_policy_prewhere on release branches
robot-ch-test-poll2 added a commit that referenced this pull request Jul 15, 2026
Cherry pick #107970 to 26.3: Fix flaky test 04146_iceberg_orc_row_policy_prewhere on release branches
robot-clickhouse added a commit that referenced this pull request Jul 15, 2026
@robot-ch-test-poll robot-ch-test-poll added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label Jul 15, 2026
alexey-milovidov added a commit that referenced this pull request Jul 15, 2026
Backport #107970 to 26.4: Fix flaky test 04146_iceberg_orc_row_policy_prewhere on release branches
alexey-milovidov added a commit that referenced this pull request Jul 15, 2026
Backport #107970 to 26.5: Fix flaky test 04146_iceberg_orc_row_policy_prewhere on release branches
alexey-milovidov added a commit that referenced this pull request Jul 16, 2026
Backport #107970 to 26.3: Fix flaky test 04146_iceberg_orc_row_policy_prewhere on release branches
kewin-robetti pushed a commit to viasoftkorp/ClickHouse that referenced this pull request Aug 24, 2026
kewin-robetti pushed a commit to viasoftkorp/ClickHouse that referenced this pull request Aug 24, 2026
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
…-iceberg-prewhere-pin-native-reader-v3

Fix flaky test 04146_iceberg_orc_row_policy_prewhere on release branches
Blargian pushed a commit to Blargian/ClickHouse that referenced this pull request Nov 3, 2026
The count-only query and the input_format_defaults_for_omitted_fields = 0
query added by ClickHouse#116666 test the native Parquet reader. The test was
backported to 26.3 unchanged (ClickHouse#128501), and the 26.3 runner randomizes
input_format_parquet_use_native_reader_v3 to 0 in about 1 of 6 runs. The
legacy ParquetBlockInputFormat resolves every header column in
initializeIfNeeded() before its count-only branch, so with
input_format_parquet_allow_missing_columns = 0 the missing column `d`
throws THERE_IS_NO_COLUMN (seen on the 26.3 backport ClickHouse#128753).

Pin the reader in the SETTINGS of those two queries. A query-level pin
overrides the runner's injected value for that query only, so the older
reader-agnostic Parquet query keeps exercising the legacy reader on 26.3.
On master the setting is obsolete and accepted without effect; the change
matters once backported to 26.3 (same shape as ClickHouse#107970).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore pr-ci pr-must-backport Pull request should be backported intentionally. Use this label with great care! pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants