Skip to content

Deprecate the enable_analyzer setting: the analyzer can no longer be disabled - #118629

Merged
alexey-milovidov merged 25 commits into
masterfrom
deprecate-enable-analyzer
Sep 15, 2026
Merged

alexey-milovidov merged 25 commits into
masterfrom
deprecate-enable-analyzer

Conversation

@alexey-milovidov

@alexey-milovidov alexey-milovidov commented Sep 7, 2026 •

Copy link
Copy Markdown
Member

The analyzer has been the default since 24.3. Keeping the old query analysis switchable per query means two code paths behind every feature, a second flavor of every test run in CI, and a setting whose two values disagree on the result of a query. This retires the switch in 26.9 and keeps the old analysis only where the server still falls back to it internally.

allow_experimental_analyzer (alias enable_analyzer) becomes an obsolete setting frozen at 1:

  • a change that would disable it is refused with SETTING_CONSTRAINT_VIOLATION wherever a change is checked against the settings constraints — a query, a session, an HTTP parameter, a client option, CREATE/ALTER of a user, a role or a settings profile. Unlike the other obsolete settings the change is refused rather than ignored, because the value decides how a query is analyzed and accepting it silently would return a different result than the one asked for;
  • the OBSOLETE tier makes compatibility leave the setting alone, so a compatibility below 24.3 no longer reverts it. The two CI profiles that pinned the value for exactly that reason (the stress test and the AST fuzzer) no longer need to;
  • a value that predates the deprecation can still arrive from a settings profile in the server configuration or from a setting given to clickhouse-local on the command line, neither of which consults the constraints. executeQuery ignores it, so such a server keeps working with the analyzer instead of quietly analyzing queries the retired way, and system.warnings reports the changed obsolete setting rather than the server refusing every query.

A query that another server sent keeps the value it was sent with: the analyzer is still turned off for a whole query by a few internal code paths on the initiator (EXPLAIN AST, a view read by the old interpreter, a materialized view over a Distributed table), and the servers of a cluster have to agree on how one query is analyzed. test_analyzer_compatibility, whose initiator is a 24.2 server, covers that.

Such a query is identified by its kind, which the initiator sends, so a client that declares its own query to be a secondary one keeps the value as well; there is nothing more trustworthy to key this on, since a secondary query is exactly a query another server says it is sending. clickhouse-local is not a server another one can send a query to, so there the declaration carries no meaning and the value is ignored like any other. 05210_analyzer_cannot_be_disabled_by_query_kind covers that.

What this enables, and what is in this PR because of it:

  • CI. The old-analyzer flavor of the required integration test job is replaced by the plain one (that flavor already existed for the release branches, so a release-branch run now has eight ASan integration jobs instead of sixteen), the --analyzer install flag and the CLICKHOUSE_USE_OLD_ANALYZER mode of the integration framework are gone, and the slowest coverage job keeps its s3 storage, DBReplicated configuration without the analyzer flag.
  • Tests. The arms that ran a shape through the old analysis are removed with their reference lines; the no-old-analyzer tag and the 205 tests carrying it are gone; the three tests that used this setting as their example of a setting with an alias now use one that still moves. 05136_analyzer_cannot_be_disabled covers the new behavior.
  • Documentation. The pages and the setting descriptions stop describing how to run a query without the analyzer. The known-incompatibility list stays — it is how a query written for the older analysis gets updated — but it now says that the older behavior is observable only on an older version.

Not in this PR: the old analysis code itself, which the server still reaches through those internal fallbacks. Removing it is the point of freezing the setting first.

The only thing lost is comparing the two analyses by flipping a flag; that comparison now needs a ClickHouse older than 26.9. Bug reports that only reproduce with enable_analyzer = 0, such as #111927 and #114428, become unreachable.

Related: #111927
Related: #114428

Changelog category (leave one):

  • Backward Incompatible Change

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

The analyzer can no longer be disabled: the enable_analyzer setting (and its old name allow_experimental_analyzer) is obsolete, an attempt to set it to 0 is rejected, and the compatibility setting no longer reverts it. The analyzer has been the default since 24.3, and the query analysis used before it is no longer supported. To compare the behaviour or the performance of a query with the old query analysis, use a ClickHouse version older than 26.9.


Workflow [PR]
Sync PR [sync-upstream/pr/118629]

Version info

  • Merged into: 26.9.1.1520 (included in 26.9 and later)

alexey-milovidov and others added 7 commits September 7, 2026 17:02
The analyzer has been the default since 24.3. Keeping the old query analysis
switchable per query means two code paths for every feature, a second flavor of
every test run in CI, and a setting whose two values disagree on the result of a
query. Retire the switch in 26.9 and keep the old analysis only where the server
itself still falls back to it internally.

`allow_experimental_analyzer` (alias `enable_analyzer`) becomes an obsolete
setting frozen at `1`:

- a change that would disable it is refused with
  `SETTING_CONSTRAINT_VIOLATION` wherever a change is checked against the
  settings constraints - a query, a session, an HTTP parameter, a client option,
  `CREATE`/`ALTER` of a user, a role or a settings profile. Unlike the other
  obsolete settings the change is refused rather than ignored, because the value
  decides how a query is analyzed and accepting it silently would return a
  different result than the one asked for;
- the `OBSOLETE` tier makes `compatibility` leave the setting alone, so a
  `compatibility` below 24.3 no longer reverts it to the pre-analyzer value.
  The two profiles that pinned the value for that reason (the stress test and
  the AST fuzzer) no longer need to;
- a value that predates the deprecation can still arrive from a settings profile
  in the server configuration or from a setting given to `clickhouse-local` on
  the command line, neither of which consults the constraints. `executeQuery`
  ignores it, so such a server keeps working with the analyzer instead of quietly
  analyzing queries the retired way, and `system.warnings` reports the changed
  obsolete setting.

A query that another server sent keeps the value it was sent with: the analyzer
is still turned off for a whole query by a few internal code paths on the
initiator (`EXPLAIN AST`, a view read by the old interpreter), and the servers of
a cluster have to agree on how one query is analyzed. This is also why the value
is only refused on the throwing constraint paths and not on the clamping ones,
which is what a secondary query takes.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Every query that asked for `enable_analyzer = 0` is now refused, so the arms
that ran a shape through the old analysis are removed together with their
reference lines, and the two tests that covered nothing else are deleted:

- `04926_optimize_date_preimage_old_analyzer` pinned the legacy planner's
  preimage rewrite (`04927` covers the analyzer);
- `05022_analyzer_constraint_survives_compatibility` pinned the two halves of
  the profile the stress test and the AST fuzzer used to keep the analyzer on -
  a `MIN 1` constraint and a pinned value. Both halves are now built in, and
  `05136_analyzer_cannot_be_disabled` covers the behavior for every user;
- `04894_in_subquery_lowcardinality_type_old_analyzer` keeps the invariant it
  asserts (the result type of `IN` over `LowCardinality` must not depend on the
  form of the right-hand side) and loses the name of the analysis that had the
  bug;
- `04721`'s ALIAS-column arm and `test_legacy_read_in_order_is_rejected` were
  reachable only through the old interpreter, so they are removed rather than
  ported;
- the `getSetting` documentation example switched settings: it changed
  `enable_analyzer`, which the docs-examples check would now fail on.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
The suite no longer has a flavor that runs it with the analyzer turned off:

- `tests/config/install.sh --analyzer` and the `users.d/analyzer.xml` profile it
  linked are gone, and so is the `CLICKHOUSE_USE_OLD_ANALYZER` mode of the
  integration-test framework and its `use_old_analyzer` per-instance option. The
  instances that asked for it are cross-version tests whose old node is
  `CLICKHOUSE_CI_MIN_TESTED_VERSION` (25.3), which enables the analyzer by
  default anyway, so both sides now agree the other way around;
- `clickhouse-test` loses the `no-old-analyzer` tag, the probe that decided
  whether the mode was active, and the `CLOUD_ENABLE_ANALYZER` knob of its cloud
  mode. The tag is removed from the 205 tests that carried it;
- `test_analyzer_compatibility` keeps testing a mixed cluster whose 24.2
  initiator has no analyzer: a query it sends is a secondary query, which still
  runs the way the initiator asked.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
The mode no longer exists, so the jobs and the profiles that used it are
reworked rather than kept:

- the required integration test job loses the `old analyzer` flavor and runs the
  plain `amd_asan_ubsan, db disk` one instead. That flavor was already defined
  for the release branches only (`integration_test_asan_master_jobs`), where it
  ran next to the old-analyzer one; the two are now the same job, so the
  duplicate is gone and a release-branch run has six integration jobs instead of
  twelve;
- the slowest coverage job, `old analyzer, s3 storage, DBReplicated`, keeps the
  configuration that makes it worth its runtime and drops the analyzer flag;
- `--analyzer` is gone from `functional_tests.py` and from
  `integration_test_job.py`, which no longer exports
  `CLICKHOUSE_USE_OLD_ANALYZER`;
- the stress test and the AST fuzzer profiles drop the `enable_analyzer`
  constraint and the pinned value they needed to survive a randomized
  `compatibility`: an obsolete setting is left alone by `compatibility`, and
  pinning it now would report a changed obsolete setting in `system.warnings`
  (which `01945_system_warnings` asserts against). `stress.py` no longer has to
  pass the setting on the client command line either.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
The setting is obsolete, so the pages and the setting descriptions stop
describing how to run a query without the analyzer:

- the analyzer guide says the setting is frozen in 26.9 and that the older
  behavior it lists is observable only on an older version. Its
  projection-name example no longer switches the setting to show both outcomes;
- the per-setting descriptions drop the clauses that scoped a behavior to
  `enable_analyzer = 1` or described what happened at `0` - among them the
  external-table strict-query paragraph, which is duplicated across the MySQL,
  PostgreSQL and SQLite engines and table functions;
- the `WITH` and pipe-operators statement documentation loses the parts about
  selecting the analyzer in a subquery.

The pages under `docs/reference/` are generated from these descriptions, so they
are left for the documentation autogeneration to pick up.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Three tests used `enable_analyzer` as their example of a setting with an alias.
It is obsolete now, which changes exactly what they assert:

- `03243_compatibility_setting_with_alias` and
  `04234_set_alias_compatibility_tracking` asserted that `compatibility` reverts
  it. `compatibility` leaves an obsolete setting alone, so both switch to
  `enable_lightweight_update`, whose default was flipped in 25.8;
- `04357_system_documentation_table` and
  `04652_system_documentation_settings_history` printed the documentation of the
  `enable_analyzer` alias. An obsolete setting and its aliases are not exposed
  in `system.documentation`, so they use the `allow_database_iceberg` alias,
  whose history is likewise recorded under its own name.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Drop the trailing whitespace and the blank lines that removing a sentence from a
setting description left, and a comment in `04403` that promises to run its
scenario with the analyzer turned off (its loop has one value already).

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@mintlify

mintlify Bot commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated
ClickHouse-docs 🟢 Ready View Preview Sep 15, 2026, 3:59 AM

@clickhouse-gh

clickhouse-gh Bot commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [d88f086]

Summary: ❌

job_name test_name status info comment
LLVM Coverage FAIL
Generate LLVM Coverage Diff Report FAIL cidb Coverage degraded: master 89.10% → PR 88.40% (dropped 0.70 pp, tolerance 0.3 pp)

AI Review

Summary

This PR freezes enable_analyzer / allow_experimental_analyzer at 1, removes the old-analyzer CI and test modes, and documents the setting as obsolete. The direction is right, but the current head still leaves several real paths where a stale allow_experimental_analyzer = 0 continues to affect behavior, so I would not merge it yet.

Findings

❌ Blockers

  • [tests/integration/test_analyzer_compatibility/test.py:16] Mixed-version secondary queries from a stock 24.2 initiator are still not preserved. src/Server/TCPHandler.cpp:2820-2824 only synthesizes allow_experimental_analyzer = 0 for senders older than 23.3, while a 24.2 initiator still defaults to the old analyzer but does not send unchanged settings. The new old_analyzer.xml pin hides that rolling-upgrade break instead of fixing it, so a real 24.2 -> 26.9 cluster can still return different results across replicas. Suggested fix: synthesize the legacy analyzer setting for pre-24.3 secondary queries when the sender could still default it off and did not send it.
  • [src/Access/SettingsConstraints.cpp:461] Explicit writes of enable_analyzer = 0 are still silently accepted when the current context already carries that value. getNewValueToCheck drops unchanged assignments before the new refusal runs, so SET enable_analyzer = 0 and CREATE SETTINGS PROFILE ... SETTINGS enable_analyzer = 0 are treated as no-ops instead of raising SETTING_CONSTRAINT_VIOLATION. That still lets new profiles, roles, and users persist the obsolete 0, and it feeds the remaining stale-setting bugs below. Suggested fix: run the analyzer-disable check before the unchanged-value fast path, or exempt this setting from that fast path.
  • [src/Interpreters/executeQuery.cpp:2301] Normalizing the obsolete setting in executeQuery is too late for several supported internal paths. Background mutation contexts created via makeQueryContextForMutate still fall back to allow_experimental_analyzer (src/Interpreters/MutationsInterpreter.cpp:118-122, src/Storages/MergeTree/MergeTreeData.cpp:9951-9973, src/Storages/MergeTree/MutateFromLogEntryTask.cpp:262-277), and metadata replay still constructs InterpreterCreateQuery directly from an unnormalized context (src/Interpreters/loadMetadata.cpp:62-84, src/Interpreters/InterpreterCreateQuery.cpp:1149-1162, 1317-1353). A stale config or profile allow_experimental_analyzer = 0 therefore still changes mutation analysis / execution and startup ATTACH / CREATE ... AS SELECT behavior, contradicting the PR contract that obsolete profile values are ignored. Suggested fix: normalize the setting in the common query-context constructors, with an explicit carve-out only for genuine secondary-query cases that still need the legacy path.

⚠️ Majors

  • [tests/queries/0_stateless/04759_mutation_pruning_background_analyzer_mode.sh:8] The PR deletes the only end-to-end check that submit-time partition-pruning analysis follows the background analyzer mode while use_analyzer_for_mutations = false remains a supported fallback. tests/integration/test_mutations_analyzer_override/test.py only watches the Will use old analyzer to prepare mutation log line, so it would not catch a regression where a mutation is accepted and enqueued under the session analyzer and only fails later in the background. Suggested fix: keep a behavioral test that proves the fail-fast / no-enqueue invariant, not just the log message.
  • [src/Interpreters/executeQuery.cpp:2301] The stale setting still changes MySQL-port query semantics even on the new-analyzer path. src/Interpreters/Session.cpp:728-733 copies the user or session profile first, and src/Server/MySQLHandler.cpp:880-889 checks allow_experimental_analyzer before executeQuery forces it back to 1; when the stale value is 0, the handler still flips prefer_column_name_to_alias = 1. tests/queries/0_stateless/02968_mysql_prefer_column_name_to_alias.sh documents that this workaround changes identifier resolution results, so the obsolete analyzer flag is still observably affecting MySQL queries. Suggested fix: normalize allow_experimental_analyzer before that workaround runs, or key the workaround off the actual legacy interpreter path instead of the raw setting.

💡 Nits

  • [src/Parsers/ParserWithElement.cpp:412] The recursive CTE note now tells users on older versions to enable enable_analyzer, but versions 24.3 through 24.7 only know allow_experimental_analyzer. That recovery hint will send exactly the affected users to an unknown setting. Suggested fix: mention allow_experimental_analyzer for 24.3-24.7, or mention both names with the version split, and optionally note that a low compatibility can also keep the analyzer off on those versions.
Tests
  • ⚠️ The mixed-version compatibility claim is still not proved by the current tests. The smallest focused missing check is one 24.2 -> current cluster test without pinning allow_experimental_analyzer = 0 on the old node.
  • ⚠️ The supported use_analyzer_for_mutations = false path no longer has an end-to-end pruning test. The smallest missing proof is a test that asserts a mutation with an analyzer-only predicate is rejected before it is enqueued when background execution will use the old analyzer.
Final Verdict
  • Status: ❌ Block
  • Minimum required action: fix stale allow_experimental_analyzer = 0 leakage in settings checks and in query contexts that bypass or precede executeQuery.
  • Minimum required action: preserve rolling-upgrade behavior for pre-24.3 secondary queries without requiring manual pinning on the old node.
  • Minimum required action: restore focused coverage for the still-supported mutation fallback path.
  • Minimum required action: correct the recursive-CTE recovery note for pre-24.8 setting names.

LLVM Coverage Report

Measured on commit d88f086.

Metric Baseline Current Δ
Lines 89.10% 88.40% -0.70%
Functions 91.80% 91.80% +0.00%
Branches 81.50% 80.60% -0.90%

Changed lines: Changed C/C++ lines covered: 163/163 (100.00%) · Uncovered code

Full report · Diff report

@clickhouse-gh clickhouse-gh Bot added the pr-backward-incompatible Pull request with backwards incompatible changes label Sep 7, 2026
The scan that found the queries asking for `enable_analyzer = 0` only matched a
literal value, so the places that pass it through a variable survived:

- `01786_explain_merge_tree` ran its whole body twice, `--enable_analyzer=$i`
  over `seq 0 1`; it keeps the analyzer half, and its reference loses the other;
- `04759_mutation_pruning_background_analyzer_mode` submitted a mutation with
  the session analyzer mode set to the opposite of the server's, which is no
  longer a state a test can reach, so it is deleted. The guard it covered still
  matters for a mutation whose background context disagrees with the session -
  `test_mutations_analyzer_override` covers that through the server setting;
- four integration tests parametrized over both values
  (`test_wasm_udf_fail_close`, `test_storage_delta` twice, `test_s3_cluster`,
  `test_storage_bigquery`); they now run once, with the analyzer.

`05136` asserts a `clientError` for a `SETTINGS` clause: the client applies a
query's `SETTINGS` to its own session before sending the query, so the constraint
refuses it there rather than on the server. A `SET` still fails server-side.

Also revert the `sqlalchemy.mdx` edit: that path is a one-way copy from
`ClickHouse/clickhouse-connect`, which the docs check rejects editing here.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Comment thread src/Interpreters/executeQuery.cpp Resolved
@alexey-milovidov

Copy link
Copy Markdown
Member Author

Remove tests for compatibility with the old analyzer.

Conflicts and the decisions taken:

- `src/Core/SettingsChangesHistory.cpp`: both entries kept.
- `src/Core/Settings.cpp`: master's new "Supported only with the analyzer" note on
  `optimize_rewrite_aggregate_function_with_if` is dropped, like the others this branch removed.
- `src/Server/TCPHandler.cpp`: master's `query_kind` assignment before the version-gated
  decisions is kept, with this branch's `FIXME` wording.
- `src/Storages/Storage{MySQL,PostgreSQL,SQLite}.cpp`: master's `<Note>` markup with this
  branch's text, which no longer describes the old query analysis.
- `ci/defs/defs.py`, `ci/defs/job_configs.py`: master's `ASAN_IT_NUM_BATCHES = 8` is kept, and
  the single remaining ASan integration flavor is the plain one, so
  `integration_test_asan_master_jobs` (the release-branch-only duplicate) is gone and
  `LLVM_FT_OLD_S3_DB_REPL_NUM_BATCHES` is renamed. The workflow YAML is regenerated.
- `tests/integration/test_distributed_plan_replicated_merge_tree/test.py`: master's new
  `test_legacy_read_in_order_is_rejected` runs its query with `enable_analyzer = 0` and is
  removed with the rest of the old-analyzer coverage.
- `04306_distributed_aggregation_correctness_guards.sql`,
  `04335_distributed_plan_cancel.sh`: master's text without the `no-old-analyzer` tag.

The nine tests master tagged `no-old-analyzer` in the meantime lose the tag too.
The 3070 commits merged in the previous commit brought about forty more test arms that run a
shape with `enable_analyzer = 0`, mostly around the new `LIMIT AFTER`/`UNTIL` feature. Such a
query is refused now, so those arms go the way of the ones the branch already removed.

Removed outright, having no other arm: `04353_limit_after_legacy_union_branch_local_settings`
and `test_limit_after_until_distributed`'s
`test_legacy_union_settings_limit_is_not_sent_to_range_shards`, whose analyzer-side counterpart
is `04345_limit_after_distributed_settings_limit`.
`05067_limit_after_legacy_distributed_in_subquery` loses the word from its name: what is left of
it is the arm that was the control.

`05210_analyzer_cannot_be_disabled_by_query_kind` and the narrowing in `executeQuery` answer the
review of `src/Interpreters/executeQuery.cpp:2287`: the carve-out that lets a query keep the
value it was sent with is keyed on the query kind, which the client sends, so a client could
declare its own query to be a secondary one and keep the old query analysis. There is nothing
more trustworthy to key it on - a secondary query is exactly a query another server says it is
sending, and forcing the analyzer on instead would make an initiator that turned it off
internally (a materialized view over a `Distributed` table, a view read by the old interpreter)
disagree with its own replicas. `clickhouse-local` is not a server another one sends queries to,
so there the declaration no longer carries a meaning.
Recorded from a local build of this branch, so each file loses exactly the lines the removed arm
produced (and, in the `-- { echo }` tests, the echoed queries and the comments that were reworded).
`05068_limit_after_exact_rows_before_limit_early_finish` loses its arm here: the scan that found the
others missed it.
The `Fast test` of the previous push found them: CI merges the branch with master's current head,
which had moved 92 commits past the merge, and four of the tests that arrived in them run a shape
with `enable_analyzer = 0`.

Three hid the value behind an indirection, which is why the scan of the previous commit did not see
them: `05182_legacy_array_join_constraint_not_used_by_optimizer` and
`05076_additional_table_filters_column_access` loop a shell variable over both values, and
`05112_recursive_cte_union_branch_propagation_json_ast` passes it as a function argument. The scan
now flags every mention of the setting that is not a literal `1`, and the value set behind each
remaining `$analyzer` indirection was checked by hand; `05183_unreferenced_with_array_join_limit_pushdown`
was the only one spelling it out.

`05182` keeps its name: the "legacy" in it is the stored constraint written by a version without the
`arrayJoin` check, not the query analysis. `05076` loses the `analyzer=N` label from its echoes
along with the loop, so its reference gains the relabelled lines and loses the arm's results.
main_configs=["configs/remote_servers.xml"],
)
# Here analyzer is disabled by default
# Here analyzer is disabled by default. The value is pinned explicitly all the same: only a changed

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This pin makes the test pass, but it also hides a rolling-upgrade break in the implementation. A stock 24.2 initiator keeps allow_experimental_analyzer = 0 only as its default and does not force that setting into the transmitted SettingsChanges (for example, v24.2.3.70-stable src/Client/MultiplexedConnections.cpp just forwards modified_settings as-is). On the 26.9 side TCPHandler only synthesizes allow_experimental_analyzer = 0 when the sender is < 23.3, so an ordinary 24.2 secondary query still arrives without the setting and is analyzed with the new analyzer on the follower. That means a mixed 24.2/26.9 cluster can still return different results during upgrade unless the old nodes are reconfigured exactly like this test.

The receiver-side fallback needs to cover "sender defaulted to old analyzer and omitted the setting" for pre-24.3 initiators, not just versions that predate the setting entirely.

return true;
}

if (isChangeDisablingTheAnalyzer(setting_name, new_value))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This rejection runs after getNewValueToCheck, which already returns {} for a no-op change when the current context value is the same. So if a session, profile, or server config already inherited allow_experimental_analyzer = 0, an explicit SET enable_analyzer = 0 or CREATE SETTINGS PROFILE ... SETTINGS enable_analyzer = 0 is treated as "unchanged" and succeeds instead of raising SETTING_CONSTRAINT_VIOLATION. That contradicts the contract this PR adds in 05136_analyzer_cannot_be_disabled.sql, and it lets new users, roles, and profiles keep persisting the obsolete 0 as long as the creator already has it.

I think the special-case needs to run before the unchanged-value fast path, or that fast path needs an exception for this setting, so every explicit write of 0 is rejected regardless of the current inherited value.

# shellcheck source=../shell_config.sh
. "$CUR_DIR"/../shell_config.sh

# A mutation executes in the background with a context derived from the background context, so a

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

use_analyzer_for_mutations = false is still a supported old-analyzer fallback after this PR: MutationsInterpreter::shouldUseAnalyzerForMutations still switches on it, and test_mutations_analyzer_override only verifies that the MutationsInterpreter log line appears. This deleted test is the only end-to-end check I found that the submit-time partition-pruning analysis follows the background analyzer mode rather than the submitting session. Without it, a regression where ALTER ... UPDATE ... WHERE t.p = 1 is accepted under the session analyzer and only fails later after the mutation was enqueued would go unnoticed.

Please keep a behavioral test for this invariant, even if it moves to integration. The log message alone does not prove that pruning and enqueue/no-enqueue still use the same analyzer mode as background execution.

<Note>
Recursive CTEs rely on the [query analyzer](/guides/clickhouse/performance-and-monitoring/analyzer) introduced in version **`24.3`**. If you're using version **`24.3+`** and encounter a **`(UNKNOWN_TABLE)`** or **`(UNSUPPORTED_METHOD)`** exception, it suggests that the analyzer is disabled on your instance, role, or profile. To activate the analyzer, enable the setting **`allow_experimental_analyzer`** or update the **`compatibility`** setting to a more recent version.
Starting from version `24.8` the analyzer has been fully promoted to production, and the setting `allow_experimental_analyzer` has been renamed to `enable_analyzer`.
Recursive CTEs rely on the [query analyzer](/guides/clickhouse/performance-and-monitoring/analyzer) introduced in version **`24.3`**, which is the default since that version and mandatory since **`26.9`**. On an older version that still has the analyzer disabled on the instance, the role or the profile, a recursive CTE raises a **`(UNKNOWN_TABLE)`** or **`(UNSUPPORTED_METHOD)`** exception; enable the `enable_analyzer` setting there, or upgrade.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This recovery hint is wrong for the versions it is talking about. enable_analyzer was only added as an alias in 24.8 (SettingsChangesHistory.cpp records that), so users on 24.3-24.7 who hit this note still need allow_experimental_analyzer. Since the note explicitly targets older versions with the analyzer disabled, it should mention the historical name, or both names with the version split, instead of only the post-24.8 alias.

@clickhouse-gh

clickhouse-gh Bot commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing d88f086fc with master 8d780d797 (stripped binary size, per-symbol sizes and ThinLTO time; object sizes against the warmup build of 64f327c50; compile times per translation unit against the most recent warmup build that recompiled it).

✅ No significant changes.

Binary sizes

programs/clickhouse-stripped: smaller than the master baseline by the known offset between the two builds, so the difference is not shown. A delta that differs from the offset by more than 50% of it is shown, in either direction.

The official master build is compiled with -g and a pull request build is not, and XRay counts debug instructions towards its instrumentation threshold, so master instruments thousands of functions more and its binary is ~0.4% larger no matter what the pull request does.

Compile time of recompiled translation units

20 translation units recompiled, 101 s compile time in total, 20 of them have a recent master baseline.

Median compile-time ratio to the baselines is ×1.09 (machine-speed difference or a change affecting every TU); per-TU deltas below are relative to that ratio.
The matched translation units cost +9.5 s (+10%) in total before that adjustment.

Job report

@alexey-milovidov

Copy link
Copy Markdown
Member Author

🕵 The LLVM Coverage failure is the intended effect of this change and is going to be overridden rather than fixed.

Baseline coverage : 89.00%
Current coverage  : 88.30%
Coverage degraded: master 89.00% → PR 88.30% (dropped 0.70 pp, tolerance 0.3 pp)

The gate compares total line coverage. This pull request removes the tests that exercised the query analysis used before 24.3 while deliberately leaving that code in the tree — removing it is the point of freezing the setting first — so about 0.7 pp of the codebase stops being exercised by design. The number is the same one the first CI run reported, so it is a property of the change and not of the merge with master.

The coverage of what the change actually touches is unaffected: PR changed C/C++ lines covered by tests: 100.00% (163/163), and the gate has no per-pull-request waiver (COVERAGE_DROP_TOLERANCE is a constant in ci/jobs/llvm_coverage_job.py), so raising the tolerance here would loosen it for every other pull request. The drop is expected to be recovered when the old analysis code itself is removed.

/// no meaning there and does not keep the old query analysis alive.
const bool sent_by_another_server = client_info.query_kind == ClientInfo::QueryKind::SECONDARY_QUERY
&& client_info.interface != ClientInfo::Interface::LOCAL;
if (!context->getSettingsRef()[Setting::allow_experimental_analyzer] && !sent_by_another_server)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This normalization is still too late for the MySQL wire path. Session::makeQueryContextImpl copies the user's/profile's stale allow_experimental_analyzer into the query context first, and src/Server/MySQLHandler.cpp:880-889 reads it before executeQuery reaches this reset. When that stale value is 0, the handler still forces prefer_column_name_to_alias = 1 as the old-analyzer workaround from Bug 56173, even though the query is then analyzed with the new analyzer.

tests/queries/0_stateless/02968_mysql_prefer_column_name_to_alias.sh documents that this workaround changes name-resolution behavior, so the obsolete analyzer flag is still observably affecting MySQL-port query semantics. I think the stale value needs to be normalized before the handler reads it, or the workaround needs to key off the actual legacy interpreter path instead of the raw setting.

@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Sep 15, 2026
Merged via the queue into master with commit 038ade6 Sep 15, 2026
346 of 349 checks passed
@alexey-milovidov
alexey-milovidov deleted the deprecate-enable-analyzer branch September 15, 2026 11:15
@robot-ch-test-poll robot-ch-test-poll added the pr-synced-to-cloud The PR is synced to the cloud repo label Sep 15, 2026
novikd added a commit that referenced this pull request Sep 15, 2026
Master froze `enable_analyzer` at `1` (#118629): setting it to `0` is rejected and the
`no-old-analyzer` tag is gone from the harness. The old-analyzer sections of
`05141_force_materialized_cte` and the two `enable_analyzer = 0` variants of the `05154` alias
section are removed, `05153_force_materialized_cte_old_analyzer_udf` is deleted as a test of
the retired configuration, and the tags this PR had added to `04076` and `04700` go away.

The old query analysis still runs for mutations on a server configured with
`use_analyzer_for_mutations = 0`, so the checks in `InterpreterSelectQuery`,
`TreeRewriter::normalize` and `InterpreterUpdateQuery` stay; the setting descriptions, the
`WITH` documentation and the rejection message name that server setting instead of
`enable_analyzer`.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
alexey-milovidov added a commit that referenced this pull request Sep 17, 2026
Master made the analyzer mandatory since 26.9 (#118629): `SET enable_analyzer = 0`
now throws `SETTING_CONSTRAINT_VIOLATION`, so tests `04759_read_in_window_order_prefetching_concat`
and `04823_read_in_order_legacy_path_no_prefetching_concat` fail. Both exercised
`PrefetchingConcatProcessor` opt-outs on paths that only the old analyzer reached:
the `query_plan_reuse_storage_ordering_for_window_functions` window-order reuse
(gated on `!allow_experimental_analyzer` in `optimizeReadInOrder.cpp`) and the
`InterpreterSelectQuery` `order_optimizer` entry point with `query_plan_read_in_order = 0`.
With the analyzer these shapes no longer read in order at all, so the assertions
would only be vacuous. Delete the tests, as master did for its own old-analyzer-only tests.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
alexey-milovidov added a commit that referenced this pull request Sep 19, 2026
…deleted

`#118629` deleted the handling of this tag from `tests/clickhouse-test` along with
the flavor that used it, and nothing validates the tag list, so an unknown tag
selects nothing and is silently inert. Four tests that landed on master between
2026-09-11 and 2026-09-16 therefore arrived with the tag and no report ever
mentioned it - grep is the only way to see them. They name an analysis this branch
removes, so the text goes with it.

`05212_isnull_non_canonical_null_map` runs under `-- { echo }`, which echoes the
two lines into its output, so its reference loses exactly the same two lines and
every surviving line stays byte-identical to what master recorded.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
groeneai added a commit to groeneai/ClickHouse that referenced this pull request Sep 19, 2026
`enable_analyzer` is obsolete since v26.9 (ClickHouse#118629): a query that sets it to `0`
is refused with `SETTING_CONSTRAINT_VIOLATION`, and a value that reaches a query
through a settings profile or a `clickhouse-local` command line is ignored in
`executeQuery`. The old query analysis therefore no longer applies the frame
this test is about, so the comment saying it does describes a removed feature.

The consequence the test asserts on is unaffected and still reachable: the frame
is dropped from the query text. Measured on master 015bf12,
`formatQuerySingleLine('SELECT 1 WINDOW w AS (ORDER BY a), x AS (ROWS UNBOUNDED
PRECEDING w)')` returns `SELECT 1 WINDOW w AS (ORDER BY a ASC), x AS (w)`.

Comment only. The test never set `enable_analyzer`, so it was not rejected by
the new constraint, and the parser fix is analyzer-agnostic: the diff carries no
other reference to the analyzer.
@alexey-milovidov alexey-milovidov mentioned this pull request Sep 20, 2026
47 of 72 tasks
pull Bot pushed a commit to TCeason/ClickHouse that referenced this pull request Sep 20, 2026
ClickHouse#118629 froze `enable_analyzer`
at `1` and left the old query analysis reachable through a handful of internal
fallbacks. This removes those fallbacks, and with them the old analysis as a
way a query can be analyzed.

Nothing turns the analyzer off for a query anymore:

- a secondary query from an initiator older than 23.3 no longer carries
  `allow_experimental_analyzer = 0` into this server, and a value that reaches a
  query some other way (a settings profile from the server configuration,
  `clickhouse-local` on the command line, an initiator that sends it) is
  normalized in `executeQuery`, so `getSetting` and `system.query_log` report
  the analysis that actually ran;
- `EXPLAIN AST`, a view read by the old interpreter and a materialized view over
  a `Distributed` table no longer switch the setting off for the query they run;
- `InterpreterFactory` builds `InterpreterSelectQueryAnalyzer` for every shape of
  a `SELECT`, `ASTSelectIntersectExceptQuery` included - that one used to reach
  the old interpreter regardless of the setting, which the old interpreter then
  noticed and reported as a possible bug.

With that, every `if (enable_analyzer)` in `src` has one reachable arm, and the
other arm is gone: 76 files, from the storages that chose between a query tree
and an AST down to the constant-expression evaluator and the `isNull` family.
Removing them makes a pile of code unreferenced - the parallel-replicas reading
step built from an AST, `StorageDistributed::getOptimizedQueryProcessingStage`,
`rewriteSelectQuery`, the `EXPLAIN` plan-secrets guard (the analyzer masks
secrets in the plan, the old analysis could not) and
`tryReuseStorageOrderingForWindowFunctions`, an optimization that had been
obsolete for as long as it was analyzer-gated.

Three consumers that were still analyzed the old way are converted to the
analyzer instead: mutations, the `format_schema` query of `FormatSchemaInfo`, and
the row lookup of `MaterializedPostgreSQL`. Mutations lose the
`use_analyzer_for_mutations` server setting, the escape hatch from the rollout
that made them analyzer-analyzed; it is the last thing that could have asked for
the old analysis, and `parallel_replicas_only_with_analyzer` becomes obsolete for
the same reason.

Not removed: `InterpreterSelectQuery`, `ExpressionAnalyzer` and `TreeRewriter`.
They are no longer how a query a user sends is analyzed, but they remain the
machinery that compiles a standalone expression (a `TTL` expression, a sharding
key, a column default) and a synthetic `SELECT` over a source built in place -
the projection machinery and the AST-based arms of `EXPLAIN SYNTAX` and
`EXPLAIN AST` do that and never go through query analysis. `InterpreterSelectQuery`
says so now, so that no new caller is added.

A pre-26.9 initiator therefore no longer gets the query analysis it asks its
replicas for; `test_analyzer_compatibility`, whose initiator is a 24.2 server,
covers that this server ignores the value instead.
pull Bot pushed a commit to admariner/ClickHouse that referenced this pull request Sep 24, 2026
… Distributed table

A `CREATE TABLE` whose `CHECK` constraint contains a scalar subquery over a
`Distributed` table or `remote(...)` kills the server:

    CREATE TABLE t (x UInt64, CONSTRAINT c CHECK x < (SELECT max(id) + 1000
        FROM remote('127.0.0.1', currentDatabase(), 'src'))) ENGINE = MergeTree ORDER BY tuple();

`InterpreterCreateQuery::getConstraintsDescription` analyses every constraint with
`TreeRewriter::analyze`, which runs `executeScalarSubqueries`; that visitor built
`InterpreterSelectWithUnionQuery` unconditionally, and the old interpreter never
assigns `query_info.query_tree` or `query_info.planner_context`. Since
`StorageDistributed::read` has no non-analyzer arm any more, it dereferences the
planner context unconditionally and the read faults on a null pointer.

A `TTL ... WHERE` predicate is a second carrier of the same fault, not a separate bug:
`TTLDescription::getTTLFromAST` analyses the `DELETE WHERE` predicate through the same
`TreeRewriter::analyze` (`TTLDescription.cpp:1490` then `:1270`), so the one fix resolves
both slots. The two differ in how the source may be named: the `remote(...)` table
function is rejected before planning there with `THERE_IS_NO_QUERY`, because a TTL
description is built without a query context and resolving a table *function* needs one,
so only a named `Distributed` table reaches the dereference. Both slots are covered by the
new test, the `TTL` one through a named table.

The branch that used to hide this was keyed on `allow_experimental_analyzer`, which has
been frozen at 1 since ClickHouse#118629, and ClickHouse#120311 removed it. That commit's own note in
`InterpreterSelectQuery.h` asks new callers to use `InterpreterSelectQueryAnalyzer`; a
scalar subquery of a standalone expression is the user's own `SELECT`, i.e. exactly that
case. The crash is not a regression of ClickHouse#120311: the same dereference and the same
interpreter construction exist on 26.9 and 26.8, where that setting's default of 1 selects
the analyzer arm as well.

The identical dereference was reached once before through `StorageMaterializedView` and
fixed at its origin by ClickHouse#107653. This is a second entry path, so the producer is fixed
rather than the storage: a null guard in `StorageDistributed` would have no arm to fall
back to and could only throw, turning a crash into a rejected statement that works on
26.9, and it would have to be repeated for every analyzer-only engine.

The interpreter swap carries over four behaviours of the old path, each matching the
analyzer's own scalar-subquery executor in
`src/Analyzer/Resolve/evaluateScalarSubqueryIfNeeded.cpp`:

* the materialized-view source substitution `JoinedTables::getLeftTableStorage` did,
  through the `InterpreterSelectQueryAnalyzer` storage overload, so a scalar subquery
  compiled during a view push still reads the inserted block;
* `use_structure_from_insertion_table_in_table_functions` in the subquery settings,
  because `QueryAnalyzer` reads it from the scope context rather than from the query
  context the pre-existing line mutates (that line stays, it is issue ClickHouse#52494's);
* `allow_experimental_parallel_reading_from_replicas = 0`, because `Planner`'s
  constructor inspects the tree for parallel-replica candidates;
* `options.forceMaterializeCTE()`, because `collectMaterializedCTEs` returns nothing for
  subquery options, so a materialized CTE would be read unpopulated.

Disabling parallel replicas on the subquery context alone is not enough, and the setting is
also stripped from a clone of the subquery AST. `QueryTreeBuilder::buildSelectExpression`
applies a SELECT's own `SETTINGS` clause onto the context it stamps on the `QueryNode`, and
`findQueryForParallelReplicas` reads the decision from that node context inside `Planner`'s
member-init list, i.e. inside the interpreter's constructor, where nothing can repair it
afterwards. Without the strip, a scalar subquery whose own clause turns parallel replicas on
and names a cluster that does not exist is rejected with `CLUSTER_DOESNT_EXIST` where it used
to succeed: measured on the constraint above with
`parallel_replicas_for_non_replicated_merge_tree = 1` in the same clause. Both spellings of the
aliased setting are stripped, the way the automatic-parallel-replicas probe in
`InterpreterSelectQueryAnalyzer` strips the settings it overrides, and from a clone because the
AST belongs to the statement being analysed rather than to this helper.

The test's session-level arm pins `automatic_parallel_replicas_mode = 0`, which is that
setting's own default. The test runner draws 2 for it in a quarter of runs, and with the
statement's `allow_experimental_parallel_reading_from_replicas = 1` inherited,
`InterpreterSelectQueryAnalyzer::buildContext` then clears `enable_parallel_replicas` on its
own context copy, so the subquery would never reach a cluster lookup and the arm would stop
exercising the strip at all in those runs.

The recursive nested-context walk the reference executor also does stays uncopied: it clones an
already-built tree whose nested nodes carry the original context, while this path builds the
tree from an AST with the subquery context, and `QueryTreeBuilder` stamps a copy of that context
onto every node it creates.

`usesViewSource()` lives on `IInterpreterUnionOrSelectQuery` and has no counterpart on
the analyzer interpreter, so both call sites ask the built query tree with the existing
`isStorageUsedInTree`. The answer is the same wherever the old flag was true and
conservative elsewhere: a scalar can only move from the global cache to the per-query
one, never the reverse.

Co-Authored-By: Claude Opus 5 <[email protected]>
huldarchen pushed a commit to huldarchen/ClickHouse that referenced this pull request Sep 27, 2026
Since ClickHouse#118629, a change that disables the obsolete `allow_experimental_analyzer` (`enable_analyzer`) setting is refused with `SETTING_CONSTRAINT_VIOLATION`, or with `INCORRECT_QUERY` in a nested `SETTINGS` clause. Queries, sessions, settings profiles, clients and drivers that still carry `enable_analyzer = 0` start failing after an upgrade, and `compatibility` does not protect them.

Rewrite such a change to `1` instead: in `SettingsConstraints::checkImpl` for every path that consults the constraints, and in the parsed AST (`normalizeAnalyzerSettings`, formerly `validateAnalyzerSettings`) for `SETTINGS` clauses anywhere in a query, so the value is neither applied to a subquery nor stored in a view definition. The existing normalization at the start of `executeQuery` still covers the paths that bypass the constraints.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp-settings Settings & configuration infrastructure (server/user/query settings, profiles). pr-backward-incompatible Pull request with backwards incompatible changes 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.

2 participants