Skip to content

Explain pretty make default - #105036

Merged
Fgrtue merged 85 commits into
masterfrom
explain-pretty-make-default
Jun 28, 2026
Merged

Fgrtue merged 85 commits into
masterfrom
explain-pretty-make-default

Conversation

@Fgrtue

@Fgrtue Fgrtue commented May 15, 2026 •

Copy link
Copy Markdown
Contributor

Changelog category (leave one):

  • Improvement

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

Make EXPLAIN [PLAN] actions=1, compact=1, pretty=1 the default.

Version info

  • Merged into: 26.7.1.194 (included in 26.7 and later)

@clickhouse-gh

clickhouse-gh Bot commented May 15, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [8f43848]

Summary: ❌

job_name test_name status info comment
Stress test (amd_asan_ubsan) FAIL
Logical error: Can't extract iceberg table state from storage snapshot for table location A (STID: 2606-4a47) FAIL cidb, issue ISSUE EXISTS
Stress test (arm_ubsan) FAIL
Logical error: Unexpected return type from A. Expected B. Got C (STID: 3262-40aa) FAIL cidb IGNORED

AI Review

Summary

This PR makes EXPLAIN [PLAN] default to pretty, compact, action-annotated output via explain_query_plan_default, adds compatibility history, updates docs, and pins existing EXPLAIN output tests to legacy. The runtime/defaulting path and current CI look consistent, but one user-facing docs contract still overstates the JSON plan schema.

Findings

⚠️ Majors

  • [docs/en/sql-reference/statements/explain.md:228] The json = 1 documentation says every node always has Plans, but QueryPlan::explainPlan only attaches Plans when a node has child steps or child plans. Leaf nodes such as ReadFromStorage contain Node Type and Node Id without Plans, so clients following the docs may treat valid output as malformed.
    Suggested fix: describe Plans as present only when the node has child plans or child steps, or say it is optional and omitted for leaves.
Final Verdict

Status: ⚠️ Request changes

Minimum required action: update the JSON Plans wording in docs/en/sql-reference/statements/explain.md.

@clickhouse-gh clickhouse-gh Bot added the pr-improvement Pull request with some product improvements label May 15, 2026
Comment thread src/Core/Settings.cpp Resolved
@rienath rienath self-assigned this May 15, 2026
Fgrtue and others added 2 commits May 15, 2026 15:49
Adds the missing entry to SettingsChangesHistory's 26.5 block so that
`SET compatibility = '25.5'` (or any version older than 26.5) reverts
`query_plan_pretty_default` to its pre-26.5 value `false` via
`applyCompatibilitySetting`.

Without this entry, the test `04219_explain_plan_pretty_default` (test 1
of 5) fails — it asserts that the `compatibility = '25.5'` knob rolls
the new pretty default back. `02995_new_settings_history` was also
failing because it cross-checks that newly declared settings have a
corresponding entry in the history.

CI report: #105036

Co-Authored-By: Claude Opus 4.7 <[email protected]>
A second batch of stateless tests that the previous opt-out commits
missed. All of these inspect EXPLAIN PLAN / EXPLAIN AST output (either
matching it against a reference file, grepping it for substrings, or
counting lines), and so they break when the default flips to the
compact/pretty/action-annotated form.

The fixes are:

- 14 .sql tests without `-- { echo }`: prepend
  `SET query_plan_pretty_default = 0;` (placed after any leading Tags
  block, so `getTestTagsLength` still strips it).

- 3 .sh tests (`02303_query_kind`, `04093_lazy_final_combined_filtering`,
  `04095_lazy_final_with_lazy_materialization`): append
  `--query_plan_pretty_default=0` to `$CLICKHOUSE_CLIENT`
  (and `$CLICKHOUSE_LOCAL` in `02303_query_kind`, which also calls
  `clickhouse-local`).

- `03280_aliases_for_selects_and_views`: move the SET line below the
  two `EXPLAIN AST ... -- { clientError SYNTAX_ERROR }` queries.
  Placing it above breaks `TestHint` detection of the expected client
  error, the same regression that commit fdcb993 on master already
  fixed for `SET enable_analyzer`.

Known still-failing: tests with `-- { echo }` / `-- { echoOn }` where
the SET on line 1 displaces `-- Tags:` from the first line — so
`getTestTagsLength` no longer strips the Tags block and those lines
end up echoed before the rest of the test. Fixing those needs the
reference files to be regenerated locally, so they're left for a
follow-up commit.

CI report: #105036

Co-Authored-By: Claude Opus 4.7 <[email protected]>

@rienath rienath 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.

Overall looks good. I've left some comments. Let's also mention the new query_plan_pretty_default setting in the changelog

@Fgrtue
Fgrtue marked this pull request as draft May 15, 2026 16:02
@Fgrtue
Fgrtue added this pull request to the merge queue Jun 28, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jun 28, 2026
@Fgrtue
Fgrtue added this pull request to the merge queue Jun 28, 2026
@Fgrtue
Fgrtue removed this pull request from the merge queue due to a manual request Jun 28, 2026
@Fgrtue
Fgrtue enabled auto-merge June 28, 2026 00:55
Comment thread src/Core/SettingsChangesHistory.cpp Resolved
@clickhouse-gh

clickhouse-gh Bot commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 85.30% 85.30% +0.00%
Functions 92.60% 92.60% +0.00%
Branches 77.50% 77.50% +0.00%

Changed lines: Changed C/C++ lines covered by tests: 46/47 (97.87%) | Lost baseline coverage: none · Uncovered code

Full report · Diff report

@Fgrtue
Fgrtue added this pull request to the merge queue Jun 28, 2026
Merged via the queue into master with commit b240acb Jun 28, 2026
166 of 169 checks passed
@Fgrtue
Fgrtue deleted the explain-pretty-make-default branch June 28, 2026 12:05
@Fgrtue

Fgrtue commented Jun 28, 2026 •

Copy link
Copy Markdown
Contributor Author

@groeneai investigate the failure in this test suit: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=105036&sha=8f438483ac39c6874f50859392159b2d711e1f61&name_0=PR&name_1=Stress%20test%20%28arm_ubsan%29

Check if there are any relevant issues or pull requests already opened that are related to this failure. Here is the name of the error that occurred: Logical error: Unexpected return type from A. Expected B. Got C (STID: 3262-40aa)

If there are no relevant issues or PRs found -- create an issue and a PR that will solve this problem.

@robot-clickhouse robot-clickhouse added the pr-synced-to-cloud The PR is synced to the cloud repo label Jun 28, 2026
alexey-milovidov added a commit to zex-hyd/ClickHouse that referenced this pull request Jul 3, 2026
…lan_default` default flip

This test failed on CI (result differs with reference) for two independent
reasons on the current head:

1. The `.sql` printed the label `-- Additional WHERE clauses present, 2 full
   parts selected by partition key / 1 part partially selected by PK` while the
   `.reference` expected the same line suffixed with `, expect index usage`. The
   query below it now uses the vector index under partial primary key pruning
   (the point of this PR), so `USearchSearchCount` is `1` and the label should
   read `expect index usage`. Align the `.sql` literal with the `.reference`.

2. `ClickHouse#105036` made `explain_query_plan_default = 'pretty'` the default on master,
   which renders `EXPLAIN` plans with box-drawing characters that `trimLeft` does
   not strip, so the grepped `Description:`/`Granules:` lines no longer match the
   plain reference. Master added `SET explain_query_plan_default = 'legacy';` to
   this test for exactly this reason; do the same here.

Verified end-to-end against the PR build (26.7.1.1): the test now matches its
reference.

CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=104754&sha=9d1b3aec2a86952d71263172400a8a97bcb05c0f&name_0=PR

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
alexey-milovidov added a commit that referenced this pull request Jul 3, 2026
The recent master merge brought in `explain_query_plan_default = 'pretty'`
(the new default since 26.7, introduced in #105036), which changes the
default `EXPLAIN PLAN` output format. The five constant-folding tests that
assert on `EXPLAIN indexes = 1` output started failing in Fast test with
"result differs with reference":
`04218_partition_pk_pruning_constants_folding`,
`04219_partition_minmax_skip_index_constants_folding`,
`04220_partition_id_constants_folding`,
`04221_partition_id_with_minmax_constants_folding`,
`04314_partition_constants_folding_derived_key`.

Add `SET explain_query_plan_default = 'legacy';` to each of them so their
existing (already reviewed) references stay valid. This mirrors how #105036
handled the ~414 existing `EXPLAIN` tests when it changed the default, and
keeps the references demonstrating per-part constant folding unchanged.

CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=104582&sha=ebf528aa38a90f8bc69735ead2da02540b2d479b&name_0=PR&name_1=Fast%20test

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
UnamedRus added a commit to UnamedRus/ClickHouse that referenced this pull request Jul 3, 2026
`EXPLAIN` output became pretty by default on master (ClickHouse#105036,
`explain-pretty-make-default`). In pretty mode `JoinStep` prints the
join clauses under a `Join conditions` node instead of the flat
`Clauses:` line, so the test's `WHERE explain ILIKE '%Clauses%'` filter
matched nothing and the reference no longer applied.

That master change updated the references of existing tests, but could
not touch 04326 because the test only exists on this branch. Add an
explicit `pretty = 0` to every `EXPLAIN actions = 1` so the flat
`Clauses:` format (and the committed reference) stay valid regardless of
the server default.

Related: ClickHouse#106955

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
Adds the missing entry to SettingsChangesHistory's 26.5 block so that
`SET compatibility = '25.5'` (or any version older than 26.5) reverts
`query_plan_pretty_default` to its pre-26.5 value `false` via
`applyCompatibilitySetting`.

Without this entry, the test `04219_explain_plan_pretty_default` (test 1
of 5) fails — it asserts that the `compatibility = '25.5'` knob rolls
the new pretty default back. `02995_new_settings_history` was also
failing because it cross-checks that newly declared settings have a
corresponding entry in the history.

CI report: ClickHouse#105036

Co-Authored-By: Claude Opus 4.7 <[email protected]>
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
A second batch of stateless tests that the previous opt-out commits
missed. All of these inspect EXPLAIN PLAN / EXPLAIN AST output (either
matching it against a reference file, grepping it for substrings, or
counting lines), and so they break when the default flips to the
compact/pretty/action-annotated form.

The fixes are:

- 14 .sql tests without `-- { echo }`: prepend
  `SET query_plan_pretty_default = 0;` (placed after any leading Tags
  block, so `getTestTagsLength` still strips it).

- 3 .sh tests (`02303_query_kind`, `04093_lazy_final_combined_filtering`,
  `04095_lazy_final_with_lazy_materialization`): append
  `--query_plan_pretty_default=0` to `$CLICKHOUSE_CLIENT`
  (and `$CLICKHOUSE_LOCAL` in `02303_query_kind`, which also calls
  `clickhouse-local`).

- `03280_aliases_for_selects_and_views`: move the SET line below the
  two `EXPLAIN AST ... -- { clientError SYNTAX_ERROR }` queries.
  Placing it above breaks `TestHint` detection of the expected client
  error, the same regression that commit fdcb993 on master already
  fixed for `SET enable_analyzer`.

Known still-failing: tests with `-- { echo }` / `-- { echoOn }` where
the SET on line 1 displaces `-- Tags:` from the first line — so
`getTestTagsLength` no longer strips the Tags block and those lines
end up echoed before the rest of the test. Fixing those needs the
reference files to be regenerated locally, so they're left for a
follow-up commit.

CI report: ClickHouse#105036

Co-Authored-By: Claude Opus 4.7 <[email protected]>
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
The recent master merge brought in `explain_query_plan_default = 'pretty'`
(the new default since 26.7, introduced in ClickHouse#105036), which changes the
default `EXPLAIN PLAN` output format. The five constant-folding tests that
assert on `EXPLAIN indexes = 1` output started failing in Fast test with
"result differs with reference":
`04218_partition_pk_pruning_constants_folding`,
`04219_partition_minmax_skip_index_constants_folding`,
`04220_partition_id_constants_folding`,
`04221_partition_id_with_minmax_constants_folding`,
`04314_partition_constants_folding_derived_key`.

Add `SET explain_query_plan_default = 'legacy';` to each of them so their
existing (already reviewed) references stay valid. This mirrors how ClickHouse#105036
handled the ~414 existing `EXPLAIN` tests when it changed the default, and
keeps the references demonstrating per-part constant folding unchanged.

CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=104582&sha=ebf528aa38a90f8bc69735ead2da02540b2d479b&name_0=PR&name_1=Fast%20test

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

Labels

pr-improvement Pull request with some product improvements 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.

5 participants