### Watch all release presentations and videos at [ClickHouse Theater](https://presentations.clickhouse.com/) and [YouTube Playlist](https://www.youtube.com/playlist?list=PL0Z2YDlm0b3jAlSy1JxyP8zluvXaN3nxU).
### Table of Contents
**[ClickHouse release v26.10, 2026-10-22](#2610)**
**[ClickHouse release v26.9, 2026-09-21](#269)**
**[ClickHouse release v26.8 LTS, 2026-08-27](#268)**
**[ClickHouse release v26.7, 2026-07-22](#267)**
**[ClickHouse release v26.6, 2026-06-25](#266)**
**[ClickHouse release v26.5, 2026-05-21](#265)**
**[ClickHouse release v26.4, 2026-04-30](#264)**
**[ClickHouse release v26.3 LTS, 2026-03-26](#263)**
**[ClickHouse release v26.2, 2026-02-26](#262)**
**[ClickHouse release v26.1, 2026-01-29](#261)**
**[Changelog for 2025](https://clickhouse.com/docs/whats-new/changelog/2025/)**
**[Changelog for 2024](https://clickhouse.com/docs/whats-new/changelog/2024/)**
**[Changelog for 2023](https://clickhouse.com/docs/whats-new/changelog/2023/)**
**[Changelog for 2022](https://clickhouse.com/docs/whats-new/changelog/2022/)**
**[Changelog for 2021](https://clickhouse.com/docs/whats-new/changelog/2021/)**
**[Changelog for 2020](https://clickhouse.com/docs/whats-new/changelog/2020/)**
**[Changelog for 2019](https://clickhouse.com/docs/whats-new/changelog/2019/)**
**[Changelog for 2018](https://clickhouse.com/docs/whats-new/changelog/2018/)**
**[Changelog for 2017](https://clickhouse.com/docs/whats-new/changelog/2017/)**
# 2026 Changelog
### ClickHouse release 26.10, 2026-10-22
#### Backward Incompatible Change
* The query analysis that preceded the analyzer is removed. It has not been selectable since 26.9, when `enable_analyzer` became obsolete; now a server no longer uses it for a query another server sends either, so a cluster whose initiator is older than 26.10 gets the analyzer on this server regardless of what the initiator asks for. Such a mixed cluster can see `NOT_FOUND_COLUMN_IN_BLOCK` on the old initiator, because the two analyses name the result columns differently; set `enable_analyzer = 1` on every server before upgrading any of them. The `use_analyzer_for_mutations` server setting is removed, and `parallel_replicas_only_with_analyzer` is obsolete. [#120311](https://github.com/ClickHouse/ClickHouse/pull/120311) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* The predicate push-down that the query analysis preceding the analyzer performed on the AST is removed, and `enable_optimize_predicate_expression` is now obsolete and has no effect. Push-down of a predicate into a subquery is performed by the analyzer as a query plan optimization and is not affected; push-down into a distributed subquery still happens on the AST level and is controlled by `allow_push_predicate_ast_for_distributed_subqueries`. The visible difference is that `EXPLAIN SYNTAX` of a query that is not a `SELECT`, for example `EXPLAIN SYNTAX INSERT INTO ... SELECT ...`, no longer prints a predicate copied into a subquery, a non-aggregate `HAVING` conjunct moved to `WHERE`, or the right-hand table of a `JOIN` wrapped into a subquery. [#121465](https://github.com/ClickHouse/ClickHouse/pull/121465) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* `system.metric_log` now uses the `bucketed` schema by default: all profile events and current metrics are stored in a single `metrics` column of type `Map(Enum16(...), Int64)` with the bucketed `Map` serialization and a constant number of 128 buckets, so the table has a few columns instead of thousands, zero values are not stored, and reading one metric reads only one of the 128 buckets. Every metric is also exposed as an `ALIAS` column, so queries such as `SELECT ProfileEvent_Query FROM system.metric_log` continue to work unchanged. On upgrade the existing table is renamed to `metric_log_0`, as with any other change of the structure of a system log table, and the built-in dashboards read `merge('system', '^metric_log')`, so they keep showing the data collected before the upgrade. Add `wide` to the `` section of the server configuration to keep the previous schema. [#118318](https://github.com/ClickHouse/ClickHouse/pull/118318) ([Alexey Milovidov](https://github.com/alexey-milovidov)). [#124016](https://github.com/ClickHouse/ClickHouse/pull/124016) ([Raúl Marín](https://github.com/Algunenano)).
* `clickhouse-server` can now apply a `seccomp` system call filter at startup. The `seccomp` setting controls refused system calls: `log` only records them, while `trap`, `kill`, and `errno` enforce the policy; `disabled` installs no filter. The `config.xml` shipped with the server packages and the Docker image now sets `seccomp` to `trap`, so a server that runs in a sandbox which refuses the `seccomp` system call must switch it to `log` or `disabled` before the upgrade. Extended-attribute probes used by some hostname-resolution libraries are rejected with `ENOSYS` instead of the configured seccomp action, so server startup still succeeds under the default `trap` mode. You might need to disable seccomp when using executable user-defined functions. [#119545](https://github.com/ClickHouse/ClickHouse/pull/119545) ([Alexey Milovidov](https://github.com/alexey-milovidov)). [#122577](https://github.com/ClickHouse/ClickHouse/pull/122577) ([Alexey Milovidov](https://github.com/alexey-milovidov)). [#124856](https://github.com/ClickHouse/ClickHouse/pull/124856) ([Azat Khuzhin](https://github.com/azat)).
* Settings constraints and `allow_feature_tier` are now enforced for users, roles and settings profiles defined by SQL. A statement is refused if it changes a restricted setting of some user indirectly (such as `GRANT`, `DROP ROLE`, `DROP SETTINGS PROFILE` or `CREATE USER OR REPLACE`), sets a value outside its author's constraints, or removes a setting its author is constrained on. A user defined by SQL whose stored settings, roles or assigned settings profiles violate the constraints or `allow_feature_tier` can no longer log in. The `compatibility` setting no longer applies values that settings constraints or `allow_feature_tier` refuse; such settings keep their current value. Login checks use the user's resolved constraints, preserving bounds inherited from the default profile. Closes [#124966](https://github.com/ClickHouse/ClickHouse/issues/124966). [#119472](https://github.com/ClickHouse/ClickHouse/pull/119472) ([Raúl Marín](https://github.com/Algunenano)). [#125582](https://github.com/ClickHouse/ClickHouse/pull/125582) ([Raúl Marín](https://github.com/Algunenano)).
* Overriding a key that is stored in a named collection now requires `SHOW NAMED COLLECTIONS SECRETS` on that collection. This also applies to overrides through an alias (including flat `kafka_*` settings over nested `kafka.*` keys), through a `SETTINGS` clause of a table engine or table function, and through keys in a dictionary source (checked when the dictionary is created). Resolving a relative `url` stored in a named collection against `s3_base` or `url_base` also counts as an override of `url`. Adding a key that the collection does not store remains allowed, and keys marked `NOT OVERRIDABLE` cannot be overridden. The `allow_named_collection_override_by_default` setting is obsolete. Existing tables whose `SETTINGS` or alias arguments override a `NOT OVERRIDABLE` key cannot be loaded after the upgrade, and the server does not start: before upgrading, recreate such tables without the override, or make the key overridable. [#123133](https://github.com/ClickHouse/ClickHouse/pull/123133) ([Nikita Mikhaylov](https://github.com/nikitamikhaylov)).
* `max_bytes_before_external_join` and `max_bytes_ratio_before_external_join` are now the spill threshold for every hash-based `join_algorithm`, including `grace_hash`, which previously ignored them and spilled on `max_rows_in_join` / `max_bytes_in_join` instead. Those two settings are a hard cap again for every algorithm: they no longer cause spilling, and a join that spills no longer exceeds them. All join algorithms remain available; `join_algorithm = 'grace_hash'` now needs a non-zero spill threshold, and is skipped in favour of the next algorithm in the list when it has none. Set `legacy_join_size_limits_trigger_spilling = 1` (or `compatibility` to 26.8 or older) to restore the previous behavior. [#117356](https://github.com/ClickHouse/ClickHouse/pull/117356) ([Yarik Briukhovetskyi](https://github.com/yariks5s)). [#119335](https://github.com/ClickHouse/ClickHouse/pull/119335) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* `arrayCount` now returns `UInt64` instead of `UInt32`, so it stays exact for arrays with more than 4294967295 matching elements. Set `array_count_legacy_uint32_result = 1` (or `compatibility = '26.9'`) to restore the previous result type. During a rolling upgrade, enable `array_count_legacy_uint32_result` on upgraded servers for the users under which shard-side queries execute, so distributed queries initiated by not-yet-upgraded servers keep the previous behavior on upgraded shards; remove it after the upgrade is complete. In addition, `length(arrayFilter(func, arr))` is now rewritten to `arrayCount(func, arr)`, which is up to 1.29x faster on long arrays, controlled by `optimize_rewrite_array_filter_length_to_array_count`. [#113023](https://github.com/ClickHouse/ClickHouse/pull/113023) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* `accurateCast` from `String` or `FixedString` to a `Nullable` target now throws the error its non-`Nullable` target already raised (`CANNOT_PARSE_TEXT`, `TOO_LARGE_STRING_SIZE`, ...) instead of returning `NULL`, and no longer throws for a row the source marked `NULL`. This affects every use of `accurateCast`: `DeltaLake` writes stop committing an unrepresentable value as `NULL`, `dictGetOrDefault` rejects a default its `Nullable` attribute cannot hold and now converts only the defaults it uses, `IN` under `transform_null_in = 1` no longer matches an unparsable key against a `NULL` in the set, and `cast_ipv4_ipv6_default_on_conversion_error` yields the type's default for an unparsable address. `CAST`, `accurateCastOrNull`, `accurateCastOrDefault`, and ordinary `INSERT` are unchanged, as is what a non-text source does with a value it cannot represent; use `accurateCastOrNull` for the previous behavior. Closes [#120524](https://github.com/ClickHouse/ClickHouse/issues/120524). [#120674](https://github.com/ClickHouse/ClickHouse/pull/120674) ([Groene AI](https://github.com/groeneai)).
* `SELECT ... FINAL` from `SummingMergeTree` no longer removes the rows whose summed columns are all zero, unlike background merges. Before, this removal looked only at the columns the query read, so results depended on them: for example, `SELECT count() FROM table FINAL` could return fewer rows than `SELECT * FROM table FINAL`. Background merges and `OPTIMIZE TABLE ... FINAL` still remove such rows, so filter out the all-zero rows explicitly if a query relied on their removal. [#115032](https://github.com/ClickHouse/ClickHouse/pull/115032) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* A read of a `Distributed` or `Remote` table with `skip_unavailable_shards = 1` now fails with `ALL_CONNECTION_TRIES_FAILED` when every shard was skipped before returning any data, instead of returning an empty result, matching what already happens when the only shard is local. Previously an aggregate without `GROUP BY` silently returned zero rows instead of one. The error fails the whole query, so a query that combines such a read with other data, for example a `UNION ALL` with local rows, no longer returns those rows. When a shard is itself a `Distributed` table whose shards were all skipped, the outer query now fails even if another shard answered; `skip_unavailable_shards_mode = 'unavailable_or_exception_before_processing'` keeps the partial result in that case. No setting restores the previous empty result. Closes [#115646](https://github.com/ClickHouse/ClickHouse/issues/115646). [#115775](https://github.com/ClickHouse/ClickHouse/pull/115775) ([Groene AI](https://github.com/groeneai)).
* A `MATERIALIZED` column computed from a column with a `TTL` is now recomputed when the `TTL` resets that column, both during a merge and in `ALTER TABLE ... MATERIALIZE TTL`. Previously it kept the pre-expiry value forever. If the dependent expression is not defined on the expired column's default (for example `intDiv(100, x)` when `x` expires to `0`), the `TTL` merge now throws instead of writing the stale value; make the expression total on the default (`intDivOrZero`, `if(x = 0, ...)`) if such a table must keep merging. Closes [#117310](https://github.com/ClickHouse/ClickHouse/issues/117310). [#117815](https://github.com/ClickHouse/ClickHouse/pull/117815) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* With `input_format_null_as_default = 0`, a JSON `null` for a non-`Nullable` numeric column now raises an exception instead of being silently stored as `0` (or `nan`), consistent with other types and formats. Keep `input_format_null_as_default` at its default `1` to insert the column default instead. [#122137](https://github.com/ClickHouse/ClickHouse/pull/122137) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* `ALTER TABLE ... ADD COLUMN` and `MODIFY COLUMN` now apply the `data_type_default_nullable` setting the same way `CREATE TABLE` does: with the setting enabled, a column type written without an explicit `NULL` or `NOT NULL` modifier becomes `Nullable`, so the rows that existed before `ADD COLUMN` read `NULL`, `ADD COLUMN x Int32 DEFAULT NULL` is accepted, and `MODIFY COLUMN x Int64` keeps a `Nullable` column `Nullable` instead of failing. As in `CREATE TABLE`, an `Array`, `Map`, `LowCardinality`, or another type that cannot be inside `Nullable` then requires `NOT NULL`, and so does a `MODIFY COLUMN` of a sorting key column. To keep the previous result of such an `ALTER`, write `NOT NULL` explicitly or run it with `data_type_default_nullable = 0`. Closes [#124504](https://github.com/ClickHouse/ClickHouse/issues/124504). [#124597](https://github.com/ClickHouse/ClickHouse/pull/124597) ([Groene AI](https://github.com/groeneai)).
* `arrayJoin` is now lowered to an `ARRAY JOIN` step by default (setting `query_plan_lower_array_join_function`). The expansion streams through the pipeline instead of being materialized inside the projection, filters on the joined elements are applied before the rows are multiplied, and queries with several `arrayJoin` calls no longer build the whole cross product in memory. As a consequence, a non-deterministic function such as `rand` or `generateUUIDv4` next to `arrayJoin` in the same `SELECT` is now evaluated once per output row, as with the `ARRAY JOIN` clause, instead of once per source row. Set `arrayjoin_nondeterministic_functions_before_expansion = 1` (or `compatibility` to 26.9 or older) to keep the previous behavior. [#117882](https://github.com/ClickHouse/ClickHouse/pull/117882) ([Yarik Briukhovetskyi](https://github.com/yariks5s)). [#120390](https://github.com/ClickHouse/ClickHouse/pull/120390) ([Yarik Briukhovetskyi](https://github.com/yariks5s)). [#122240](https://github.com/ClickHouse/ClickHouse/pull/122240) ([Yarik Briukhovetskyi](https://github.com/yariks5s)).
* A function that depends on blocks or row order, such as `runningDifference`, `neighbor` or `rowNumberInBlock`, next to the `arrayJoin` function now sees the blocks of the expansion, like with the `ARRAY JOIN` clause. Set `legacy_array_join_function_nondeterministic_evaluation = 1` to get the previous behavior. [#123143](https://github.com/ClickHouse/ClickHouse/pull/123143) ([Yarik Briukhovetskyi](https://github.com/yariks5s)).
* A row policy on a `Distributed` table (or another table that processes the query itself) read through a `Merge` table now makes queries to the `Merge` table fail with `ILLEGAL_PREWHERE` for the users the policy applies to, like queries to that table itself. Before, the `Merge` table applied such a policy after the table had already sorted, limited and computed `extremes`, so queries could return wrong rows and show values of hidden rows in `extremes`. Define the row policy on the underlying tables of the remote servers and on the local child tables instead. This also fixes `NOT_FOUND_COLUMN_IN_BLOCK` on every query over a `Merge` table whose child has a row policy when the `Merge` table also reads a `Distributed` table. [#125765](https://github.com/ClickHouse/ClickHouse/pull/125765) ([Groene AI](https://github.com/groeneai)).
* `clickhouse-local --ignore-error` now reports a statement that failed at execution instead of skipping it silently: previously it printed no message and no exception code, so a failing multi-statement script looked exactly like a passing one, while `clickhouse-client --ignore-error` reported every error all along. `clickhouse-client` also ignored the option entirely when it was combined with `--interactive` and `--query`/`--queries-file` on a terminal, and now applies it to those queries too. The exit code of `clickhouse-client --ignore-error` changes accordingly: it used to be the code of whichever error the last statement of the batch happened to hit, which made the result depend on the position of the failing statement rather than on the batch as a whole, and it is now a success code, matching what `clickhouse-local --ignore-error` has always returned. Scripts that relied on the old exit code to detect failures should drop `--ignore-error` so that the run stops and fails at the first error, or check the reported errors on `stderr`. [#119572](https://github.com/ClickHouse/ClickHouse/pull/119572) ([Yakov Olkhovskiy](https://github.com/yakov-olkhovskiy)).
* `ATTACH TABLE ... FROM ''` now requires `READ ON FILE` and `WRITE ON FILE` on the source directory in `user_files`, in addition to `CREATE TABLE`, because the query reads the directory and then moves it out of `user_files` on success. Previously a user could attach and read staged data without those `FILE` grants. Grant the corresponding `FILE` privileges to users that rely on this form. [#120582](https://github.com/ClickHouse/ClickHouse/pull/120582) ([Alexander Gololobov](https://github.com/davenger)).
* A `MySQL` dictionary source created with a `CREATE DICTIONARY` query can no longer enable `enable_local_infile`, at the source or at one of its `REPLICA` entries; loading such a dictionary fails with `BAD_ARGUMENTS`, which with the default `dictionaries_lazy_load` is on first use rather than at `CREATE`. A `REPLICA` that does not set the key inherits the source's value, as the connection pool does. To keep the option, define the dictionary in a server configuration file; `enable_local_infile = 0`, and a `SOURCE(MYSQL(NAME ...))` reference to a named collection where the key was never read, are unaffected. [#120972](https://github.com/ClickHouse/ClickHouse/pull/120972) ([Groene AI](https://github.com/groeneai)).
* The definitions of disks in `storage_configuration` and in `disk` are validated: an element that nothing reads is reported as `UNKNOWN_ELEMENT_IN_CONFIG` instead of being silently ignored, which finds typos and options that do not exist for this disk type, such as `path` in an `S3` disk. If a server does not start after the upgrade because of an element it does not know, remove that element from the configuration, or set `1`. [#118440](https://github.com/ClickHouse/ClickHouse/pull/118440) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* `system.*_log` tables can now be configured uniformly via `system_tables.*`. In `system.opentelemetry_span_log`, `finish_date` is renamed to `event_date` and kept as an alias. Aliases are now supported in configured `PARTITION BY`, `ORDER BY`, `TTL`, `PRIMARY KEY`, and `SAMPLE BY` expressions, so custom definitions can continue to use `finish_date`. Some tables now fall back to the default TTL when none is configured, so set `ttl` explicitly if that matters. [#121563](https://github.com/ClickHouse/ClickHouse/pull/121563) ([Azat Khuzhin](https://github.com/azat)). [#125564](https://github.com/ClickHouse/ClickHouse/pull/125564) ([Azat Khuzhin](https://github.com/azat)).
* The setting `validate_mutation_query` is deprecated and ignored: mutation queries (`ALTER TABLE ... UPDATE`, `ALTER TABLE ... DELETE`, `DELETE FROM`) are now always validated before being accepted. It was enabled by default since 24.11, and disabling it did not avoid the failure but only deferred it to the background, where the mutation got stuck and required manual intervention. Setting it to `0` no longer lets an invalid mutation be accepted: it is rejected when submitted. [#121419](https://github.com/ClickHouse/ClickHouse/pull/121419) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Settings `query_plan_read_in_order`, `query_plan_optimize_prewhere`, and `query_plan_aggregation_in_order` are obsolete and no longer have any effect. Use `optimize_read_in_order`, `optimize_aggregation_in_order`, and `optimize_move_to_prewhere` instead. [#121390](https://github.com/ClickHouse/ClickHouse/pull/121390) ([Anton Popov](https://github.com/CurtizJ)).
* The setting `use_compact_format_in_distributed_parts_names` is obsolete. The non-compact directory format for the async `INSERT` queue of a `Distributed` table has been removed. The setting was `1` by default since version 21.1. Before upgrading, set it to `1` and let the queue drain. [#120186](https://github.com/ClickHouse/ClickHouse/pull/120186) ([Alexander Tokmakov](https://github.com/tavplubix)).
* The `MergeTree` settings `use_minimalistic_part_header_in_zookeeper` and `use_minimalistic_checksums_in_zookeeper` are obsolete and have no effect: new data parts of `ReplicatedMergeTree` tables are always stored in ZooKeeper as a single node with the compact header, the default since 20.1. An explicit `0` in table metadata or in the `merge_tree` configuration is ignored, and such tables and configurations still load. Part nodes written in the old format by earlier versions are still read. Closes [#122744](https://github.com/ClickHouse/ClickHouse/issues/122744). [#122790](https://github.com/ClickHouse/ClickHouse/pull/122790) ([Groene AI](https://github.com/groeneai)).
* Settings `s3_max_connections` and the `S3` disk's `max_connections` key are obsolete. They have had no effect since 21.4, when the per-endpoint connection pool of the `S3` client they bounded was removed, but were still documented as limiting the number of connections per server. Both are still accepted and do nothing. To bound the connections to object storage, use the server settings `disk_connections_soft_limit`, `disk_connections_store_limit`, `disk_connections_warn_limit`, and `disk_connections_hard_limit` and their `storage_connections_*` and `http_connections_*` counterparts; to bound the request rate, use `s3_max_get_rps` and `s3_max_put_rps`. [#119550](https://github.com/ClickHouse/ClickHouse/pull/119550) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Removed the zero-argument `year` function. Queries that used `year()` must switch to `toYear(today())` instead. [#120268](https://github.com/ClickHouse/ClickHouse/pull/120268) ([Robert Schulze](https://github.com/rschu1ze)).
* Removed the `system.codecs.is_experimental` column. Queries that filtered or selected it should use `tier = 'Experimental'` instead. [#118523](https://github.com/ClickHouse/ClickHouse/pull/118523) ([Raufs Dunamalijevs](https://github.com/rienath)).
* Removed the experimental function `detectTonality`. Queries that use it now fail with `UNKNOWN_FUNCTION`. [#123327](https://github.com/ClickHouse/ClickHouse/pull/123327) ([Groene AI](https://github.com/groeneai)).
* Update the `zxc` library to v0.14.0, which changes the compressed block format of the experimental `ZXC` codec. Data written with `CODEC(ZXC)` by earlier versions cannot be read by the new version and fails with `CANNOT_DECOMPRESS`. If you used the experimental `ZXC` codec, re-encode the affected columns to a different codec before upgrading, or re-insert the data after the upgrade. [#119097](https://github.com/ClickHouse/ClickHouse/pull/119097) ([Actuele AI](https://github.com/actueleai)).
* An aggregate function state that serializes to zero bytes cannot be read back, so the two parameterizations that produced one are now rejected: a `-Resample` combinator over an empty range (`begin >= end`, such as `countResample(10, 5, 1)`) throws `ARGUMENT_OUT_OF_BOUND`, and `covarSampMatrix`, `covarPopMatrix`, and `corrMatrix` with no arguments throw `NUMBER_OF_ARGUMENTS_DOESNT_MATCH`. Both returned an empty array before. No serialized format changes, but a table with such a column no longer loads. Before upgrading, drop the column where the engine supports `DROP COLUMN`, and the whole table where it does not (`Log`, `TinyLog`, `StripeLog`, `Set`, `Join`, `File`). [#119728](https://github.com/ClickHouse/ClickHouse/pull/119728) ([Groene AI](https://github.com/groeneai)).
* A data type naming the state of a function that only works as a window function, such as `AggregateFunction(rank)`, is now rejected with `BAD_ARGUMENTS`: such a state has no serialization, so the column could never hold a value. This applies wherever a type is named, including inside `Array`, `Map`, `Tuple`, and another state's argument list. A table that already stores such a column will no longer attach after the upgrade; drop or rewrite the column before upgrading. [#122148](https://github.com/ClickHouse/ClickHouse/pull/122148) ([Groene AI](https://github.com/groeneai)).
* `rankState` and every other `-State` of a function that only works as a window function, such as `denseRankStateIf` or `initializeAggregation('lagInFrameState', x)`, are now rejected with `BAD_ARGUMENTS` when the query is analyzed, also where the state is never computed (`toTypeName`, `EXPLAIN`, a column the outer query drops), and so is such a type in a binary-encoded `Native` header. Computing such a state always failed, but a view or `CREATE TABLE ... AS SELECT` could still store its type. A table whose engine expressions build such a state, for example in a sorting key, partition key, skip index, or `TTL`, no longer attaches. [#122463](https://github.com/ClickHouse/ClickHouse/pull/122463) ([Groene AI](https://github.com/groeneai)).
* `CREATE TABLE` and full-definition `ATTACH TABLE` now refuse a `CONSTRAINT` name declared more than once, and `ALTER TABLE ... ADD CONSTRAINT` / `MODIFY CONSTRAINT` now refuse an expression containing `arrayJoin` even when the command would install nothing. A table already stored with a repeated constraint name still attaches and keeps enforcing each of its declarations; give each constraint a unique name in new definitions. [#121235](https://github.com/ClickHouse/ClickHouse/pull/121235) ([Groene AI](https://github.com/groeneai)).
* The `Remote`, `RemoteSecure`, and `Cluster` database engines now reject an empty remote database name with `BAD_ARGUMENTS` instead of creating a database that lists and reads no tables. A server that holds such a database, created by an earlier version, does not start after the upgrade, so drop these databases before upgrading. Closes [#122616](https://github.com/ClickHouse/ClickHouse/issues/122616). [#122675](https://github.com/ClickHouse/ClickHouse/pull/122675) ([Groene AI](https://github.com/groeneai)).
* Connections to MySQL (the `mysql` table function, the `MySQL` table and database engines, and `MySQL` dictionaries) that set `ssl_ca` or `ssl_ca_pem` now verify the server certificate chain and host name, after updating `mariadb-connector-c` to v3.4.10. Previously the CA was not enforced, so a connection to a server whose certificate is signed by another CA, or whose certificate does not list the host name or IP address used to connect, succeeded and now fails with `self-signed certificate in certificate chain` or `Hostname verification failed`. Before upgrading, make sure the configured CA signs the MySQL server certificate and that the certificate lists the host name or IP address ClickHouse connects to. [#119510](https://github.com/ClickHouse/ClickHouse/pull/119510) ([Actuele AI](https://github.com/actueleai)).
#### New Feature
* Sets built for `IN` with a subquery or a table now spill to disk by default once query memory usage exceeds half the available memory under the applicable server or user memory limit, calculated at the start of execution (`max_bytes_ratio_before_external_set = 0.5`). The `max_bytes_before_external_set` setting can set an absolute threshold (`max_memory_usage` is not taken into account by the ratio, so use it to spill before that limit is reached), and setting both thresholds to `0` keeps sets in memory. This feature is now generally available. [#123860](https://github.com/ClickHouse/ClickHouse/pull/123860) ([Nihal Z. Miaji](https://github.com/nihalzp)). [#124907](https://github.com/ClickHouse/ClickHouse/pull/124907) ([Nihal Z. Miaji](https://github.com/nihalzp)).
* Support parts of the Trino SQL dialect in regular ClickHouse SQL: `TRY_CAST(x AS T)`, the `ARRAY[...]` array constructor, the type names `ARRAY(T)` and `MAP(K, V)`, and aliases for Trino functions such as `starts_with`, `slice`, `regexp_like`, `day_of_week`, `url_extract_host`, `bitwise_and`, `arbitrary`, and `bool_and`. [#124763](https://github.com/ClickHouse/ClickHouse/pull/124763) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Implemented a generic block nested loop join algorithm. `JOIN` now supports an arbitrary `ON` condition with no equality between the two tables, executing it as a block nested loop join, as slow as a `CROSS JOIN` with a filter, instead of failing with `INVALID_JOIN_ON_EXPRESSION`. The new setting `allow_block_nested_loop_join` turns it on/off. [#123642](https://github.com/ClickHouse/ClickHouse/pull/123642) ([Alexey Milovidov](https://github.com/alexey-milovidov)). [#123792](https://github.com/ClickHouse/ClickHouse/pull/123792) ([Groene AI](https://github.com/groeneai)).
* Added the function-composition operator `f | g` and the argument placeholders `_`, `_1`, `_2`, ...: for example, `arrayMap(plus(_, 1) | multiply(_, 2), [1, 2, 3])` returns `[4, 6, 8]`. A composition can be used wherever a function is expected, including as an argument of a higher-order function. The operands can be lambdas, function names, nested compositions, or expressions with placeholders, which also work on their own, for example `arrayMap(_1 * 2 + 1, [1, 2, 3])`. The composition is resolved at query analysis time into an ordinary lambda. Note that `|` here is not bitwise OR; use `bitOr` for that. [#116029](https://github.com/ClickHouse/ClickHouse/pull/116029) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* The query cache can now store its entries on disk, backed by a preconfigured filesystem cache: this gives the entries more space, makes them survive server restarts, and, with a distributed filesystem cache, provides a way to share them between servers. Select the filesystem cache with the new setting `query_cache_on_disk_cache_name`; see also the new settings `query_cache_on_disk_codec`, `enable_writes_to_query_cache_on_disk`, and `enable_reads_from_query_cache_on_disk`. Closes [#115361](https://github.com/ClickHouse/ClickHouse/issues/115361). [#115382](https://github.com/ClickHouse/ClickHouse/pull/115382) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Added a notebook mode to the Web UI (`/play`). After a query is run, a `[+]` button under the result adds further cells, each either a query with its own result or a block of Markdown text, turning the tab into a notebook in the style of Jupyter or Observable. Cells can be run, reordered, inserted and deleted individually; the query editor collapses to a single line when it is not focused, results are bounded and scroll inside themselves, and the whole notebook is restored on reload. Notebook mode is per tab, so a tab that has only one cell looks and behaves exactly as before. [#115378](https://github.com/ClickHouse/ClickHouse/pull/115378) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Added support for reading and writing data in the `SQLite` format. [#104510](https://github.com/ClickHouse/ClickHouse/pull/104510) ([Yue Ni](https://github.com/niyue)).
* Added the `Cluster` database engine, which provides real-time access to the tables of a configured cluster database and forwards `SELECT` and `INSERT` queries to it. [#114417](https://github.com/ClickHouse/ClickHouse/pull/114417) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Added the `Overlay` database engine: `CREATE DATABASE db ENGINE = Overlay(db1, db2, ...)` exposes the union of the tables of existing databases, each table working as an `Alias` table to the table of the first source database that has it. [#121878](https://github.com/ClickHouse/ClickHouse/pull/121878) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* `CREATE DATABASE` and `ATTACH DATABASE` now accept a `SETTINGS` clause without an explicit `ENGINE` clause, defaulting to `Atomic`, so a database can define its metadata disk inline the same way a single table does. A single `SETTINGS` clause can now also mix database-engine settings with ordinary query settings. [#118423](https://github.com/ClickHouse/ClickHouse/pull/118423) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* `MergeTree` tables in `Ordinary` databases can now be converted to `ReplicatedMergeTree` with `ATTACH TABLE ... AS REPLICATED` or the `convert_to_replicated` flag. [#118757](https://github.com/ClickHouse/ClickHouse/pull/118757) ([Kirill](https://github.com/kirillgarbar)).
* Added query-aware scheduling in workloads: the new workload setting `scheduler` selects how queries of a workload are scheduled — `fifo` (default), `fair` (weighted fair queueing with per-query weights that can be lowered as a query runs), `las` (least-attained-service), or `priority` (by the query setting `workload_priority`). The leaf-node `type` in `system.scheduler` is now `request_queue` instead of `fifo`. [#116800](https://github.com/ClickHouse/ClickHouse/pull/116800) ([Sergei Trifonov](https://github.com/serxa)).
* Queries can now spill to disk under memory pressure based on limits set per workload. The `max_memory_before_spill` and `max_memory_to_spill_ratio` options of `WORKLOAD` define a soft memory limit that triggers spilling for `ORDER BY`, `GROUP BY`, `IN`, `DISTINCT`, and `JOIN` with `grace_hash`. [#119443](https://github.com/ClickHouse/ClickHouse/pull/119443) ([Azat Khuzhin](https://github.com/azat)).
* Quotas can now limit the number of rows written by `INSERT` queries with the new `written_rows` resource, for example `CREATE QUOTA q KEYED BY ip_address FOR INTERVAL 1 minute MAX written_rows = 100000, query_inserts = 250 TO user`. Until now only the written bytes could be limited (`written_bytes`), which is awkward when the natural unit of the workload is rows. The current and maximum values are exposed as `written_rows` and `max_written_rows` in `system.quota_usage`, `system.quotas_usage`, and `system.quota_limits`, and the resource can also be set in `users.xml` as ``. [#118272](https://github.com/ClickHouse/ClickHouse/pull/118272) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Added the settings `max_temporary_tables`, `max_temporary_table_memory_usage`, `max_temporary_table_size_bytes_compressed`, and `max_temporary_table_size_bytes_uncompressed` to limit the number of temporary tables in a session, the memory usage of `Memory` temporary tables, and the size of `MergeTree` temporary tables. [#122165](https://github.com/ClickHouse/ClickHouse/pull/122165) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Added the SQL-standard `SIMILAR TO` pattern-matching predicate. [#101514](https://github.com/ClickHouse/ClickHouse/pull/101514) ([Zhao Zheguang](https://github.com/zheguang)).
* Allow `MATERIALIZED` common table expressions inside recursive `WITH`. A materialized helper CTE is evaluated once and every recursive step reads the snapshot, instead of the subquery being re-evaluated on each iteration. The recursive CTE itself still cannot be materialized. [#123452](https://github.com/ClickHouse/ClickHouse/pull/123452) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Query parameters can now be used for primary `USER` and `ROLE` names in `CREATE`, `ALTER`, and `DROP`, and for role and grantee names in `GRANT` and `REVOKE`, for example `GRANT {role:Identifier} TO {user:Identifier}`. [#109696](https://github.com/ClickHouse/ClickHouse/pull/109696) ([Pervakov Grigorii](https://github.com/GrigoryPervakov)).
* `SET DEFAULT ROLE` now accepts an `ON CLUSTER` clause, in either position: `SET DEFAULT ROLE role1 TO user ON CLUSTER my_cluster` and `SET DEFAULT ROLE ON CLUSTER my_cluster role1 TO user`. `CURRENT_USER` is resolved on the initiator before the query is distributed. `SET ROLE` only affects the current session and still takes no `ON CLUSTER` clause. [#118429](https://github.com/ClickHouse/ClickHouse/pull/118429) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Added `CREATE OR REPLACE NAMED COLLECTION ...` to replace an existing named collection entirely. [#121569](https://github.com/ClickHouse/ClickHouse/pull/121569) ([Pervakov Grigorii](https://github.com/GrigoryPervakov)).
* The `postgresql` table function and the `PostgreSQL` table engine can now connect to another ClickHouse server over the PostgreSQL protocol. The `query(...)` variant still needs an explicit column list. Added the PostgreSQL-compatibility functions `format_type` and `current_setting`. Also fixed cancellation over the PostgreSQL protocol: a cancel request never cancelled anything. [#112940](https://github.com/ClickHouse/ClickHouse/pull/112940) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Disks with the `plain_rewritable` metadata (`s3_plain_rewritable`, and `azure`/`local` object storages with `metadata_type = plain_rewritable`) support hard links if configured with the new `enable_hard_links` setting, which enables `ALTER` operations and mutations on `MergeTree` tables stored on them. Mutations and partition operations share the unchanged blobs between parts instead of copying them. The setting is off by default, because a disk that has hard links cannot be read by older servers. [#110939](https://github.com/ClickHouse/ClickHouse/pull/110939) ([yanglongwei](https://github.com/ylw510)). [#119304](https://github.com/ClickHouse/ClickHouse/pull/119304) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Added `EXCEPT DATA FROM TABLE` / `EXCEPT DATA FROM TABLES` clauses to `BACKUP` queries, so a table's definition can be backed up without its rows, for any table engine that supports backups. Formatting now quotes keyword table names correctly in `EXCEPT DATA FROM TABLES`, so `BACKUP ... ON CLUSTER` round-trips through the formatter. Closes [#111827](https://github.com/ClickHouse/ClickHouse/issues/111827). [#111895](https://github.com/ClickHouse/ClickHouse/pull/111895) ([Aditya Kumar](https://github.com/adityaksolves)). [#122468](https://github.com/ClickHouse/ClickHouse/pull/122468) ([David Meng](https://github.com/davidmenggx)).
* Added five columns to `system.query_log` describing what a query really executed: `used_number_of_joins`, `used_join_algorithms`, `used_join_kinds`, `used_join_strictness`, and `spilled_to_disk`. This makes it possible to find problematic `JOIN` patterns and queries that fall back to external memory across a fleet without reproducing each query. A spilling `SELECT DISTINCT` now records `distinct` in `spilled_to_disk` instead of `[]`, and a spilling block nested loop join records `join`. [#113833](https://github.com/ClickHouse/ClickHouse/pull/113833) ([Matheus Nerone](https://github.com/Manerone)). [#121830](https://github.com/ClickHouse/ClickHouse/pull/121830) ([Groene AI](https://github.com/groeneai)). [#124681](https://github.com/ClickHouse/ClickHouse/pull/124681) ([David Meng](https://github.com/davidmenggx)).
* Added table function `traceView` that renders an OpenTelemetry trace from `system.opentelemetry_span_log` as a call tree with a per-span timeline bar, for debugging where the time of a traced, for example distributed, query was spent. It has a `host` column with the `hostname` of the server that recorded each span, so the spans of the initiator, remote shards, replicas, and stateless workers can be distinguished and filtered with `WHERE host = ...`. [#116325](https://github.com/ClickHouse/ClickHouse/pull/116325) ([Diego Gomes Tomé](https://github.com/diegomestre2)). [#122169](https://github.com/ClickHouse/ClickHouse/pull/122169) ([Diego Gomes Tomé](https://github.com/diegomestre2)). [#123528](https://github.com/ClickHouse/ClickHouse/pull/123528) ([Diego Gomes Tomé](https://github.com/diegomestre2)).
* `clickhouse-client --login` can now authenticate against arbitrary OAuth/OIDC identity providers via endpoint discovery, with explicit endpoint and scope overrides and improved RFC 8628 device-code handling. On Linux desktops it now also passes the client's environment to `xdg-open` when opening the identity-provider login page, so the system browser is detected correctly. Closes [#120127](https://github.com/ClickHouse/ClickHouse/issues/120127). [#110718](https://github.com/ClickHouse/ClickHouse/pull/110718) ([yanglongwei](https://github.com/ylw510)). [#121337](https://github.com/ClickHouse/ClickHouse/pull/121337) ([Konstantin Bogdanov](https://github.com/thevar1able)).
* Added interactive client commands `/dialect`, `/lang`, and `/language` to `clickhouse-client` and `clickhouse-local`, so you can switch the active SQL dialect before parsing, including when the current dialect cannot express a `SET` query, for example to leave `kusto` or `promql`. The current non-default dialect is now shown in the prompt, and `SET dialect = ...` keeps the prompt in sync. [#114568](https://github.com/ClickHouse/ClickHouse/pull/114568) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* `chdig` [v26.10.1](https://github.com/azat/chdig/releases/tag/v26.10.1): ZooKeeper browser, per-host summary, and better filters. [#124100](https://github.com/ClickHouse/ClickHouse/pull/124100) ([Azat Khuzhin](https://github.com/azat)).
* Support reading the `Parquet` `VARIANT` type (unshredded, as written for example by Spark 4.0) into `Dynamic`, with object values read as `JSON`. A variant column can also be read directly as `JSON` if all its values are objects. Shredded variants are not supported yet. [#117106](https://github.com/ClickHouse/ClickHouse/pull/117106) ([Konstantin Vedernikov](https://github.com/scanhex12)).
* Support the `variant` type of `Iceberg`. Based on the `Parquet` variant reader in [#117106](https://github.com/ClickHouse/ClickHouse/pull/117106). [#117198](https://github.com/ClickHouse/ClickHouse/pull/117198) ([Konstantin Vedernikov](https://github.com/scanhex12)). [#125458](https://github.com/ClickHouse/ClickHouse/pull/125458) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Support the `Parquet` `FILE` logical type (a reference to bytes stored inline or in an external file): it is read as a named `Tuple`, and can be written from a `Tuple` with the corresponding element names with the new setting `output_format_parquet_write_file_logical_type`. [#125132](https://github.com/ClickHouse/ClickHouse/pull/125132) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Lazy type hints for the `JSON` type are now generally available under the `enable_json_lazy_type_hints` setting. The setting remains disabled by default. [#122711](https://github.com/ClickHouse/ClickHouse/pull/122711) ([Pavel Kruglov](https://github.com/Avogar)).
* Add a new input format `Freeform`, which does schema inference for arbitrary tabular text files. Closes [#34006](https://github.com/ClickHouse/ClickHouse/issues/34006). [#43449](https://github.com/ClickHouse/ClickHouse/pull/43449) ([Tri Dao](https://github.com/dmtri35)).
* The `generateRandom` table function and the `GenerateRandom` table engine now support `JSON`, `Dynamic`, `Variant`, `BFloat16`, `Time`, and `Time64`. Generated `JSON` documents have a realistic schema derived from the seed. The new settings `null_ratio`, `max_json_depth`, and `max_json_keys_per_object` control the share of nulls and absent keys, the nesting depth, and the number of keys per object. Generation respects memory limits. `CREATE TABLE ... AS generateRandom(...)` also keeps the `SETTINGS` argument in the stored definition. [#107966](https://github.com/ClickHouse/ClickHouse/pull/107966) ([apst41](https://github.com/apst41)). [#124772](https://github.com/ClickHouse/ClickHouse/pull/124772) ([Vadim Lopatin](https://github.com/buggins)). [#123247](https://github.com/ClickHouse/ClickHouse/pull/123247) ([Raúl Marín](https://github.com/Algunenano)).
* Add the `obfuscate` table function for generating anonymized query results. [#115004](https://github.com/ClickHouse/ClickHouse/pull/115004) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Text indexes with the `keyValuePairs` tokenizer now answer `map['key'] IN ('value1', 'value2')` directly from the index, as they already did for `map['key'] = 'value'`. Added the function `mapContainsKeyValue(map, key, value)`, which returns whether a map contains an entry with the given key and value; in contrast to `map[key] = value`, all entries of a repeated key are considered, and such an index evaluates the function directly. The `mergeTreeTextIndex` table function returns the decoded parts of each token of such an index in the columns `token_key` and `token_value`. [#120244](https://github.com/ClickHouse/ClickHouse/pull/120244) ([Jimmy Aguilar Mena](https://github.com/Ergus)). [#120010](https://github.com/ClickHouse/ClickHouse/pull/120010) ([Jimmy Aguilar Mena](https://github.com/Ergus)). [#120183](https://github.com/ClickHouse/ClickHouse/pull/120183) ([Anton Popov](https://github.com/CurtizJ)).
* The `mergeTreeTextIndex` table function now returns posting lists and token positions for a text index in the new virtual columns `row_id` and `positions`. If one of them is selected, the function returns a row per posting. The `positions` column is available for indexes created with `support_phrase_search = 1`. [#125536](https://github.com/ClickHouse/ClickHouse/pull/125536) ([Anton Popov](https://github.com/CurtizJ)).
* Added `mapRemove`, which removes all entries with a specified key from a map, and `mapEntries`, which returns a map's entries as an array of key-value tuples. [#123322](https://github.com/ClickHouse/ClickHouse/pull/123322) ([Minh Vu](https://github.com/fallintoplace)). [#123344](https://github.com/ClickHouse/ClickHouse/pull/123344) ([Minh Vu](https://github.com/fallintoplace)).
* The `-Map` combinator can now be used with non-`Map` columns (the key is passed as the last argument, e.g. `sumMap(value, key)`) and supports aggregate functions with multiple arguments, e.g. `argMaxMap(arg, val, key)`. [#123449](https://github.com/ClickHouse/ClickHouse/pull/123449) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* The aggregate functions `avg`, `sum`, `sumWithOverflow`, and `sumKahan` now support the `Interval` data types. The result is an interval of the same unit. [#121458](https://github.com/ClickHouse/ClickHouse/pull/121458) ([Alexey Milovidov](https://github.com/alexey-milovidov)). [#121600](https://github.com/ClickHouse/ClickHouse/pull/121600) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* The linear regression aggregate functions can now also be called under ClickHouse-style names: `regrSlope`, `regrIntercept`, `regrR2`, `regrCount`, `regrAvgX`, `regrAvgY`, `regrSXX`, `regrSYY`, and `regrSXY`. [#119796](https://github.com/ClickHouse/ClickHouse/pull/119796) ([mosya415](https://github.com/mosya415)).
* Added the `arrayMinIndex` and `arrayMaxIndex` array functions. [#120097](https://github.com/ClickHouse/ClickHouse/pull/120097) ([Minh Vu](https://github.com/fallintoplace)). [#123686](https://github.com/ClickHouse/ClickHouse/pull/123686) ([Minh Vu](https://github.com/fallintoplace)).
* Added the `arrayRemoveAt` array function. [#120445](https://github.com/ClickHouse/ClickHouse/pull/120445) ([Minh Vu](https://github.com/fallintoplace)).
* Added higher-order array functions to pack bits: `arrayPackBitsToUInt64`, `arrayPackBitsToString`, `arrayPackBitsToFixedString`, `arrayPackBitGroupsToUInt64`, `arrayPackBitGroupsToString`, and `arrayPackBitGroupsToFixedString`. [#123478](https://github.com/ClickHouse/ClickHouse/pull/123478) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Added SQL functions `normalizedQueryHashUnordered` and `normalizedQueryHashUnorderedOrNull`. Unlike `normalizedQueryHash`, they ignore the order of expression lists such as the `SELECT` list, `GROUP BY` keys, and function arguments, so logically equivalent queries can collapse to one pattern in `query_log`; the `OrNull` variant returns `NULL` instead of throwing when the input is not valid ClickHouse SQL in the current session. [#116345](https://github.com/ClickHouse/ClickHouse/pull/116345) ([Yarik Briukhovetskyi](https://github.com/yariks5s)).
* Add functions `encodeQuotedPrintable` and `decodeQuotedPrintable` for Quoted-Printable encoding (RFC 2045), commonly used in email. [#125454](https://github.com/ClickHouse/ClickHouse/pull/125454) ([Jay Pokale](https://github.com/JayPokale)).
* Added the `sql_compatible_division_for_integers` setting, disabled by default, to make `/` and `divide` return integer quotients truncated toward zero when both operands are integers. It supports integer types up to 256 bits and checks division by zero and result overflow; division involving `Decimal` or floating-point operands is unchanged. [#124490](https://github.com/ClickHouse/ClickHouse/pull/124490) ([Ilya Yatsishin](https://github.com/qoega)).
* Added `SYSTEM RESET FILELOG [db.]table [FILE 'file_name' [OFFSET n | TO END]]`: a `FileLog` table reads all its files again from the beginning, or one file from the beginning, from a given offset, or only from data appended after the command, without recreating the table. Requires the new `SYSTEM RESET FILELOG` privilege. [#123545](https://github.com/ClickHouse/ClickHouse/pull/123545) ([Groene AI](https://github.com/groeneai)).
* The `FileLog` table engine now accepts globs (`*`, `?`, `{a,b}`, `{N..M}`) in the file name of its path, for example `FileLog('/var/lib/clickhouse/user_files/my_app/*.log', 'JSONEachRow')`, and reads only the matching files of that directory, so the compressed files `logrotate` leaves next to the log are not read. A file that is already read keeps being read after it is renamed to a non-matching name, such as `app.log` rotated to `app.log.1`. [#123590](https://github.com/ClickHouse/ClickHouse/pull/123590) ([Groene AI](https://github.com/groeneai)).
* Added the `flat_namespaces` setting to the `DataLakeCatalog` database engine. Set it for `Iceberg` REST catalogs that have only single-level namespaces and reject the `parent` query parameter of the list-namespaces endpoint, such as Apache Polaris federated to AWS Glue: only top-level namespaces are then listed and sub-namespaces are not requested. [#117329](https://github.com/ClickHouse/ClickHouse/pull/117329) ([Konstantin Vedernikov](https://github.com/scanhex12)).
* Added the ClickHouse Keeper `ListWithOptions` operation for filtered direct or recursive listing with optional stats, data, limits, and shuffled results. [#117521](https://github.com/ClickHouse/ClickHouse/pull/117521) ([Antonio Andelic](https://github.com/antonio2368)).
* Added the `MergeTree` setting `min_unreserved_disk_space_for_merge`: background merge selection subtracts the specified amount from the unreserved disk space, so large merges stop being selected before they can take the last free space and starve inserts. Unlike `keep_free_space_bytes`, the protected space remains usable by ClickHouse itself. [#115723](https://github.com/ClickHouse/ClickHouse/pull/115723) ([Valery Petrov](https://github.com/valerypetrov)).
* You can now disable reading through the `executable` table function and from `Executable`/`ExecutablePool` tables with the new `allow_executable_tables` setting, for a deployment that must not run arbitrary server-side scripts. It defaults to `true`, so existing behavior is unchanged. [#120713](https://github.com/ClickHouse/ClickHouse/pull/120713) ([Hanzi Jiang](https://github.com/HanziJiang)).
* Added server setting `ai_function_allow_sql_named_collections`. When disabled, AI functions accept only named collections defined in the server configuration file. [#124999](https://github.com/ClickHouse/ClickHouse/pull/124999) ([George Larionov](https://github.com/george-larionov)).
* Added `` and `` settings to restrict which TLS 1.3 cipher suites a TLS port negotiates. Without them, `cipherList` controls only TLS 1.2 and below. An absent or empty value keeps the OpenSSL defaults. Closes [#119929](https://github.com/ClickHouse/ClickHouse/issues/119929). [#120480](https://github.com/ClickHouse/ClickHouse/pull/120480) ([Groene AI](https://github.com/groeneai)).
* You can now set a custom syslog program name for ClickHouse logs using `logger.syslog.programname`, making it easier to distinguish multiple ClickHouse instances in syslog. The default syslog identifier is now command-specific: remote syslog previously sent `-` as the RFC 5424 `APP-NAME` and now sends the command name (for example `clickhouse-server`), and the multi-purpose binary started as `clickhouse server` or `clickhouse keeper` now uses `clickhouse-server` / `clickhouse-keeper` instead of `clickhouse` for local syslog. [#98789](https://github.com/ClickHouse/ClickHouse/pull/98789) ([François Martin](https://github.com/martinfrancois)).
* Added the `Copy` event and the `source_bucket` and `source_remote_path` columns to `system.blob_storage_log` for server-side object copies (S3 `CopyObject` and `UploadPartCopy`, Azure Blob Storage copies). Azure backups, restores, and `AzureQueue` moves now write to `system.blob_storage_log` too. Closes [#123163](https://github.com/ClickHouse/ClickHouse/issues/123163). [#123178](https://github.com/ClickHouse/ClickHouse/pull/123178) ([Groene AI](https://github.com/groeneai)).
* Added an `is_lazy` column to `system.dictionaries`. It shows whether each dictionary loads on first use, taking into account both its `dictionary_lazy_load` setting and the server setting `dictionaries_lazy_load`. This makes it possible to tell a lazy dictionary that has not been used yet from an eager one that has not been loaded yet; both show `NOT_LOADED`. [#124260](https://github.com/ClickHouse/ClickHouse/pull/124260) ([Miсhael Stetsyuk](https://github.com/mstetsyuk)).
* Added the `replica_group` column to `system.clusters`. For clusters that belong to a `Replicated` database, it shows the replica group of each node as published from the server configuration `replica_group_name`, or its alias `role`. [#120537](https://github.com/ClickHouse/ClickHouse/pull/120537) ([RinChanNOW](https://github.com/RinChanNOWWW)).
* Added `SYSTEM DISABLE ALL FAILPOINTS`, which disables every fail point at once and resumes any thread blocked on a pauseable one. [#118877](https://github.com/ClickHouse/ClickHouse/pull/118877) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
#### Experimental Feature
* Added an experimental columns cache that keeps deserialized columns of wide `MergeTree` parts in memory, one entry per stripe of granules of a column. Compared with the uncompressed cache, this saves time on deserialization and copying. It is enabled by the experimental setting `use_columns_cache`, with `enable_reads_from_columns_cache` and `enable_writes_to_columns_cache` as beta sub-settings, and it applies to tables in databases that assign UUIDs (`Atomic` and `Replicated`). The cache gives its memory back to queries when the server is short of it. [#96844](https://github.com/ClickHouse/ClickHouse/pull/96844) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Added experimental `LATERAL JOIN` support, allowing correlated subqueries in the `FROM` clause. This enables the standard SQL pattern for "top N per group" and per-row aggregation queries. Controlled by the `allow_experimental_lateral_join` setting. [#97833](https://github.com/ClickHouse/ClickHouse/pull/97833) ([Dimitri König](https://github.com/dimitri-koenig)).
* Added an experimental `logsql` dialect: LogsQL, the log query language of VictoriaLogs, can now be used to query ClickHouse tables with logs. Enable it with `SET enable_logsql_dialect = 1, logsql_table = '
', dialect = 'logsql'` (plus `logsql_database`, `logsql_time_column`, and `logsql_message_column` as needed). LogsQL queries are translated at parse time into ordinary `SELECT` queries, so text filters expect `String`-backed log columns, while the `math` pipe applies raw arithmetic and needs numeric operand columns (`String` field values are not coerced to numbers). [#113207](https://github.com/ClickHouse/ClickHouse/pull/113207) ([Alexey Milovidov](https://github.com/alexey-milovidov)). [#123891](https://github.com/ClickHouse/ClickHouse/pull/123891) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Added the beta `PCO` compression codec for fixed-width numeric columns, based on the [pcodec](https://github.com/pcodec/pcodec) library. Enable it with `enable_pco_codec = 1`. [#110613](https://github.com/ClickHouse/ClickHouse/pull/110613) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Added a new implementation of the `unity` catalog type in the `DataLakeCatalog` database engine. It serves both `DeltaLake` and `Iceberg` tables from a single Unity Catalog, detecting the format of each table and routing `Iceberg` tables through the Unity Catalog `Iceberg` REST endpoint. Enable it with the database setting `use_unity_catalog_v2`, or set the session setting of the same name before `CREATE DATABASE`. Switch an existing database with `ALTER DATABASE ... MODIFY SETTING use_unity_catalog_v2 = 1`. [#115879](https://github.com/ClickHouse/ClickHouse/pull/115879) ([Asya Shneerson](https://github.com/asya-ch)).
* Added an experimental embedded `Iceberg` REST catalog server with ClickHouse HTTP authentication. It supports `GET /v1/config`, listing, creating, and checking the existence of namespaces, stored either in memory or in `Keeper`, and listing, creating, loading, checking the existence of, and dropping tables, with their metadata files stored in `S3`. The catalog can also serve TLS via `secure_port`, using the certificate and key in `openSSL.server`, and correctly handles `/` in table and namespace names. Closes [#125762](https://github.com/ClickHouse/ClickHouse/issues/125762). [#118924](https://github.com/ClickHouse/ClickHouse/pull/118924) ([Asya Shneerson](https://github.com/asya-ch)). [#123000](https://github.com/ClickHouse/ClickHouse/pull/123000) ([Asya Shneerson](https://github.com/asya-ch)). [#123331](https://github.com/ClickHouse/ClickHouse/pull/123331) ([Asya Shneerson](https://github.com/asya-ch)). [#124978](https://github.com/ClickHouse/ClickHouse/pull/124978) ([Asya Shneerson](https://github.com/asya-ch)). [#125791](https://github.com/ClickHouse/ClickHouse/pull/125791) ([Groene AI](https://github.com/groeneai)).
* Added experimental XGBoost dictionaries: the `XGBOOST` layout trains a gradient-boosted model from the source table at load time, and `predictXGBoost` runs inference. Enable it with `enable_xgboost`. Available only in builds that include the XGBoost contrib library. [#109999](https://github.com/ClickHouse/ClickHouse/pull/109999) ([Matheus Nerone](https://github.com/Manerone)).
* Added `ipcryptEncrypt`, `ipcryptDecrypt`, `ipcryptPrefixEncrypt` and `ipcryptPrefixDecrypt` functions for format-preserving encryption of IP addresses following the [IPCrypt specification](https://ipcrypt-std.github.io/). The deterministic mode produces consistent output for deduplication, while the prefix-preserving mode maintains subnet relationships. Enable with `SET enable_ipcrypt = 1`. Contributed by Frank Denis. [#123680](https://github.com/ClickHouse/ClickHouse/pull/123680) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Added read support for `Iceberg` v3 deletion vectors stored in `Puffin` files. [#110781](https://github.com/ClickHouse/ClickHouse/pull/110781) ([linjiayu1025-collab](https://github.com/linjiayu1025-collab)).
* Added experimental support for `ALTER TABLE ... DROP PARTITION` on standalone `Iceberg` tables and `Iceberg` REST catalogs. On standalone tables, the operation currently requires `Iceberg` format-version 2 with a single non-evolved partition spec. Old date-transform spellings in the partition expression are now evaluated with the `Iceberg` transform semantics too. [#111219](https://github.com/ClickHouse/ClickHouse/pull/111219) ([Den Kalantaevskii](https://github.com/Diskein)). [#123273](https://github.com/ClickHouse/ClickHouse/pull/123273) ([Groene AI](https://github.com/groeneai)). [#122269](https://github.com/ClickHouse/ClickHouse/pull/122269) ([Den Kalantaevskii](https://github.com/Diskein)).
* `parallel_replicas_plan_based` can now distribute queries with an `IN (subquery)` predicate instead of falling back to single-node execution. Closes [#111876](https://github.com/ClickHouse/ClickHouse/issues/111876). [#114086](https://github.com/ClickHouse/ClickHouse/pull/114086) ([Igor Nikonov](https://github.com/devcrafter)).
* With `parallel_replicas_plan_based` enabled, distributed `INSERT ... SELECT` again uses distributed execution when `parallel_distributed_insert_select = 2`, instead of running the `SELECT` on the initiator alone. Closes [#118276](https://github.com/ClickHouse/ClickHouse/issues/118276). [#121097](https://github.com/ClickHouse/ClickHouse/pull/121097) ([Igor Nikonov](https://github.com/devcrafter)).
* Distributed query plans built with `make_distributed_plan` now compress exchanged data with `network_compression_method`; for `ZSTD`, they also use `network_zstd_compression_level` instead of the server's default codec settings. [#120333](https://github.com/ClickHouse/ClickHouse/pull/120333) ([Alexander Gololobov](https://github.com/davenger)).
* Queries executed with the experimental `make_distributed_plan` setting now propagate the OpenTelemetry trace context to stateless workers via the `traceparent` and `tracestate` HTTP headers of the task dispatch request. Each dispatched task produces a `StatelessWorkerClient::sendTask` span on the initiator plus `InterserverIOHTTPHandler` and `DistributedPlanTask::execute` spans on the worker, with the task id, initial query id, plan hash, and exchange streams as attributes, so the whole distributed plan is visible as one trace in `system.opentelemetry_span_log`. [#119010](https://github.com/ClickHouse/ClickHouse/pull/119010) ([Diego Gomes Tomé](https://github.com/diegomestre2)).
* Join runtime filters can now travel across distributed query plan stages with the experimental setting `distributed_plan_join_runtime_filters` (default off). Build-side tasks send partial filters to probe-side scans before their shuffle exchange, reducing the number of rows crossing the network. A filter that is lost, late, or never built cannot change results. [#114822](https://github.com/ClickHouse/ClickHouse/pull/114822) ([Harikrishnan Prabakaran](https://github.com/harikrishnan94)).
* Distributed index analysis is now beta. [#123577](https://github.com/ClickHouse/ClickHouse/pull/123577) ([Azat Khuzhin](https://github.com/azat)).
* Added the experimental setting `enable_join_seal_gated_reading` (default off). When enabled together with `enable_join_runtime_filters` and the probe-side join key is a prefix of the table's primary key, the probe side of a hash `JOIN` starts reading only after the build side completes, and the completed runtime filter prunes whole mark ranges by the primary key before read tasks are created, instead of only filtering rows after they were read. [#113512](https://github.com/ClickHouse/ClickHouse/pull/113512) ([Nikolai Kochetov](https://github.com/KochetovNicolai)).
* Replaced the experimental settings `query_plan_optimize_join_order_use_conflict_detector_a` and `query_plan_optimize_join_order_use_conflict_detector_c` with `query_plan_optimize_join_order_conflict_detector`, which takes `a`, `c`, or `''` (the default). [#120630](https://github.com/ClickHouse/ClickHouse/pull/120630) ([Fisnik Kastrati](https://github.com/fkastrati)).
* Adaptive codec selection (`enable_adaptive_codec_selection`) also tries each specialized codec followed by the table's default codec, and makes merges of `Float32` and `Float64` columns faster. [#121630](https://github.com/ClickHouse/ClickHouse/pull/121630) ([Raufs Dunamalijevs](https://github.com/rienath)). [#122248](https://github.com/ClickHouse/ClickHouse/pull/122248) ([Raufs Dunamalijevs](https://github.com/rienath)).
* Added the setting `json_extract_named_tuples_as_objects` (default off): when enabled, the `JSONExtract` functions fill named tuples from JSON objects only. By default a JSON array fills a named tuple positionally, so which element lands in which field depends on the order the fields were declared in. [#122637](https://github.com/ClickHouse/ClickHouse/pull/122637) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Experimental `UNIQUE KEY` SST probes now batch lookups with `MultiGet`, so absent keys can be filtered by the SST bloom filter. More unsupported `UNIQUE KEY` operations are now rejected early. [#119997](https://github.com/ClickHouse/ClickHouse/pull/119997) ([johnjing](https://github.com/JingYanchao)). [#123002](https://github.com/ClickHouse/ClickHouse/pull/123002) ([Murphy](https://github.com/murphy-4o)).
* The experimental reader executor (`use_reader_executor = 1`) now plans filesystem cache reads ahead over a window set by `reader_executor_plan_look_ahead` instead of re-checking the cache on every read window. It also no longer fails spuriously with `CANNOT_READ_ALL_DATA` when a concurrent download advances the filesystem cache during a cold read. [#115816](https://github.com/ClickHouse/ClickHouse/pull/115816) ([Sema Checherinda](https://github.com/CheSema)). [#122214](https://github.com/ClickHouse/ClickHouse/pull/122214) ([Sema Checherinda](https://github.com/CheSema)).
* Streaming queries now prefer a `commit_order` projection when one is available for the current read round. [#120420](https://github.com/ClickHouse/ClickHouse/pull/120420) ([Mikhail Artemenko](https://github.com/Michicosun)).
* PromQL again supports the range functions `present_over_time`, `absent_over_time`, `quantile_over_time`, and `predict_linear`, and now also supports `stddev_over_time`, `stdvar_over_time`, `first_over_time`, `ts_of_first_over_time`, `ts_of_last_over_time`, and `mad_over_time`. [#112355](https://github.com/ClickHouse/ClickHouse/pull/112355) ([Valery Petrov](https://github.com/valerypetrov)). [#120352](https://github.com/ClickHouse/ClickHouse/pull/120352) ([Vitaly Baranov](https://github.com/vitlibar)). [#121578](https://github.com/ClickHouse/ClickHouse/pull/121578) ([Vitaly Baranov](https://github.com/vitlibar)). [#121800](https://github.com/ClickHouse/ClickHouse/pull/121800) ([Vitaly Baranov](https://github.com/vitlibar)).
* Added PromQL functions `min_of` and `max_of` to return the smaller or larger of two scalar values. [#121250](https://github.com/ClickHouse/ClickHouse/pull/121250) ([Minh Vu](https://github.com/fallintoplace)).
* PromQL now implements `timestamp` for both direct selectors and general expressions, matching Prometheus 3.5.0 semantics. [#112356](https://github.com/ClickHouse/ClickHouse/pull/112356) ([Valery Petrov](https://github.com/valerypetrov)).
* Support standalone PromQL `step` and `range` scalar functions. The PromQL parser now also accepts bare calls to `start`, `end`, `sort_by_label`, `sort_by_label_desc`, `double_exponential_smoothing`, and `limit_ratio`, so these not yet implemented functions are rejected after parsing instead of failing with a parse error. [#121118](https://github.com/ClickHouse/ClickHouse/pull/121118) ([Minh Vu](https://github.com/fallintoplace)). [#123589](https://github.com/ClickHouse/ClickHouse/pull/123589) ([James Cunningham](https://github.com/JTCunning)).
* `prometheusQuery` now always returns `Float64` values and `DateTime64` timestamps with at least millisecond precision. The time zone of the returned timestamps comes from its `DateTime` or `DateTime64` arguments when they agree, and otherwise from the table. [#120285](https://github.com/ClickHouse/ClickHouse/pull/120285) ([Vitaly Baranov](https://github.com/vitlibar)).
* PromQL now treats Prometheus stale markers as absent in instant selectors and omits them from range selectors. [#121098](https://github.com/ClickHouse/ClickHouse/pull/121098) ([Minh Vu](https://github.com/fallintoplace)).
* PromQL now rejects queries that use the same label in both `on(...)` and `group_left(...)` or `group_right(...)`. [#114376](https://github.com/ClickHouse/ClickHouse/pull/114376) ([Minh Vu](https://github.com/fallintoplace)).
* PromQL now rejects vector selectors whose matchers can all match the empty string. [#121099](https://github.com/ClickHouse/ClickHouse/pull/121099) ([Minh Vu](https://github.com/fallintoplace)).
* PromQL's `stddev` and `stdvar` now return `NaN` instead of `0`. [#122743](https://github.com/ClickHouse/ClickHouse/pull/122743) ([James Cunningham](https://github.com/JTCunning)).
* PromQL now returns `NaN` from date functions when the sample is not finite. [#124300](https://github.com/ClickHouse/ClickHouse/pull/124300) ([James Cunningham](https://github.com/JTCunning)).
* PromQL no longer fails on empty joins. [#124362](https://github.com/ClickHouse/ClickHouse/pull/124362) ([James Cunningham](https://github.com/JTCunning)).
* Aligned PromQL string and comment parsing with Prometheus: quoted strings cannot contain a line feed, and a line comment can end at the end of the query without a space after `#`. Closes [#117812](https://github.com/ClickHouse/ClickHouse/issues/117812). [#124584](https://github.com/ClickHouse/ClickHouse/pull/124584) ([Vitaly Baranov](https://github.com/vitlibar)).
* PromQL range functions over scalars now handle windows with no samples without failing on `NULL`, including when used in nested range functions. [#124586](https://github.com/ClickHouse/ClickHouse/pull/124586) ([Vitaly Baranov](https://github.com/vitlibar)).
* Added deduplication caches for `TimeSeries` metric families and tags, and fixed stale cache entries when the pending rows are full. [#121915](https://github.com/ClickHouse/ClickHouse/pull/121915) ([Vitaly Baranov](https://github.com/vitlibar)). [#122771](https://github.com/ClickHouse/ClickHouse/pull/122771) ([Vitaly Baranov](https://github.com/vitlibar)).
* The `tags` inner table of the `TimeSeries` table engine is split into a `tags` table without `min_time` and `max_time` and a separate table of time ranges. [#121924](https://github.com/ClickHouse/ClickHouse/pull/121924) ([Vitaly Baranov](https://github.com/vitlibar)).
* The inner tables of the `TimeSeries` table engine now use the outer column name `metric_family` instead of `metric_family_name`. [#119226](https://github.com/ClickHouse/ClickHouse/pull/119226) ([Vitaly Baranov](https://github.com/vitlibar)).
* Fixed `ALIAS_REQUIRED` for a join with a `VIEW` written without an alias under the experimental setting `analyzer_inline_views = 1`: the inlined subquery now keeps the view's name as a table expression name, so it needs no alias and stays usable as a column qualifier, with or without the database name. [#118401](https://github.com/ClickHouse/ClickHouse/pull/118401) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Reading subcolumns of the experimental `Quantized` codec (`vec.quantized`, `vec.product_quantization_codebook`) through a `Merge` table no longer breaks when another child table of the `Merge` lacks the base column. [#123895](https://github.com/ClickHouse/ClickHouse/pull/123895) ([Groene AI](https://github.com/groeneai)).
#### Performance Improvement
* Large hash tables used for `GROUP BY`, `uniqExact`, and `JOIN` now use up to two times less memory, and aggregation with many keys is faster on many threads. [#125001](https://github.com/ClickHouse/ClickHouse/pull/125001) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* The query condition cache now serves conditions that involve the current time, e.g. `WHERE time >= now() - INTERVAL 10 DAY`, when reading from `MergeTree` tables, by deriving a deterministic condition from them with the current-time constant rounded onto a time grid. Closes [#115504](https://github.com/ClickHouse/ClickHouse/issues/115504). [#115522](https://github.com/ClickHouse/ClickHouse/pull/115522) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Enabled the setting `apply_string_filters_during_scan` by default. Substring search conditions on `String` columns (`LIKE`, `position`, `startsWith`, `endsWith`) from `PREWHERE` are pushed down into the column scan, and non-matching values are read as empty strings without copying their data. This makes such queries faster and lowers their memory usage when reading from `MergeTree` tables and from `Parquet` pages whose string values use the `PLAIN`, `DELTA_LENGTH_BYTE_ARRAY`, `DELTA_BYTE_ARRAY`, or dictionary encodings, including reads using the uncompressed cache on object storage. [#115848](https://github.com/ClickHouse/ClickHouse/pull/115848) ([Alexey Milovidov](https://github.com/alexey-milovidov)). [#124503](https://github.com/ClickHouse/ClickHouse/pull/124503) ([Alexey Milovidov](https://github.com/alexey-milovidov)). [#125079](https://github.com/ClickHouse/ClickHouse/pull/125079) ([Groene AI](https://github.com/groeneai)). [#124507](https://github.com/ClickHouse/ClickHouse/pull/124507) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Queries `GROUP BY key LIMIT n` and `GROUP BY key ORDER BY key LIMIT n` over `MergeTree` tables now read much less data: the aggregation publishes the boundary of its top-K heap to the reading step, which drops rows beyond it before reading the other columns and can skip whole granules through the primary key or a `minmax` skip index. Controlled by the new setting `enable_group_by_top_k_dynamic_filtering`. The same primary-key granule skipping now also applies to `ORDER BY column LIMIT n` when the column is in the primary key. [#121145](https://github.com/ClickHouse/ClickHouse/pull/121145) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Queries with `ORDER BY LIMIT n` over `Parquet` files now use TopN dynamic filtering with `use_top_k_dynamic_filtering`: rows that cannot enter the top-K are filtered inside the reader before the remaining columns are read, and whole row groups are skipped when their min/max statistics prove they cannot contribute. This works through the `file` and `url` table functions, the `File` and `URL` engines, object storage (`s3`, `Azure`, `HDFS`), and data lake tables such as `Iceberg`. Floating-point sort columns are excluded for now. [#115798](https://github.com/ClickHouse/ClickHouse/pull/115798) ([Alexey Milovidov](https://github.com/alexey-milovidov)). [#122109](https://github.com/ClickHouse/ClickHouse/pull/122109) ([Alexey Milovidov](https://github.com/alexey-milovidov)). [#124861](https://github.com/ClickHouse/ClickHouse/pull/124861) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* `query_plan_join_shard_by_pk_ranges` is enabled by default. A `full_sorting_merge` or `parallel_full_sorting_merge` `JOIN` of two `MergeTree` tables whose join keys contain a prefix of the primary key of both tables now runs as independent streaming merge joins over primary-key ranges on all threads instead of a single-threaded merge join, several times faster and with several times less memory in our tests. Hash joins are affected only when both join runtime filters and spilling to disk are disabled. Set `query_plan_join_shard_by_pk_ranges = 0` to restore the previous behavior. [#117856](https://github.com/ClickHouse/ClickHouse/pull/117856) ([Alexey Milovidov](https://github.com/alexey-milovidov)). [#119925](https://github.com/ClickHouse/ClickHouse/pull/119925) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Enabled the text-index postings cache by default with `use_text_index_postings_cache`. On a 1B-row table, a four-token phrase query that previously recomputed posting lists and phrase-search results within one query went from 19 s to 0.12 s. The shared cache is bounded by `text_index_postings_cache_size` (2 GiB by default). [#120677](https://github.com/ClickHouse/ClickHouse/pull/120677) ([Nikita Fomichev](https://github.com/fm4v)). [#123228](https://github.com/ClickHouse/ClickHouse/pull/123228) ([Anton Popov](https://github.com/CurtizJ)).
* With `optimize_aggregation_in_order = 1`, or with the default `optimize_distinct_in_order = 1`, a `GROUP BY` or `DISTINCT` whose keys extend past the table's sorting key no longer re-packs the whole block's grouping key once per run of equal sorting-key values. That cost was quadratic in `max_block_size` once the sorting prefix is near-unique, so `GROUP BY a, b` on a table sorted by `a` is up to 130x faster. Closes [#45386](https://github.com/ClickHouse/ClickHouse/issues/45386). [#120259](https://github.com/ClickHouse/ClickHouse/pull/120259) ([Groene AI](https://github.com/groeneai)).
* Blocks sent back by remote replicas are now marshalled in parallel (`enable_parallel_blocks_marshalling`) when `parallel_replicas_plan_based` is enabled. [#121642](https://github.com/ClickHouse/ClickHouse/pull/121642) ([Igor Nikonov](https://github.com/devcrafter)).
* `GROUP BY` with a `Nullable` key now uses the adaptive aggregator, except when that key is the only one and is a number of up to 8 bytes, a `String`, or a `FixedString`, or when any key is `LowCardinality`. Schema inference makes such keys common in CSV, JSON, and `Parquet` files; high-cardinality aggregations over them become up to 2x faster with up to 2.2x less memory. [#124868](https://github.com/ClickHouse/ClickHouse/pull/124868) ([Groene AI](https://github.com/groeneai)).
* Queries over `Nullable` columns now use the same optimizations as over non-`Nullable` ones: `length`, `empty`, `notEmpty`, and comparisons with an empty string on `Nullable(String)` read the `size` subcolumn, `sum(x + c)` is rewritten to `sum(x) + c * count(x)`, and `uniqExact` over `Nullable` is merged in parallel. Some queries become several times faster. [#125011](https://github.com/ClickHouse/ClickHouse/pull/125011) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* The trivial `GROUP BY ... LIMIT n` optimization (setting `optimize_trivial_group_by_limit_query`) now also applies to queries with aggregate functions in the projection when the `GROUP BY` top-K optimization does not apply, for example above `query_plan_max_limit_for_top_k_optimization`: once any aggregation thread exceeds `n + offset` distinct keys, all threads are restricted to a single shared set of kept keys, so the hash tables stay small while the aggregate values of the returned keys remain exact, with up to 7-9x speedups. The optimization no longer fires for queries with `DISTINCT`, `QUALIFY`, `LIMIT AFTER`, `LIMIT UNTIL`, window functions, `arrayJoin`, or `exact_rows_before_limit`, where it could return wrong or inexact results. [#114690](https://github.com/ClickHouse/ClickHouse/pull/114690) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* When `max_threads` is not set explicitly, a query is planned with the fair share of CPU slots of the concurrency control instead of all CPU cores. This increases the throughput and lowers the memory usage under many concurrent queries, while a query on an idle server still uses all cores. It can be disabled with the setting `use_concurrency_control_for_max_threads`. [#125085](https://github.com/ClickHouse/ClickHouse/pull/125085) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* A single-level `GROUP BY` result smaller than `max_block_size` is now split into several blocks when it was aggregated by several threads, so the steps after it, such as the probe of a following join, run in parallel instead of on one thread. Previously such queries could be several times slower, most visibly under `compatibility` older than 26.8, which disables `enable_parallel_single_level_merge` and `enable_adaptive_aggregator`. The result of a `GROUP BY` on a single 8- or 16-bit integer key is split the same way. [#121711](https://github.com/ClickHouse/ClickHouse/pull/121711) ([Pratham Nayak](https://github.com/protomn)).
* Restored the batched hash-and-prefetch insert path for `uniq`, `uniqCombined`, and `uniqCombined64` in ordinary `GROUP BY` queries, where they had silently fallen back to a per-row loop and were up to 46% slower. Closes [#120531](https://github.com/ClickHouse/ClickHouse/issues/120531). [#120578](https://github.com/ClickHouse/ClickHouse/pull/120578) ([Groene AI](https://github.com/groeneai)).
* Faster `GROUP BY` over keys that have to be serialized, such as several columns that include a `String`. [#122857](https://github.com/ClickHouse/ClickHouse/pull/122857) ([Samuel Krempaský](https://github.com/NIKTONIKTO717)).
* `GROUP BY` over multiple `LowCardinality` keys now serializes the keys from the per-block dictionaries instead of copying them into full columns first, reducing CPU time and memory usage of aggregation queries over `LowCardinality` dimensions. [#121795](https://github.com/ClickHouse/ClickHouse/pull/121795) ([artemkulyk](https://github.com/artemkulyk)).
* Speed up `GROUP BY` over several `LowCardinality` keys when the same key tuples repeat, by caching aggregate states per tuple of dictionary positions in the serialized aggregation method. [#121998](https://github.com/ClickHouse/ClickHouse/pull/121998) ([artemkulyk](https://github.com/artemkulyk)).
* `GROUP BY` over a single `String` column with only `count` is faster when the grouping state does not fit in the CPU cache, especially with long strings. [#123655](https://github.com/ClickHouse/ClickHouse/pull/123655) ([Groene AI](https://github.com/groeneai)).
* `GROUP BY` queries with many groups that end in `ORDER BY count() ... LIMIT n` and use no other aggregate function are slightly faster when they group by a `String` column or by several columns. [#124277](https://github.com/ClickHouse/ClickHouse/pull/124277) ([Groene AI](https://github.com/groeneai)).
* Share the `GROUP BY` top-K skip boundary between aggregation threads. [#116150](https://github.com/ClickHouse/ClickHouse/pull/116150) ([Konstantin Bogdanov](https://github.com/thevar1able)).
* Allow using fused `GROUP BY` top-K with a serialized query plan. [#116163](https://github.com/ClickHouse/ClickHouse/pull/116163) ([Konstantin Bogdanov](https://github.com/thevar1able)).
* Added a query-plan optimization, controlled by the new setting `query_plan_aggregation_having_prefilter`, for `HAVING count() ` over a `GROUP BY`. While a two-level bucket of the aggregation result is converted to chunks, a group whose `count()` cannot satisfy the bound is now skipped before its key columns are materialized, instead of being materialized and then discarded by the filter above. This speeds up "groups above a threshold" queries over a high-cardinality `GROUP BY` with wide keys, where the discarded keys are most of the conversion. A skipped group is neither filtered nor finalized, so a `HAVING` conjunct written before the bound, and a sibling aggregate's finalization, stop being evaluated on the groups the bound rejects: a query that raised an exception from one of those can now return rows instead. Setting `query_plan_aggregation_having_prefilter = 0`, or `compatibility` to a version below `26.10`, keeps the previous behavior. [#120510](https://github.com/ClickHouse/ClickHouse/pull/120510) ([Groene AI](https://github.com/groeneai)).
* `optimize_aggregators_of_group_by_keys` now works for `LowCardinality` `GROUP BY` keys, so a `HAVING` predicate such as `HAVING min(s) = 'x'` is pushed down to storage and can use skip indexes, as for a plain key. It also eliminates `anyHeavy`, `quantileExact`, `quantileExactLow`, `quantileExactHigh`, `groupBitAnd`, and `groupBitOr` of a `GROUP BY` key. [#110059](https://github.com/ClickHouse/ClickHouse/pull/110059) ([Groene AI](https://github.com/groeneai)).
* `-If` aggregate functions with one `Nullable` argument no longer allocate a buffer the size of the whole block for every group with `optimize_aggregation_in_order` or for every window frame. With small groups or frames this makes them 1.7 to 3.1 times faster on x86_64. [#122505](https://github.com/ClickHouse/ClickHouse/pull/122505) ([Groene AI](https://github.com/groeneai)).
* Speed up `-ForEach` aggregate functions such as `sumForEach` and `avgForEach`: rows are processed in batches instead of calling `add` for each row, and an array of two or more elements is passed to the nested function in one call instead of one call per element. Grouped multi-argument `-If` aggregate functions with a `Nullable` argument or condition are also processed in batches. [#121137](https://github.com/ClickHouse/ClickHouse/pull/121137) ([Valery Petrov](https://github.com/valerypetrov)). [#124207](https://github.com/ClickHouse/ClickHouse/pull/124207) ([Groene AI](https://github.com/groeneai)).
* Speed up serialization of `AggregateFunction` state columns with a fixed-size state, such as `sum`, `count`, `avg`, `min`, `max`, and `any`, and their `-If`, `-Array`, `-Merge`, and `Nullable` variants. This affects writes to `AggregatingMergeTree`, the `Native` format, distributed queries, and spilling aggregate states to disk. [#113962](https://github.com/ClickHouse/ClickHouse/pull/113962) ([Manuel](https://github.com/raimannma)).
* Speed up reading and merging of `uniq` aggregate function states, such as `uniqMerge` over an `AggregatingMergeTree`, by 10-35% depending on state sizes and merge shape. [#111493](https://github.com/ClickHouse/ClickHouse/pull/111493) ([Manuel](https://github.com/raimannma)).
* Faster merging of `uniqCombined` and `uniqCombined64` states with many distinct values into empty states, e.g. in `-Merge` combinators and `AggregatingMergeTree`: up to 6x faster. [#124389](https://github.com/ClickHouse/ClickHouse/pull/124389) ([Manuel](https://github.com/raimannma)).
* Reduce memory usage and improve performance of external `DISTINCT` by avoiding spills for duplicate-heavy input, writing smaller spill blocks, budgeting tail spilling before the final merge, preserving constant payloads, combining chunks before sorting, and retaining fewer rows while restoring order with `LIMIT`. [#121772](https://github.com/ClickHouse/ClickHouse/pull/121772) ([Nihal Z. Miaji](https://github.com/nihalzp)).
* Faster sorted-stream processing on a multi-column key whose leading column has long runs, in `LIMIT BY`, negative `LIMIT BY`, `DISTINCT` in order, `full_sorting_merge` and `partial_merge` `JOIN`, and `ReplacingMergeTree` `FINAL` without vertical `FINAL`: the run of a key prefix is now found once instead of again for every group in it. The query from [#123700](https://github.com/ClickHouse/ClickHouse/issues/123700) is about 3.5x faster. [#123808](https://github.com/ClickHouse/ClickHouse/pull/123808) ([Groene AI](https://github.com/groeneai)).
* Short queries with many keyed aggregations or scalar subqueries over large constant-folded literals are faster because hash-table-stats cache keys no longer hash whole variable-size constant values. [#122738](https://github.com/ClickHouse/ClickHouse/pull/122738) ([Nikita Taranov](https://github.com/nickitat)).
* Reduce memory usage of some window functions by precomputing peer-group boundaries instead of keeping earlier blocks in memory. [#123737](https://github.com/ClickHouse/ClickHouse/pull/123737) ([Mikhail Artemenko](https://github.com/Michicosun)).
* A filter on the `PARTITION BY` columns of a window function is no longer pushed below the window (this reverts [#110114](https://github.com/ClickHouse/ClickHouse/pull/110114)). The push-down made queries up to 8 times slower when the window reads a `JOIN` and the filter removes every row, for example `IN` over an empty subquery, because the join built its right side before the filter could stop the query. Closes [#123875](https://github.com/ClickHouse/ClickHouse/issues/123875). [#125463](https://github.com/ClickHouse/ClickHouse/pull/125463) ([Groene AI](https://github.com/groeneai)).
* `hash` and `parallel_hash` joins now copy right-side output columns directly from the stored blocks instead of calling the stored column object once per row. This speeds up every column type, including `String`, `Array`, `Tuple`, `Nullable`, `Variant`, `Map`, `LowCardinality`, `JSON`, `Dynamic`, `AggregateFunction`, and `QBit`. [#117460](https://github.com/ClickHouse/ClickHouse/pull/117460) ([Harikrishnan Prabakaran](https://github.com/harikrishnan94)).
* Speed up hash join output construction in the row-major layout: output reconstruction is up to 2x faster for joins with many rows per key and about 1.5x for wide or `Nullable` payloads. The row-major layout is now also skipped for payloads too narrow to benefit from it. [#121981](https://github.com/ClickHouse/ClickHouse/pull/121981) ([Hechem Selmi](https://github.com/m-selmi)).
* Hash joins with many matches per key are faster when they output a `LowCardinality` column whose blocks have different dictionaries (several parts, `FINAL`, or a `LowCardinality` value computed per block): short ranges from another dictionary are now inserted key by key instead of through temporary columns. Such joins run 4-9x faster, at the 26.6 level or better. [#123900](https://github.com/ClickHouse/ClickHouse/pull/123900) ([Groene AI](https://github.com/groeneai)).
* `RIGHT` and `FULL` joins using `hash`, `parallel_hash`, or `grace_hash` skip the search for unmatched right rows when every right key has matched. With 50 million right keys, that search was about 10% of query time for `hash` (356 ms of 3.6 s) and about 15% for `parallel_hash` (106 ms of 0.7 s). [#124775](https://github.com/ClickHouse/ClickHouse/pull/124775) ([Groene AI](https://github.com/groeneai)).
* A `full_sorting_merge` join now advertises that its result is ordered by the join key, so a sort above it, the pre-sort of the next merge join in a chain or an `ORDER BY`, merges the already sorted streams instead of sorting from scratch. Joining several tables on the same key with `full_sorting_merge` no longer performs one full sort per join. Also fixed the interplay with `query_plan_join_shard_by_pk_ranges`, which could otherwise fail with a logical error or return wrong results for such a chain. [#117786](https://github.com/ClickHouse/ClickHouse/pull/117786) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* A join step that has a condition of its own now also joins on equalities implied through other tables, so for `a.x = b.x AND b.x = c.x`, joining `a` with `c` also uses `a.x = c.x`. With `query_plan_optimize_join_order_algorithm = 'dpsize'`, this makes TPC-H Q02 join its correlated subquery to `partsupp` on the part key instead of on the supply cost alone. Closes [#122396](https://github.com/ClickHouse/ClickHouse/issues/122396). [#122445](https://github.com/ClickHouse/ClickHouse/pull/122445) ([Groene AI](https://github.com/groeneai)).
* A `WHERE` condition that no row satisfies is pushed to every `JOIN` input again, including the non-preserved side of an `OUTER JOIN` and a side with no column used above the join, so that input is no longer read and hash-built for nothing. For example, a `UNION ALL` branch whose constant column fails the outer `WHERE` is skipped as in 26.6. Closes [#123702](https://github.com/ClickHouse/ClickHouse/issues/123702). Closes [#123878](https://github.com/ClickHouse/ClickHouse/issues/123878). [#123829](https://github.com/ClickHouse/ClickHouse/pull/123829) ([Groene AI](https://github.com/groeneai)).
* Constant comparison, logical, and null (`IS NULL` / `IS NOT NULL`) filters over materialized constants are now folded and pushed down, reducing unnecessary reads in `WHERE`, `PREWHERE`, and `UNION` branches. Always-true `WHERE` filters are replaced with expressions so join reordering still sees all joined tables as one graph. [#105987](https://github.com/ClickHouse/ClickHouse/pull/105987) ([Yarik Briukhovetskyi](https://github.com/yariks5s)). [#124056](https://github.com/ClickHouse/ClickHouse/pull/124056) ([Yarik Briukhovetskyi](https://github.com/yariks5s)).
* `OUTER JOIN` queries can now be faster: when a `WHERE` clause or another `JOIN` later in the query would discard the unmatched rows anyway, ClickHouse converts the join to an `INNER JOIN`. The new setting `query_plan_convert_outer_join_to_inner_join_transitively` controls this, and only takes effect when `query_plan_convert_outer_join_to_inner_join` is enabled. [#120253](https://github.com/ClickHouse/ClickHouse/pull/120253) ([Hechem Selmi](https://github.com/m-selmi)).
* Restored filter push-down over `ANY INNER JOIN`, so primary-key pruning works again and such queries no longer read much more data than necessary. Because `ANY` keeps an arbitrary matching row, `SELECT ... ANY INNER JOIN ... WHERE ...` can now return a different matching row than before. [#120765](https://github.com/ClickHouse/ClickHouse/pull/120765) ([Kirill Shokhin](https://github.com/kirillshokhin)).
* `optimize_and_compare_chain` again derives transitive conditions through a `DateTime` or lower-scale `DateTime64` constant compared with a `DateTime64` expression, as it did before 26.8. For example, `t1.ts < toDateTime('2026-09-16 00:00:00') AND t1.ts >= t2.ts` adds `t2.ts < toDateTime('2026-09-16 00:00:00')`, so the other side of a join can be pruned by its partition and primary key instead of being read in full. Closes [#123706](https://github.com/ClickHouse/ClickHouse/issues/123706). [#123796](https://github.com/ClickHouse/ClickHouse/pull/123796) ([Groene AI](https://github.com/groeneai)).
* Improve join order selection when column statistics are missing: an equi join without NDV statistics is now treated more like a foreign-key-to-primary-key join instead of a cross product, and the greedy join-order algorithm prefers equi-connected pairs over pairs linked only by non-equi predicates. [#120176](https://github.com/ClickHouse/ClickHouse/pull/120176) ([Vladimir Cherkasov](https://github.com/vdimir)). [#121075](https://github.com/ClickHouse/ClickHouse/pull/121075) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Improves `JOIN` cardinality estimation by propagating join-key distinct-value estimates according to join semantics. Outer joins retain the preserved-side estimate, anti joins keep their input estimates, and semi joins narrow only the output side, preventing underestimation that could lead to suboptimal query plans. [#122305](https://github.com/ClickHouse/ClickHouse/pull/122305) ([Christoph Viebig](https://github.com/cv4g)).
* `IEJoin` now treats opposite-direction conditions on unrelated columns as independent conditions instead of as a band, which avoids choosing a join-key pair that passes thousands of times more rows to the residual condition. [#120213](https://github.com/ClickHouse/ClickHouse/pull/120213) ([Vladimir Cherkasov](https://github.com/vdimir)).
* Function `firstNonDefault`, which computes the `USING` columns of `FULL JOIN`, now copies whole ranges of rows instead of making two virtual calls per row. Queries that use a `USING` column of a `FULL JOIN` after the join, for example in `WHERE`, are faster. [#123302](https://github.com/ClickHouse/ClickHouse/pull/123302) ([Groene AI](https://github.com/groeneai)).
* Enabled `enable_join_runtime_filters_index_analysis` by default, so join runtime filters can prune granules during the probe phase. [#121859](https://github.com/ClickHouse/ClickHouse/pull/121859) ([Robert Schulze](https://github.com/rschu1ze)).
* Join runtime filters now run after the query's own `PREWHERE` conditions also for tables without column statistics, as they already did with statistics. Before, a runtime filter on a well-compressed join key could run first and read that key for every row, so enabling `enable_join_runtime_filters` could make a query read several times more data than without it. [#122452](https://github.com/ClickHouse/ClickHouse/pull/122452) ([Groene AI](https://github.com/groeneai)).
* The granule pruning of `enable_join_runtime_filters_index_analysis` now also applies when the left side of a `JOIN` is read from a normal projection. The setting description states that the pruning does not happen with parallel replicas, a distributed query plan, or `FINAL`. [#119041](https://github.com/ClickHouse/ClickHouse/pull/119041) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* The query condition cache now records the static `WHERE` conditions of a join whose `PREWHERE` also holds a join runtime filter, so a repeated join skips the granules those conditions exclude instead of reading them again. This helps whenever the runtime filter cannot skip those granules through an index itself, for example when no primary key or skip index covers the join key, or when `enable_join_runtime_filters_index_analysis` is disabled. [#122380](https://github.com/ClickHouse/ClickHouse/pull/122380) ([Groene AI](https://github.com/groeneai)).
* Repeated insertion of empty and single-element `Array` values into in-memory columns is now faster. This happens, for example, during joins. [#117321](https://github.com/ClickHouse/ClickHouse/pull/117321) ([Minh Vu](https://github.com/fallintoplace)).
* With `use_top_k_dynamic_filtering = 1` (the default), a `SELECT ... ORDER BY ... LIMIT n` could read far more data than with the setting off: the internal `__topKFilter` took over the read's `PREWHERE` slot and displaced the query's own condition, and an explicit `PREWHERE` disabled the feature outright. The threshold filter now shares `PREWHERE` with the other conditions and takes the first slot. It is also no longer installed on a read that a sorting projection already delivers in `ORDER BY` order, where it forced a full scan. [#117968](https://github.com/ClickHouse/ClickHouse/pull/117968) ([Groene AI](https://github.com/groeneai)).
* Granules fully filtered by the dynamic threshold of an `ORDER BY ... LIMIT n` read are now recorded in the query condition cache, so repeat runs of such queries skip them at the mark-selection stage instead of re-reading and re-filtering most of the table. On the ClickBench Q24/Q26 shapes (`SELECT SearchPhrase FROM hits WHERE SearchPhrase <> '' ORDER BY EventTime LIMIT 10`), a warm run drops from about 95 million rows / 12000 granules read to about 1.3 million rows / 160 granules, and from about 15-30 ms to about 8 ms on a 96-core machine. This now also works for `ORDER BY ... LIMIT n` queries over `Parquet` files of `File` tables, with or without a `WHERE` clause: a repeated query reads only the row groups which can hold rows of its result. [#114659](https://github.com/ClickHouse/ClickHouse/pull/114659) ([Alexey Milovidov](https://github.com/alexey-milovidov)). [#122064](https://github.com/ClickHouse/ClickHouse/pull/122064) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Improve performance of `ORDER BY ... LIMIT` queries that use minmax-index top-K pruning (`use_skip_indexes_for_top_k`) on large tables with many granules. [#116512](https://github.com/ClickHouse/ClickHouse/pull/116512) ([Anton Popov](https://github.com/CurtizJ)).
* Queries with `FINAL` that sort in reverse order of the sorting key, such as `SELECT ... FROM t FINAL ORDER BY key DESC LIMIT n`, now read in order through `Merge` tables over `ReplacingMergeTree` tables too, and the `topKThroughJoin` optimization defers to reverse-order reads below a `LEFT JOIN` when the table supports them. This extends [#115345](https://github.com/ClickHouse/ClickHouse/pull/115345). [#118008](https://github.com/ClickHouse/ClickHouse/pull/118008) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed a performance regression in `ORDER BY` merge sort: queries with a sort followed by `LIMIT` no longer do redundant per-output-block work in result-block reservation. [#108179](https://github.com/ClickHouse/ClickHouse/pull/108179) ([Groene AI](https://github.com/groeneai)).
* Setting `optimize_move_to_prewhere_if_final` is now enabled by default, so queries with `FINAL` benefit from the automatic `PREWHERE` optimization. Only deterministic conditions over the sorting key are moved, and query results are not affected. [#121350](https://github.com/ClickHouse/ClickHouse/pull/121350) ([Yarik Briukhovetskyi](https://github.com/yariks5s)).
* With short-circuit evaluation, non-throwing arguments of `and` and `or` are now ordered by measured cost and selectivity, so cheap filters can avoid evaluating expensive expressions on excluded rows. Controlled by `short_circuit_function_evaluation_reorder_arguments`, enabled by default. [#122508](https://github.com/ClickHouse/ClickHouse/pull/122508) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fix a performance regression in short-circuit evaluation of `and` and `or` by avoiding expansion of intermediate results that are only used to update the logical mask. [#120520](https://github.com/ClickHouse/ClickHouse/pull/120520) ([LB7666](https://github.com/acking-you)).
* On a table with no applicable data skipping index, a query no longer stores the same predicate under two query condition cache keys. This halves the number of `O(marks per part)` cache entries such a query allocates, and removes one cache lookup per part. Queries with `distributed_index_analysis` enabled keep both keys. [#116259](https://github.com/ClickHouse/ClickHouse/pull/116259) ([Groene AI](https://github.com/groeneai)).
* `SELECT ... FINAL` with a selective skip-index plan is much faster on tables with many granules: the `use_skip_indexes_if_final_exact_mode` recovery pass now iterates ranges instead of individual granules. [#121799](https://github.com/ClickHouse/ClickHouse/pull/121799) ([Nikolai Kochetov](https://github.com/KochetovNicolai)).
* Improve primary index analysis in queries that filter both by the primary key and by other columns, for example `WHERE timestamp BETWEEN ... AND level = 'error'` where `level` is not in the primary key. [#123535](https://github.com/ClickHouse/ClickHouse/pull/123535) ([Anton Popov](https://github.com/CurtizJ)).
* `IS NULL` and `IS NOT NULL` predicates can now prune `MergeTree` parts using the `NULL` row count tracked by `basic` statistics on `Nullable` columns. [#116697](https://github.com/ClickHouse/ClickHouse/pull/116697) ([zoomxi](https://github.com/zoomxi)).
* A `set` skip index on a `Nullable` column again skips granules whose stored set contains `NULL` but not the searched value for `IN` and `=` conditions, restoring the pruning lost in 26.8. Closes [#123705](https://github.com/ClickHouse/ClickHouse/issues/123705). [#123778](https://github.com/ClickHouse/ClickHouse/pull/123778) ([Groene AI](https://github.com/groeneai)).
* Skip indexes (`text`, `bloom_filter`, `tokenbf_v1`, `ngrambf_v1`, `minmax`) and the primary key are now used when the indexed column or the searched constant is wrapped in a conversion that does not change its value, such as `toLowCardinality`, `toNullable`, or a `CAST` to `Nullable` or `LowCardinality`. For example, `m['key'] = 'value'` on `Map(String, LowCardinality(String))` and `hasToken(s, toLowCardinality('x'))` no longer scan all granules. `bloom_filter` and text indexes also work when a `Nullable` indexed column is cast to the non-`Nullable` type, such as `CAST(x, 'String')` or `json.path::String`. [#120220](https://github.com/ClickHouse/ClickHouse/pull/120220) ([Anton Popov](https://github.com/CurtizJ)). [#123239](https://github.com/ClickHouse/ClickHouse/pull/123239) ([Anton Popov](https://github.com/CurtizJ)). [#124220](https://github.com/ClickHouse/ClickHouse/pull/124220) ([Anton Popov](https://github.com/CurtizJ)).
* Speed up planning of queries with skip indexes on tables with many parts and pending patch parts of lightweight updates. [#124931](https://github.com/ClickHouse/ClickHouse/pull/124931) ([Anton Popov](https://github.com/CurtizJ)).
* Speed up queries with multiple `PREWHERE` conditions on AMD Zen 1 and Zen 2 CPUs. [#120283](https://github.com/ClickHouse/ClickHouse/pull/120283) ([Manuel](https://github.com/raimannma)).
* Analysis of a query over a `Merge` table no longer traverses every child table for each query-tree node when `optimize_functions_to_subcolumns` is enabled. The answer is now reused across the query tree, so analysis time grows with the query size plus the number of child tables instead of their product. Closes [#113202](https://github.com/ClickHouse/ClickHouse/issues/113202). [#113367](https://github.com/ClickHouse/ClickHouse/pull/113367) ([Groene AI](https://github.com/groeneai)).
* Queries to the `merge` table function and creation of `Merge` tables are faster when the source tables have many columns: combining the source columns no longer takes quadratic time in the number of columns. [#124115](https://github.com/ClickHouse/ClickHouse/pull/124115) ([Groene AI](https://github.com/groeneai)).
* Faster analysis of queries to tables with many `ALIAS` columns, such as `system.metric_log`: the expression of an `ALIAS` column is analyzed only if the query uses that column. [#123926](https://github.com/ClickHouse/ClickHouse/pull/123926) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Reduce aggregate projection analysis overhead for tables with many subcolumns. [#110979](https://github.com/ClickHouse/ClickHouse/pull/110979) ([Rory Shanks](https://github.com/rorylshanks)).
* A condition such as `name IN ('a', 'b')` on the system tables that enumerate tables (`system.tables`, `system.columns`, `system.parts`, `system.replicas`, and others) now narrows the enumeration instead of walking every table of every database, the same way an equality condition already did. This is most visible for databases whose table list comes from a remote system, such as `PostgreSQL`, `SQLite`, and the DataLake catalogs. [#117589](https://github.com/ClickHouse/ClickHouse/pull/117589) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Added the `external_storage_push_down_limit` setting to reduce data read from external databases for safe `LIMIT` queries. Also fixed wrong results when `LIMIT` plus `OFFSET` does not fit in `UInt64`: `numbers`, `system.numbers`, `generate_series`, `primes`, `system.primes`, and the `PostgreSQL` table engine returned no rows for the common "no limit" idiom `LIMIT 18446744073709551615 OFFSET n`, and a `LIMIT` over a `JOIN` with `numbers`-like sources returned too few rows. [#115238](https://github.com/ClickHouse/ClickHouse/pull/115238) ([Alexey Milovidov](https://github.com/alexey-milovidov)). [#118131](https://github.com/ClickHouse/ClickHouse/pull/118131) ([Groene AI](https://github.com/groeneai)).
* Push filters into the query fragment executed by parallel replicas so replicas can filter rows and prune data before sending results to the initiator. This also allows join runtime filters to reach the relevant reads. Controlled by `parallel_replicas_filter_pushdown`, now enabled by default; `SET parallel_replicas_filter_pushdown = 0` restores the behavior before 26.10. [#117373](https://github.com/ClickHouse/ClickHouse/pull/117373) ([Nikita Taranov](https://github.com/nickitat)).
* With parallel replicas, `optimize_aggregation_in_order` no longer disables projections: aggregate and normal projections, and `_minmax_count_projection` for `count()` with a partition predicate, are used as with `optimize_aggregation_in_order = 0`. Closes [#123061](https://github.com/ClickHouse/ClickHouse/issues/123061). [#123098](https://github.com/ClickHouse/ClickHouse/pull/123098) ([Groene AI](https://github.com/groeneai)).
* Parallel replicas now apply `enable_join_runtime_filters_index_analysis` to prune probe-side granules locally on each replica, reducing `JOIN` read work. [#123116](https://github.com/ClickHouse/ClickHouse/pull/123116) ([Nikita Taranov](https://github.com/nickitat)).
* Automatic parallel replicas no longer distributes a query when most of its reading would be repeated in full by every replica rather than split between them. The limit is set by the new setting `automatic_parallel_replicas_max_duplicated_read_ratio` (default `0.5`; `1` disables it). [#123332](https://github.com/ClickHouse/ClickHouse/pull/123332) ([Nikita Taranov](https://github.com/nickitat)).
* Automatic parallel replicas for multi-read queries now reuse local plan index analysis in the parallel-replicas plan, reducing extra reads when parallel replicas are enabled. [#115153](https://github.com/ClickHouse/ClickHouse/pull/115153) ([Nikita Taranov](https://github.com/nickitat)).
* Improve reuse of collected query statistics by automatic parallel replicas for equivalent local and distributed plans. [#116781](https://github.com/ClickHouse/ClickHouse/pull/116781) ([Nikita Taranov](https://github.com/nickitat)).
* Automatic parallel replicas now account correctly for the size of aggregated results on more aggregation paths, so the cost model no longer treats shipping aggregate states as free and is less likely to choose parallel replicas when a query is cheaper locally. [#119499](https://github.com/ClickHouse/ClickHouse/pull/119499) ([Nikita Taranov](https://github.com/nickitat)).
* Automatic parallel replicas now collect planning statistics for the table read that is actually split between replicas, including after join reordering and with lazy materialization, improving the decision to distribute a query. [#122906](https://github.com/ClickHouse/ClickHouse/pull/122906) ([Nikita Taranov](https://github.com/nickitat)).
* Avoid building the parallel replicas candidate plan when cached statistics already show the query should stay on a single replica. [#124983](https://github.com/ClickHouse/ClickHouse/pull/124983) ([Nikita Taranov](https://github.com/nickitat)).
* Added quick checks to skip automatic parallel replicas optimization for queries unsupported by parallel replicas, including keyless aggregations whose aggregate state owns memory and therefore never produces the probe statistics the optimization needs. [#120861](https://github.com/ClickHouse/ClickHouse/pull/120861) ([Nikita Taranov](https://github.com/nickitat)). [#125470](https://github.com/ClickHouse/ClickHouse/pull/125470) ([Nikita Taranov](https://github.com/nickitat)).
* Automatic parallel replicas (`automatic_parallel_replicas_mode`) can now be applied to queries with `ORDER BY ... WITH FILL`. [#123929](https://github.com/ClickHouse/ClickHouse/pull/123929) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Queries that search for several tokens at once with a text index, such as `hasAllTokens`, are now faster. The automatic choice of algorithm for intersecting posting lists is improved too, and is controlled by the new setting `text_index_postings_intersection_algorithm`. [#121038](https://github.com/ClickHouse/ClickHouse/pull/121038) ([Anton Popov](https://github.com/CurtizJ)).
* Queries that use a text index read large posting lists faster and with fewer disk operations. The improvement is most noticeable for searches for frequent tokens in big tables. [#121040](https://github.com/ClickHouse/ClickHouse/pull/121040) ([Anton Popov](https://github.com/CurtizJ)).
* A query that searches a text index and also selects a column no index covers no longer reads that column for every row of every granule the index selected. On a 1M-row table with a 1055-byte payload and 64 matching rows, `SELECT ts, payload FROM t WHERE hasToken(message, 'needle')` now reads 578 KiB instead of 532 MiB. [#120517](https://github.com/ClickHouse/ClickHouse/pull/120517) ([Groene AI](https://github.com/groeneai)).
* A query that reads a `text` index no longer asks the filesystem for each index substream's on-disk name and size once per part; both are now taken from the part's checksums, which already hold them. On an 8M-row table split into 400 parts, `SELECT count() FROM logs WHERE hasToken(message, 'needle')` drops from a median 12 ms to 9 ms, with 42% less system time. [#120875](https://github.com/ClickHouse/ClickHouse/pull/120875) ([Groene AI](https://github.com/groeneai)).
* Speed up queries that filter by a text index together with other `PREWHERE` conditions, such as the dynamic filter of `ORDER BY ... LIMIT` queries. [#124880](https://github.com/ClickHouse/ClickHouse/pull/124880) ([Anton Popov](https://github.com/CurtizJ)).
* Speed up `LIKE`, `ILIKE`, `startsWith`, and `endsWith` evaluated by a text-index dictionary scan (`use_text_index_like_evaluation_by_dictionary_scan`): the scan now seeks the sorted dictionary to the block range an anchored pattern can match, and tests a block's tokens for the pattern's mandatory literal in one pass instead of running the matcher on every token. [#120495](https://github.com/ClickHouse/ClickHouse/pull/120495) ([Groene AI](https://github.com/groeneai)).
* Repeated broad `LIKE` and `ILIKE` queries over a text index no longer rescan the index dictionary of every part only to abandon the scan again: the decision is cached (setting `use_text_index_pattern_bypass_cache`). [#113572](https://github.com/ClickHouse/ClickHouse/pull/113572) ([Rory Shanks](https://github.com/rorylshanks)).
* A text index with the `splitByNonAlpha` or `array` tokenizer now answers single-needle `multiSearchAny`, `multiSearchAnyUTF8`, `multiSearchAnyCaseInsensitive`, and `multiSearchAnyCaseInsensitiveUTF8` with the same dictionary scan that `LIKE '%needle%'` uses, so a needle inside a word, such as `PointerExc` in `NullPointerException`, no longer reads the whole column. [#124520](https://github.com/ClickHouse/ClickHouse/pull/124520) ([Groene AI](https://github.com/groeneai)).
* `multiSearchAny` over a map element can now use a `mapValues(...)` ngram or token text index instead of being rejected by index analysis. [#121787](https://github.com/ClickHouse/ClickHouse/pull/121787) ([Groene AI](https://github.com/groeneai)).
* Optimize `SELECT count()` queries answered from a text index with a compressed posting list codec (`bitpacking`, `pfor`). [#123294](https://github.com/ClickHouse/ClickHouse/pull/123294) ([Anton Popov](https://github.com/CurtizJ)).
* Reduced the CPU overhead of reading and intersecting text index posting lists in lazy apply mode. [#123786](https://github.com/ClickHouse/ClickHouse/pull/123786) ([Anton Popov](https://github.com/CurtizJ)). [#123873](https://github.com/ClickHouse/ClickHouse/pull/123873) ([Anton Popov](https://github.com/CurtizJ)).
* Merges of tables with a `text` index are now faster. Pages of a source part's row ids that hold consecutive values are stored as a first value plus a count, so they are neither bit-packed nor decoded per posting row id and need no storage for packed values. [#120982](https://github.com/ClickHouse/ClickHouse/pull/120982) ([Groene AI](https://github.com/groeneai)).
* Merging positional text indexes is faster: position lists are now merged segment by segment instead of being materialized and sorted in a temporary `roaringish` structure. [#121976](https://github.com/ClickHouse/ClickHouse/pull/121976) ([Elmi Ahmadov](https://github.com/ahmadov)).
* Added the `pfor` codec for text-index posting lists. It improves compression ratio and decoding speed. Enable it per index with `posting_list_codec = 'pfor'`, or for all text indexes of a table with the `text_index_posting_list_codec` setting. [#118123](https://github.com/ClickHouse/ClickHouse/pull/118123) ([Elmi Ahmadov](https://github.com/ahmadov)).
* Building text indexes during `INSERT` is now faster, especially for indexes with the `bitpacking` codec. [#113856](https://github.com/ClickHouse/ClickHouse/pull/113856) ([Anton Popov](https://github.com/CurtizJ)).
* Building a text index over a `LowCardinality(String)` or `Array(LowCardinality(String))` column is faster: each distinct value is tokenized once per batch of rows instead of at every occurrence. `MATERIALIZE INDEX` over a column with 50 distinct values takes about 33% less time. [#122409](https://github.com/ClickHouse/ClickHouse/pull/122409) ([Groene AI](https://github.com/groeneai)).
* Improve performance of the `ngrams` tokenizer. This speeds up `tokens(s, 'ngrams', N)`, `ngrams(s, N)`, `hasAnyTokens`, `hasAllTokens`, and `hasPhrase` with the `ngrams` tokenizer, as well as inserts into tables with an `ngrambf_v1` or `text(tokenizer = ngrams(N))` index. `tokens(URL, 'ngrams', 3)` over ClickBench URLs takes 26% (aarch64) to 36% (x86_64) less time. [#122328](https://github.com/ClickHouse/ClickHouse/pull/122328) ([Groene AI](https://github.com/groeneai)).
* Reading columns and subcolumns of `MergeTree` tables no longer rebuilds the serialization of a column for every reader: the serialization the data part already holds is reused. The gain is largest for `JSON` columns with many typed paths, where the whole set of path serializations used to be rebuilt per read task and per filter step. [#120632](https://github.com/ClickHouse/ClickHouse/pull/120632) ([Pavel Kruglov](https://github.com/Avogar)).
* Reduce per-block overhead when reading `MergeTree` parts with small blocks: column-stream names and substream-cache keys are no longer rebuilt for every block, and reads skip patch-part handling when there are none, virtual-column name lookups, and some small-column reallocations. This makes queries with a low `max_block_size` faster. [#124816](https://github.com/ClickHouse/ClickHouse/pull/124816) ([Alexey Milovidov](https://github.com/alexey-milovidov)). [#124817](https://github.com/ClickHouse/ClickHouse/pull/124817) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Reduce CPU overhead of reads from `MergeTree` tables by not formatting a tracing span name for every block. [#124820](https://github.com/ClickHouse/ClickHouse/pull/124820) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Reading many columns from Compact parts is up to 2% faster by avoiding per-call copies of column metadata. [#122840](https://github.com/ClickHouse/ClickHouse/pull/122840) ([Samuel Krempaský](https://github.com/NIKTONIKTO717)).
* Restore parallel prefix deserialization when reading an `Object` or `JSON` column from a Wide part: marks loading no longer queues behind one mutex. Closes [#114136](https://github.com/ClickHouse/ClickHouse/issues/114136). [#114252](https://github.com/ClickHouse/ClickHouse/pull/114252) ([Groene AI](https://github.com/groeneai)).
* Queries that read subcolumns of `JSON` columns with many typed paths are faster: resolving a subcolumn by name visits only the typed paths that can match it. For a `JSON` column with 500 typed paths, reading subcolumns from 96 parts takes about half the time. [#122029](https://github.com/ClickHouse/ClickHouse/pull/122029) ([Rory Shanks](https://github.com/rorylshanks)).
* Reduce serialization construction when reading `JSON` subcolumns from `MergeTree` parts by reusing safe cached subcolumn serializations. [#110957](https://github.com/ClickHouse/ClickHouse/pull/110957) ([Rory Shanks](https://github.com/rorylshanks)).
* Improve nested `JSON` path read performance with `map_with_buckets` by reusing thread-local serializations for `Dynamic` values. [#113344](https://github.com/ClickHouse/ClickHouse/pull/113344) ([Rory Shanks](https://github.com/rorylshanks)).
* Writing `JSON` columns with many paths in shared data is faster: the writer no longer rebuilds the statistics of the column for every block. For merges of parts with small granules, this saves up to 13% of the merge time. [#121987](https://github.com/ClickHouse/ClickHouse/pull/121987) ([Rory Shanks](https://github.com/rorylshanks)).
* Make constructing a `JSON` data type that uses `SKIP REGEXP` cheaper. The patterns are now compiled once per type instead of once for every declared path, so a column declaring 183 typed paths and 6 `SKIP REGEXP` entries performs 6 regular expression compilations where it previously performed 1098. This matters most for wide `JSON` schemas, where the patterns are often long alternations that are expensive to compile. [#122941](https://github.com/ClickHouse/ClickHouse/pull/122941) ([arc1999](https://github.com/arc1999)).
* Read only the matching `Map` subcolumn for safe `LIKE` predicates over `Map` values. [#119809](https://github.com/ClickHouse/ClickHouse/pull/119809) ([Minh Vu](https://github.com/fallintoplace)).
* Improve `SELECT` performance by avoiding lock contention when getting mutation snapshots with many concurrent background fetches. [#102382](https://github.com/ClickHouse/ClickHouse/pull/102382) ([c-end](https://github.com/c-end)).
* Support `PREWHERE` (including the automatic move of `WHERE` conditions by `optimize_move_to_prewhere`) for `Memory` tables: only the columns of the conditions are read at first, and the remaining columns are read only for the blocks where some rows pass, and only for the passing rows. This is especially beneficial for tables with `SETTINGS compress = true`, because for a selective condition most columns are never decompressed. Additionally, `SELECT count() FROM table` on a `Memory` table is now served from metadata, and `system.columns` shows real per-column sizes for `Memory` tables. [#116248](https://github.com/ClickHouse/ClickHouse/pull/116248) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* `PREWHERE` over a `Memory` table is evaluated in multiple steps, like for `MergeTree` (`enable_multiple_prewhere_read_steps`): the columns of each next condition are read only for the rows that passed the previous ones. For a table with `compress = true`, a condition on a wide column next to a selective one no longer decompresses that column for every block, which makes such queries up to several times faster. [#122604](https://github.com/ClickHouse/ClickHouse/pull/122604) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Queries with `ORDER BY ... LIMIT n` over `Memory` tables use TopN dynamic filtering: rows that cannot get into the result are dropped while reading, before the other columns are read or decompressed with `compress = true`. [#123787](https://github.com/ClickHouse/ClickHouse/pull/123787) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Queries whose only aggregate functions are `min` and `max` of columns of `Parquet` files read with the `file` table function or the `File` engine, without `GROUP BY` or filters (for example ClickBench Q7), now take the values from the column chunk statistics instead of reading the data. Controlled by the new setting `optimize_min_max_from_files`. [#124201](https://github.com/ClickHouse/ClickHouse/pull/124201) ([Groene AI](https://github.com/groeneai)).
* `ORDER BY ... LIMIT` over a single `Parquet` file reads first the row groups whose min/max statistics are best for the result, so the top-K threshold skips the other row groups: `SELECT URL FROM file('hits.parquet') ORDER BY UserID DESC LIMIT 10` skips 207 of its 226 row groups at 4 threads. New profile event `ParquetTopKSkippedRowGroups`. [#123639](https://github.com/ClickHouse/ClickHouse/pull/123639) ([Groene AI](https://github.com/groeneai)).
* Row group pruning by dictionaries in the `Parquet` reader is faster for an equality or a short `IN` list on a column with large dictionaries, such as `WHERE UserID = ...` over ClickBench `hits.parquet`: the hashes of the dictionary values are no longer sorted unless a column chunk is checked against many values. [#123579](https://github.com/ClickHouse/ClickHouse/pull/123579) ([Groene AI](https://github.com/groeneai)).
* `Parquet` readers now check a column chunk's bloom filter before reading its dictionary page. A row group that the bloom filter rules out no longer reads the much larger dictionary page to reach the same conclusion, so `input_format_parquet_dictionary_filter_push_down` costs nothing on files that carry both, while pruning as much as before. [#120907](https://github.com/ClickHouse/ClickHouse/pull/120907) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* `Parquet` footer-size reads are now tuned by storage type: remote and object-storage reads use more optimistic footer-size estimates to fetch the footer in one read instead of two, reducing footer-read latency, while local-file reads again use a 64 KiB tail so short queries over many local `Parquet` files read less data. [#115686](https://github.com/ClickHouse/ClickHouse/pull/115686) ([UnamedRus](https://github.com/UnamedRus)). [#124883](https://github.com/ClickHouse/ClickHouse/pull/124883) ([Groene AI](https://github.com/groeneai)).
* Avoid a redundant object-storage GET request when reading random-access formats from object storage. The generic from-start read-ahead is no longer issued for files larger than a single read buffer, where it could not reach the footer. Also, `input_format_allow_seeks = 0` is now honored by the `Parquet` reader, which previously sought regardless of the setting: with seeks disabled the whole object is read sequentially instead, which can raise memory usage for queries that set it. [#115681](https://github.com/ClickHouse/ClickHouse/pull/115681) ([UnamedRus](https://github.com/UnamedRus)).
* Speed up writing `Parquet` bloom filters: instead of deduplicating the value hashes in a hash set to determine the filter size, the writer now builds a filter sized for the number of values and folds it down to the size implied by `output_format_parquet_bloom_filter_bits_per_value`. This removes the worst-case slowdown on data that is adversarial for the hash set, and lowers the worst-case memory usage. [#119230](https://github.com/ClickHouse/ClickHouse/pull/119230) ([Armin Braun](https://github.com/original-brownbear)).
* Parse some GeoParquet metadata lazily. [#122693](https://github.com/ClickHouse/ClickHouse/pull/122693) ([Konstantin Vedernikov](https://github.com/scanhex12)).
* Snappy decompression on AArch64 now uses NEON for short-offset copies, as upstream snappy does by default, which makes reading Snappy-compressed `Parquet` with repetitive string columns up to ~9% faster on ARM servers. The ARMv8.0 compatibility build (`NO_ARMV81_OR_HIGHER`) is unchanged. [#124608](https://github.com/ClickHouse/ClickHouse/pull/124608) ([Groene AI](https://github.com/groeneai)).
* Reading `CSV` with `input_format_csv_trim_whitespaces = 0` no longer prevents the parser from scaling across CPU cores. Each field used to copy a `shared_ptr` shared by all parsing threads, turning its reference counter into a contention point. On a 96-core machine, reading 200 million rows became 4.6 times faster and used 23 times less CPU. [#117251](https://github.com/ClickHouse/ClickHouse/pull/117251) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* `Iceberg` partition pruning now uses the partition value of a `day`, `month`, `year`, or `hour` transform for a filter that wraps the partition source column in a monotonic function, such as `WHERE toDate(ts) = '2024-01-20'`, including for partition values from before 1970. Closes [#103433](https://github.com/ClickHouse/ClickHouse/issues/103433). [#118606](https://github.com/ClickHouse/ClickHouse/pull/118606) ([Konstantin Vedernikov](https://github.com/scanhex12)). [#119302](https://github.com/ClickHouse/ClickHouse/pull/119302) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Faster planning of queries to `Iceberg` tables with many manifest files: when a manifest file header has the `schema-id` key and that schema is already known from `metadata.json`, the schema copy stored in the manifest header is no longer parsed and compared with it. ClickHouse now also writes the `schema-id` key into the headers of manifest files it creates. [#122574](https://github.com/ClickHouse/ClickHouse/pull/122574) ([Konstantin Vedernikov](https://github.com/scanhex12)).
* An `INSERT` into an `Iceberg` table that loses the commit race now reuses its manifests on retry and rewrites only the manifest list and the metadata file, instead of regenerating all manifests. [#122096](https://github.com/ClickHouse/ClickHouse/pull/122096) ([Asya Shneerson](https://github.com/asya-ch)).
* Restore the summary-based trivial `count()` optimization for `Iceberg` tables when the snapshot summary contains a safe row count. The optimization is skipped when equality deletes are present, because their recorded count is not the number of deleted rows. [#123267](https://github.com/ClickHouse/ClickHouse/pull/123267) ([Konstantin Vedernikov](https://github.com/scanhex12)).
* `Iceberg` min/max hyperrectangles are now built only for columns the filter uses. [#122681](https://github.com/ClickHouse/ClickHouse/pull/122681) ([Konstantin Vedernikov](https://github.com/scanhex12)).
* Restore min/max pruning of `Iceberg` data files for a `Decimal(38, 38)` column. A manifest bound of magnitude above roughly 0.7 could not be widened inside `Int128` and was dropped, leaving the column without a min/max condition; it is now saturated at the largest magnitude the precision allows, which is still outside every value the file can hold. [#119712](https://github.com/ClickHouse/ClickHouse/pull/119712) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Queries to `system.iceberg_history` with filters on `table` now avoid listing unrelated data lake catalog namespaces. [#113867](https://github.com/ClickHouse/ClickHouse/pull/113867) ([Den Kalantaevskii](https://github.com/Diskein)).
* Improve HTTP upload and download efficiency for `S3`, `Azure`, the `url` table function and engine, dictionaries, and data lake catalogs. Uploads use 1 MiB chunks instead of 8 KiB chunks, reducing the number of system calls for a 15 MB body from 1817 to 15 and avoiding redundant copies. Reads from `Azure` also avoid an intermediate 8 KiB buffer. [#116222](https://github.com/ClickHouse/ClickHouse/pull/116222) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Reading from object storage with `remote_filesystem_read_method = 'read'` now keeps full-size network reads. Before, a short read at the end of one range capped every later read of the same file, which could make a scan hundreds of times slower, for example a compact part on an encrypted `S3` disk without the filesystem cache. [#123777](https://github.com/ClickHouse/ClickHouse/pull/123777) ([Groene AI](https://github.com/groeneai)).
* Reads that are served from the OS page cache no longer consume the budget of the local read bandwidth throttler (`max_local_read_bandwidth_for_server` and `max_local_read_bandwidth`), so a query over cached data is not slowed down to the configured disk bandwidth. This works with the default `local_filesystem_read_method = 'pread_threadpool'`, with `pread`, and for the files of the filesystem cache; the `read` method cannot detect cached reads and is accounted as before. [#118495](https://github.com/ClickHouse/ClickHouse/pull/118495) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Populating the filesystem cache on a cache miss is faster: the writer now reserves space ahead instead of taking the cache lock on every write. [#123255](https://github.com/ClickHouse/ClickHouse/pull/123255) ([Kseniia Sumarokova](https://github.com/kssenii)).
* Loading the metadata of a large `s3_plain_rewritable` disk is several times faster. Previously it made one `ListObjects` request per directory and enumerated the `__meta` directory by a single paginated listing, so a disk with tens of thousands of directories needed tens of thousands of sequential-ish requests. The listings are now split by key prefix and run in parallel, and the files of all directories are collected by a few listings of the whole disk. For a disk with 36 thousand directories holding half a million objects, the load time dropped from 116 to 37 seconds. [#121412](https://github.com/ClickHouse/ClickHouse/pull/121412) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Metadata transactions of unrelated tables on a `plain_rewritable` disk no longer wait for each other: the disk-wide lock used to be held across all object storage requests of a commit, so one long `MOVE PARTITION`, `DROP TABLE`, or part removal blocked every merge, insert, and `CREATE TABLE` on the same disk. The lock is now taken per affected path, and the in-memory metadata is updated by replaying the recorded changes. Also fixes a permanent leak of objects when the server was killed during `DROP TABLE` (or another removal) on a `plain_rewritable` disk: the leftovers of such a removal are now marked and deleted when the disk metadata is loaded on the next start. [#118490](https://github.com/ClickHouse/ClickHouse/pull/118490) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Removing data parts from a disk with `metadata_type = plain_rewritable` (cleanup of outdated parts, `TRUNCATE`, `DROP PARTITION`, `DROP TABLE`) no longer copies every file of the part to a temporary object before deleting it, and no longer holds the disk metadata lock for those copies. The part directory is removed with one batched delete request. Closes [#123275](https://github.com/ClickHouse/ClickHouse/issues/123275). [#123303](https://github.com/ClickHouse/ClickHouse/pull/123303) ([Groene AI](https://github.com/groeneai)).
* Reduce metadata update cost and lock contention for `s3_plain_rewritable` disks with many parts by sharing unchanged directory entries between snapshots. [#119625](https://github.com/ClickHouse/ClickHouse/pull/119625) ([Rory Shanks](https://github.com/rorylshanks)).
* Avoid object reads for unchanged directories when a plain-rewritable disk refreshes its metadata. [#119760](https://github.com/ClickHouse/ClickHouse/pull/119760) ([Rory Shanks](https://github.com/rorylshanks)).
* `OPTIMIZE TABLE ... FINAL` on a non-replicated `MergeTree` table now assigns and runs the merges for all partitions at once instead of processing them one partition at a time. [#109004](https://github.com/ClickHouse/ClickHouse/pull/109004) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* `TTL DELETE` merges can now use the vertical merge algorithm on `ReplacingMergeTree`, `CollapsingMergeTree`, and `VersionedCollapsingMergeTree`, where `vertical_merge_optimize_ttl_delete` previously applied only to plain `MergeTree`. [#119886](https://github.com/ClickHouse/ClickHouse/pull/119886) ([Murphy](https://github.com/murphy-4o)).
* Allow vertical merges to produce `Wide` parts with `Packed` storage instead of forcing the horizontal merge algorithm. [#125760](https://github.com/ClickHouse/ClickHouse/pull/125760) ([alesapin](https://github.com/alesapin)).
* Improved merge performance for `SummingMergeTree` tables by skipping unnecessary aggregate-column materialization. [#120852](https://github.com/ClickHouse/ClickHouse/pull/120852) ([Eduard Karacharov](https://github.com/korowa)).
* Many queued lightweight deletes with an `IN` condition that reach the same part in one mutation are now applied together, instead of evaluating each `IN` predicate over the whole part separately. Controlled by the new `MergeTree` setting `enable_row_mask_update_coalescing`. [#122718](https://github.com/ClickHouse/ClickHouse/pull/122718) ([Sergey Kuznetsov](https://github.com/skuznetsov-clickhouse)).
* Optimize the insert backpressure path in `MergeTree` by short-circuiting the parts-count check. [#114754](https://github.com/ClickHouse/ClickHouse/pull/114754) ([johnjing](https://github.com/JingYanchao)).
* Reduced merge-selection work when all storage volumes allow merges. [#119782](https://github.com/ClickHouse/ClickHouse/pull/119782) ([Rory Shanks](https://github.com/rorylshanks)).
* Reduce merge-selection CPU overhead for tables with column TTLs by avoiding copies of TTL descriptions. [#119644](https://github.com/ClickHouse/ClickHouse/pull/119644) ([Rory Shanks](https://github.com/rorylshanks)).
* Speed up decompression of codec chains. The first codec now reads the compressed block in place and the last codec writes the result in place, unless that codec requires a padded buffer (`LZ4`, `ZXC`). [#120043](https://github.com/ClickHouse/ClickHouse/pull/120043) ([Raufs Dunamalijevs](https://github.com/rienath)).
* Faster decompression of `T64`-encoded columns. [#120414](https://github.com/ClickHouse/ClickHouse/pull/120414) ([Raufs Dunamalijevs](https://github.com/rienath)). [#122442](https://github.com/ClickHouse/ClickHouse/pull/122442) ([Raufs Dunamalijevs](https://github.com/rienath)).
* A query with `arrayJoin` and a small `LIMIT` again shrinks the read block size instead of reading whole blocks on every thread for a few output rows, fixing a regression from 26.6. Closes [#119193](https://github.com/ClickHouse/ClickHouse/issues/119193). [#120214](https://github.com/ClickHouse/ClickHouse/pull/120214) ([Yarik Briukhovetskyi](https://github.com/yariks5s)).
* Chained `ARRAY JOIN`s no longer materialize the whole block of a lazily replicated array column before expanding it, which cuts their peak memory by several times. [#121397](https://github.com/ClickHouse/ClickHouse/pull/121397) ([Yarik Briukhovetskyi](https://github.com/yariks5s)).
* Avoid copying whole columns when slicing them, including in `ARRAY JOIN`. [#118788](https://github.com/ClickHouse/ClickHouse/pull/118788) ([Nikita Mikhaylov](https://github.com/nikitamikhaylov)).
* Improve `ARRAY JOIN` performance for queries with wide columns that are not expanded, by avoiding unnecessary copies and preserving lazy replication through filtering and sorting. [#124727](https://github.com/ClickHouse/ClickHouse/pull/124727) ([Yarik Briukhovetskyi](https://github.com/yariks5s)).
* Reduced the peak memory usage of `RESTORE` and of incremental `BACKUP`: the metadata file of a backup is now parsed while it is read, instead of being read into memory whole first. For backups of millions of files this saves gigabytes. [#125712](https://github.com/ClickHouse/ClickHouse/pull/125712) ([Julia Kartseva](https://github.com/jkartseva)).
* Faster startup of `clickhouse-local` and other tools. Time zone lookup tables are built 2.4 to 5.6 times faster and use half the memory (2.3 MiB instead of 4.6 MiB per loaded time zone). The `clickhouse` binary also starts faster when it is not in the page cache, with a 1.40x speedup measured for `clickhouse local`. [#125665](https://github.com/ClickHouse/ClickHouse/pull/125665) ([Raúl Marín](https://github.com/Algunenano)). [#125672](https://github.com/ClickHouse/ClickHouse/pull/125672) ([Raúl Marín](https://github.com/Algunenano)).
* A full scan of a complex-key `hashed`, `sparse_hashed`, `hashed_array`, or `range_hashed` dictionary (`SELECT ... FROM ` or the `dictionary` table function) is faster: each reading stream now deserializes only the keys of its own block instead of one thread deserializing all keys before reading starts. A scan with `LIMIT` deserializes only the blocks it reads. A full scan also no longer keeps all deserialized keys in memory at once. [#123883](https://github.com/ClickHouse/ClickHouse/pull/123883) ([Groene AI](https://github.com/groeneai)).
* Added the `SIEVE` cache eviction policy for in-memory caches such as the mark cache and the uncompressed cache. Enable it with the corresponding `*_cache_policy` server settings, for example `mark_cache_policy` or `uncompressed_cache_policy`. It is not available for the filesystem cache. [#123435](https://github.com/ClickHouse/ClickHouse/pull/123435) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* The symbolized stack trace of a failed query is now built only when the error message will be logged or the trace will be stored in `system.query_log`. Previously each failing `clickhouse-local` invocation built the symbol index of the whole binary to produce a string that was then discarded. [#120660](https://github.com/ClickHouse/ClickHouse/pull/120660) ([Groene AI](https://github.com/groeneai)).
* Reduces the CPU overhead of the workload scheduler thread by updating the `system.scheduler` introspection metrics more cheaply. A saturated scheduler can now serve about 15% more resource requests per second. [#121958](https://github.com/ClickHouse/ClickHouse/pull/121958) ([Sergei Trifonov](https://github.com/serxa)).
* PromQL now copies label matchers across binary operators for the labels the operator matches series by, so `b / on(job) a{job="x"}` reads only the matching series of `b`. As in Prometheus, duplicate left series of a one-to-one match in a group the right side does not have no longer fail the query. The new setting `promql_push_down_label_matchers` turns this off. [#122972](https://github.com/ClickHouse/ClickHouse/pull/122972) ([Valery Petrov](https://github.com/valerypetrov)). [#125267](https://github.com/ClickHouse/ClickHouse/pull/125267) ([Groene AI](https://github.com/groeneai)).
* Accelerate exact PromQL label matching on `TimeSeries` tables with a text index on the `tags` map. [#120083](https://github.com/ClickHouse/ClickHouse/pull/120083) ([Nikita Mikhaylov](https://github.com/nikitamikhaylov)).
* Use more compact codecs for generated `timestamp` and `value` columns in the samples and recent samples tables of the `TimeSeries` engine: `Delta`, `T64`, and `ZSTD(3)` for `timestamp`, and `ALP` plus `ZSTD(3)` for `value`. [#120454](https://github.com/ClickHouse/ClickHouse/pull/120454) ([Nikita Mikhaylov](https://github.com/nikitamikhaylov)).
* Reduce memory usage of the `timeSeries*ToGrid` aggregate functions. [#124773](https://github.com/ClickHouse/ClickHouse/pull/124773) ([Valery Petrov](https://github.com/valerypetrov)).
* Filtering and sorting are now faster: the helpers that build filter masks, count filter bytes, and check for an identity permutation use AVX2 or AVX-512 on x86 instead of SSE2, and are vectorized on ARM where they were not. [#121403](https://github.com/ClickHouse/ClickHouse/pull/121403) ([Raúl Marín](https://github.com/Algunenano)).
* Faster filtering of numeric columns on ARM (up to 1.28x) and on AMD Zen 4 (up to 2.8x), speeding up queries with `WHERE` and multi-step `PREWHERE`. [#122893](https://github.com/ClickHouse/ClickHouse/pull/122893) ([Raúl Marín](https://github.com/Algunenano)).
* Filters on numeric columns that keep few rows are faster. [#124024](https://github.com/ClickHouse/ClickHouse/pull/124024) ([Raúl Marín](https://github.com/Algunenano)).
* Filtering numeric columns no longer over-allocates the result buffer (by up to 2x) when the size of the result is known in advance. Closes [#123546](https://github.com/ClickHouse/ClickHouse/issues/123546). [#123576](https://github.com/ClickHouse/ClickHouse/pull/123576) ([Raúl Marín](https://github.com/Algunenano)).
* Vectorized comparisons of `UUID`, `IPv4`, and `IPv6` columns with columns or constants of the same type, which makes such comparisons several times faster. Comparisons of `FixedString(16)` values are now branchless too, making them faster when it is unpredictable whether the values are equal. [#120193](https://github.com/ClickHouse/ClickHouse/pull/120193) ([Manuel](https://github.com/raimannma)).
* Comparisons `<`, `>`, `<=`, and `>=` of `IPv6` and `FixedString(16)` values are 1.4 to 1.8 times faster on CPUs with AVX-512. [#125151](https://github.com/ClickHouse/ClickHouse/pull/125151) ([Groene AI](https://github.com/groeneai)).
* `LIKE`, `ILIKE`, `match`, and their variants are faster when the pattern is not a constant, up to 5 times with 8 threads. [#122764](https://github.com/ClickHouse/ClickHouse/pull/122764) ([Groene AI](https://github.com/groeneai)). [#122843](https://github.com/ClickHouse/ClickHouse/pull/122843) ([Samuel Krempaský](https://github.com/NIKTONIKTO717)).
* Faster `multiMatchAny` and related functions with non-constant needles when `reject_expensive_hyperscan_regexps` is disabled. [#122842](https://github.com/ClickHouse/ClickHouse/pull/122842) ([Samuel Krempaský](https://github.com/NIKTONIKTO717)).
* `CAST` of strings to `Nullable(Bool)` (also `accurateCastOrNull(s, 'Bool')` and `toBool` of a `Nullable(String)`) is up to 7 times faster with 8 threads, and `arrayIntersect`, `arrayUnion`, `arraySymmetricDifference`, and `arrayJaccardIndex` over non-numeric elements such as `DateTime64`, `UUID`, or `Tuple` are up to 18 times faster with 8 threads: they no longer allocate memory and update profile events for every row. `multiMatchAny` and the other multi-regexp functions with non-constant needles now add their cache hit and miss counts once per block. [#122920](https://github.com/ClickHouse/ClickHouse/pull/122920) ([Groene AI](https://github.com/groeneai)).
* Speed up extracting a value from a `Map` with `LowCardinality` keys. The key is now resolved to its dictionary position once instead of being compared against every entry of a row, so the cost of `m[key]` no longer grows with the position of the key in the row. Also fix extracting a value from a `Map` whose key is `NaN`, or holds a `NULL` inside a composite key: such a key used to compare equal to every other key. [#120453](https://github.com/ClickHouse/ClickHouse/pull/120453) ([Pavel Kruglov](https://github.com/Avogar)).
* `L2DistanceTransposed`, `cosineDistanceTransposed`, `dotProductTransposed`, and their `...Quantized` variants with precision `1` are now computed directly from the packed sign bit plane with per-byte lookup tables, 2 to 3 times faster than before. The new setting `qbit_one_bit_symmetric_distance` additionally reduces the reference vector to its signs and derives the result from the Hamming distance between the two sign vectors, computed with XOR and popcount, which is up to 10 times faster. [#120594](https://github.com/ClickHouse/ClickHouse/pull/120594) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Speed up `randomHadamardTransform` and vector quantization for vector dimensions of the form 2^k × 12 or 2^k × 20, such as 768 or 1536, on x86 with AVX2: 1.9x to 2.5x higher throughput and 50% to 60% lower median latency. [#120874](https://github.com/ClickHouse/ClickHouse/pull/120874) ([Jingxin (Philip) Li](https://github.com/philip-jingxin)).
* `hasAll` and `hasAny` on integer arrays use SIMD on both x86 and ARM, including `Nullable` arrays and `hasAny`, which previously used a scalar loop. `hasAny` is up to 15x faster, and `hasAll` becomes several times faster on ARM. [#123420](https://github.com/ClickHouse/ClickHouse/pull/123420) ([Groene AI](https://github.com/groeneai)).
* `hasAny` over `Array(String)` looks each element up in a hash set, instead of comparing it with every string, when its second argument is a constant array of four or more strings of up to 256 bytes and a block has enough rows to pay for building the set. With 32 strings this uses 87% less CPU. Closes [#122333](https://github.com/ClickHouse/ClickHouse/issues/122333). [#122507](https://github.com/ClickHouse/ClickHouse/pull/122507) ([Groene AI](https://github.com/groeneai)).
* Vectorize `least` and `greatest` for `Nullable` numeric arguments and for three or more numeric arguments, and `clamp` for numeric arguments. These cases were previously evaluated row-by-row and are now 3-7 times faster. [#109783](https://github.com/ClickHouse/ClickHouse/pull/109783) ([Manuel](https://github.com/raimannma)).
* Speed up `round`, `roundBankers`, `floor`, `ceil`, and `trunc` with a scale argument on `Float32` and `Float64` columns by using AVX2 on x86 instead of SSE4.1, and speed up rounding of integers narrower than 64 bits on ARM by vectorizing it. [#122032](https://github.com/ClickHouse/ClickHouse/pull/122032) ([Raúl Marín](https://github.com/Algunenano)).
* `modulo` and `moduloOrNull` of two unsigned integers of different widths are faster again, as before 26.9, when the wider one is `UInt128` (about 3 to 4 times, for example `UInt128 % UInt16`) or the dividend is `UInt256` (1.6 to 2 times). [#123170](https://github.com/ClickHouse/ClickHouse/pull/123170) ([Groene AI](https://github.com/groeneai)).
* `exp10` is up to 2x faster by splitting its argument with `trunc` instead of the `modf` library call, with bitwise-identical results. [#122263](https://github.com/ClickHouse/ClickHouse/pull/122263) ([Konstantin Bogdanov](https://github.com/thevar1able)).
* Speed up `entropy` and multi-argument `uniqExact` on short strings by optimizing `SipHash` for short inputs. Hash values are unchanged. [#123658](https://github.com/ClickHouse/ClickHouse/pull/123658) ([Groene AI](https://github.com/groeneai)).
* `sumMap`, `minMap`, `maxMap`, `sumMapWithOverflow`, and `sumMapFiltered` over arrays are up to 2.3 times faster for integer, `Enum`, `Date`, `Date32`, and `DateTime` keys. [#124340](https://github.com/ClickHouse/ClickHouse/pull/124340) ([Groene AI](https://github.com/groeneai)).
* `h3PolygonToCells` and `h3PolygonToCellsWithContainment` are several times faster on polygons much smaller than a cell (9x on the query from the issue). This brings `h3PolygonToCells` back to the speed it had on such polygons before 26.8.12 and 26.9. Closes [#123877](https://github.com/ClickHouse/ClickHouse/issues/123877). [#123911](https://github.com/ClickHouse/ClickHouse/pull/123911) ([Groene AI](https://github.com/groeneai)).
* `isValidUTF8` validates a `String` or `FixedString` column with one `simdutf` call over the whole column instead of one call per row, which makes it up to 2.8 times faster on short strings. [#123835](https://github.com/ClickHouse/ClickHouse/pull/123835) ([Groene AI](https://github.com/groeneai)).
* Speed up `lowerUTF8` and `upperUTF8` on text whose non-ASCII characters are mostly two-byte UTF-8 (`U+0080` to `U+07FF`, e.g. Latin-1, Greek, Cyrillic): the column is processed in one pass, these characters are mapped from a table built from ICU, and ICU is called only for the rest of a row that contains other characters. [#123867](https://github.com/ClickHouse/ClickHouse/pull/123867) ([Groene AI](https://github.com/groeneai)).
* `lower`, `upper`, and the ASCII path of `lowerUTF8` and `upperUTF8` are now faster by using AVX2 or AVX-512 depending on the CPU. [#121374](https://github.com/ClickHouse/ClickHouse/pull/121374) ([Manuel](https://github.com/raimannma)).
* Speed up `lengthUTF8` and other `UTF-8` functions on long strings by counting code points 64 bytes at a time, on both x86 and ARM. [#122049](https://github.com/ClickHouse/ClickHouse/pull/122049) ([Raúl Marín](https://github.com/Algunenano)).
* Fixed ARM performance regressions in `indexOf` with a constant needle and in text output formats over non-ASCII strings. Closes [#123338](https://github.com/ClickHouse/ClickHouse/issues/123338). Closes [#123346](https://github.com/ClickHouse/ClickHouse/issues/123346). [#123377](https://github.com/ClickHouse/ClickHouse/pull/123377) ([Raúl Marín](https://github.com/Algunenano)).
* UTF-8 string functions such as `substringUTF8` are faster on long ASCII strings on CPUs with AVX-512. [#120088](https://github.com/ClickHouse/ClickHouse/pull/120088) ([Minh Vu](https://github.com/fallintoplace)).
* Improved performance of functions `extractKeyValuePairs` and `extractKeyValuePairsWithEscaping`. [#119361](https://github.com/ClickHouse/ClickHouse/pull/119361) ([Anton Popov](https://github.com/CurtizJ)).
* Function `mortonEncode` now resolves the type of each argument and the ratios of a constant range mask once per block instead of once per row, which makes it up to 2x faster. [#123354](https://github.com/ClickHouse/ClickHouse/pull/123354) ([Groene AI](https://github.com/groeneai)).
* Speed up `mortonDecode` on AArch64 by decoding with compile-time shift-and-mask sequences instead of a lookup table. The output is unchanged on every architecture. [#116205](https://github.com/ClickHouse/ClickHouse/pull/116205) ([Groene AI](https://github.com/groeneai)).
* `encrypt` and `aes_encrypt_mysql` are faster on values shorter than 16 bytes in the `aes-*-ecb` and `aes-*-cbc` modes (up to 2x for `encrypt` with `aes-128-ecb`). [#124103](https://github.com/ClickHouse/ClickHouse/pull/124103) ([Groene AI](https://github.com/groeneai)).
* Speed up `hex` and `unhex` with optimized `AVX` and `AVX2` implementations when they are available. [#123511](https://github.com/ClickHouse/ClickHouse/pull/123511) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Faster `toMillisecond`, `toMicrosecond`, and `toNanosecond` on `DateTime64`. [#122852](https://github.com/ClickHouse/ClickHouse/pull/122852) ([Samuel Krempaský](https://github.com/NIKTONIKTO717)).
* Speed up `reverse` for `String` and `FixedString` values. [#119462](https://github.com/ClickHouse/ClickHouse/pull/119462) ([Minh Vu](https://github.com/fallintoplace)).
* `arrayDistinct` is faster: it now does a single hash-table lookup per element instead of two, and `Decimal` arrays use a specialized fast path. [#113966](https://github.com/ClickHouse/ClickHouse/pull/113966) ([Manuel](https://github.com/raimannma)). [#121646](https://github.com/ClickHouse/ClickHouse/pull/121646) ([Minh Vu](https://github.com/fallintoplace)).
* Specialize `has` and `indexOf` searches in non-nullable numeric arrays when the needle is constant. [#119090](https://github.com/ClickHouse/ClickHouse/pull/119090) ([Minh Vu](https://github.com/fallintoplace)).
* `arrayFilter` is faster when the lambda keeps all or none of the elements of a block. [#119816](https://github.com/ClickHouse/ClickHouse/pull/119816) ([Minh Vu](https://github.com/fallintoplace)).
* Improve performance of `bitmapAndCardinality`, `bitmapOrCardinality`, `bitmapXorCardinality`, `bitmapAndnotCardinality`, and `bitmapHasAny` for `UInt64` and `Int64` bitmaps, which previously had to materialize the intersection to compute the result. On AArch64, `bitmapAndCardinality`, `bitmapOrCardinality`, `bitmapXorCardinality`, and `bitmapAndnotCardinality` no longer hit a rare code-layout-dependent slow path. [#120615](https://github.com/ClickHouse/ClickHouse/pull/120615) ([Ashish kumar choubey](https://github.com/aschoube)). [#123675](https://github.com/ClickHouse/ClickHouse/pull/123675) ([Groene AI](https://github.com/groeneai)).
* Restored the existing `Decimal` fast paths in `arrayCompact`. [#121245](https://github.com/ClickHouse/ClickHouse/pull/121245) ([Minh Vu](https://github.com/fallintoplace)).
* `uniqUpTo` now stops hashing after it exceeds its threshold. [#121247](https://github.com/ClickHouse/ClickHouse/pull/121247) ([Minh Vu](https://github.com/fallintoplace)).
* Restored the `FixedString` fast path for `arrayEnumerateUniq` and `arrayEnumerateDense`. [#121338](https://github.com/ClickHouse/ClickHouse/pull/121338) ([Minh Vu](https://github.com/fallintoplace)).
* `arrayReverse` is now faster for `Decimal` and wide integer arrays. [#121342](https://github.com/ClickHouse/ClickHouse/pull/121342) ([Minh Vu](https://github.com/fallintoplace)). [#121644](https://github.com/ClickHouse/ClickHouse/pull/121644) ([Minh Vu](https://github.com/fallintoplace)).
* Avoid copying `String` columns for `substring(s, 1)`. [#119820](https://github.com/ClickHouse/ClickHouse/pull/119820) ([Minh Vu](https://github.com/fallintoplace)).
* Skip KMP preprocessing for impossible `hasSubstr` searches. [#119824](https://github.com/ClickHouse/ClickHouse/pull/119824) ([Minh Vu](https://github.com/fallintoplace)).
* Speed up `arrayMin` and `arrayMax` for `Decimal` and `DateTime64` arrays. [#123507](https://github.com/ClickHouse/ClickHouse/pull/123507) ([Minh Vu](https://github.com/fallintoplace)).
* Speed up `arrayUniq` for `Decimal32`, `Decimal64`, and `Decimal128` arrays. [#122121](https://github.com/ClickHouse/ClickHouse/pull/122121) ([Minh Vu](https://github.com/fallintoplace)).
* Allow a single condition to constrain multiple key columns during index analysis. For example, if the primary key is `(toYYYYMMDD(dt), toDate(dt), dt)` and the query has `WHERE dt >= toDateTime('2026-01-10 00:00:00')`, all three key columns are now used for pruning, instead of only one of them as before. This behavior is controlled by the setting `analyze_index_with_multiple_key_columns_per_condition` (enabled by default). [#96225](https://github.com/ClickHouse/ClickHouse/pull/96225) ([Nihal Z. Miaji](https://github.com/nihalzp)).
* Left-side columns absent from a hash join's output (for example the join key in `SELECT count() ... LEFT JOIN ...`) are now pruned when only a spill threshold is set, as with the default `max_bytes_ratio_before_external_join`, instead of being carried through the pipeline. [#108191](https://github.com/ClickHouse/ClickHouse/pull/108191) ([Groene AI](https://github.com/groeneai)).
* Joins on null-safe comparison (`<=>`) of nullable keys use fixed-width hash keys instead of a serialized tuple. [#120596](https://github.com/ClickHouse/ClickHouse/pull/120596) ([Manuel](https://github.com/raimannma)).
* Fixed a quadratic slowdown of `JOIN` with `join_algorithm = 'hash'` when `ON` has a non-equality condition or several `OR` conditions. [#121209](https://github.com/ClickHouse/ClickHouse/pull/121209) ([nt](https://github.com/namtran1812)).
* Faster parsing of floating-point numbers from text formats. Update `fast_float` to v8.3.2. [#121383](https://github.com/ClickHouse/ClickHouse/pull/121383) ([Actuele AI](https://github.com/actueleai)).
* Query plan optimizations can now use the sort order reported by any table engine, not only `MergeTree`, avoiding unnecessary sorting. [#121858](https://github.com/ClickHouse/ClickHouse/pull/121858) ([Ivan Zhukov](https://github.com/zhkvia)).
* Slightly reduce the per-block overhead of aggregation by not copying the columns of the block when preparing the aggregate function instructions. [#124819](https://github.com/ClickHouse/ClickHouse/pull/124819) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* `GROUP BY` by several keys, which requires the serialization of keys, serializes the keys of a block in chunks that fit in the CPU cache instead of all at once. This makes such queries faster when many threads are used, for example, ClickBench Q18 is 37% faster on a 96-core machine. [#124955](https://github.com/ClickHouse/ClickHouse/pull/124955) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Added the setting `cluster_function_wait_for_replica_ms` (default `0`, disabled), which lets cluster table functions wait for the replica assigned a file to connect before giving that file to another replica. This improves file distribution when replicas start at different times. Work stealing now takes files from the active replica with the most remaining bytes without scanning all unprocessed files. [#125611](https://github.com/ClickHouse/ClickHouse/pull/125611) ([Konstantin Vedernikov](https://github.com/scanhex12)).
* The `SLRU` filesystem cache policy now moves a partially downloaded file segment to the protected queue on a cache hit, as it does for a fully downloaded one. Before, a scan could evict the data of narrow reads from the probationary queue. [#125657](https://github.com/ClickHouse/ClickHouse/pull/125657) ([Sema Checherinda](https://github.com/CheSema)).
#### Improvement
* Lightweight updates (the `UPDATE` statement and patch parts) are now generally available instead of Beta. The `enable_lightweight_update` setting is now in the production feature tier. [#125719](https://github.com/ClickHouse/ClickHouse/pull/125719) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Cluster discovery is no longer experimental: clusters with a `discovery` section in `remote_servers` work without enabling `allow_experimental_cluster_discovery`. The setting is now obsolete. [#123917](https://github.com/ClickHouse/ClickHouse/pull/123917) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* The Kusto (KQL) and Trino query dialects were promoted from experimental to beta. They are still enabled with the `allow_experimental_kusto_dialect` and `enable_trino_dialect` settings. [#124750](https://github.com/ClickHouse/ClickHouse/pull/124750) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Tables and databases can now be addressed through URL paths in the HTTP interface by default: `curl http://localhost:8123/my_db/my_table.csv` now works without extra configuration. The settings `http_allow_path_requests`, `http_allow_database_as_path`, `http_allow_table_as_file`, and `http_allow_filters_as_path` are enabled by default; `http_allow_filters_as_unrecognized_url_parameters` stays disabled. [#121143](https://github.com/ClickHouse/ClickHouse/pull/121143) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* The `all_...` union tables over the system log tables (`system.all_query_log`, `system.all_text_log`, and so on) are now created by default: the default server configuration enables the `create_union_system_log_tables` section with `merge_rotated_tables`, so queries over the rotated versions of a log no longer have to remember constructs like `merge(system, '^query_log')`. The `cluster` setting is shown as a commented-out example, because the table definitions would reference the cluster and require it to exist. [#117943](https://github.com/ClickHouse/ClickHouse/pull/117943) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* In a `DataLakeCatalog` database with `allow_experimental_iceberg_compaction = 1`, only `Iceberg` tables are now cached. `DeltaLake` and `Paimon` tables no longer keep the first schema they saw, so `SELECT *` and `DESCRIBE` pick up added columns without recreating the database or restarting the server. Closes [#122548](https://github.com/ClickHouse/ClickHouse/issues/122548). [#122568](https://github.com/ClickHouse/ClickHouse/pull/122568) ([Groene AI](https://github.com/groeneai)).
* The background memory worker now corrects the global memory tracker from real memory usage on every tick (server setting `memory_worker_correct_memory_tracker`, enabled by default). Previously the tracker was a pure counter that was re-baselined only at startup and when it went negative, so upward accounting drift was permanent: servers were observed refusing every query with `MEMORY_LIMIT_EXCEEDED`, reporting more than 100 GiB in use while actually using 7 GiB, until restart. The drift itself remains visible as the difference between the `MemoryTrackingUncorrected` and `MemoryTracking` metrics. [#118094](https://github.com/ClickHouse/ClickHouse/pull/118094) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* The AI function per-query quotas are now disabled by default: `ai_function_max_input_tokens_per_query`, `ai_function_max_output_tokens_per_query`, and `ai_function_max_api_calls_per_query` default to `0`, meaning no limit. To keep the previous caps, set the three settings explicitly or use `compatibility = '26.9'`. [#121424](https://github.com/ClickHouse/ClickHouse/pull/121424) ([George Larionov](https://github.com/george-larionov)).
* Named `Tuple` columns in `Pretty` formats are now displayed as subcolumns, with the element names shown in additional header and footer lines. Controlled by the new setting `output_format_pretty_named_tuples_as_subcolumns` (enabled by default). A named tuple rendered inside one cell, for example nested in an `Array` or when the setting is disabled, is still displayed according to `output_format_pretty_named_tuples_as_json`. [#78927](https://github.com/ClickHouse/ClickHouse/pull/78927) ([Engel Danila](https://github.com/aaaengel)).
* Show the query result in `Pretty` formats as soon as it arrives. Previously a query that returns a few rows early and then keeps reading, such as `SELECT DISTINCT` over a large table, displayed nothing until it finished or was cancelled. A later fix prevents a background write error after the query has finished from surfacing as a late `LOGICAL_ERROR`. [#117005](https://github.com/ClickHouse/ClickHouse/pull/117005) ([Alexey Milovidov](https://github.com/alexey-milovidov)). [#125028](https://github.com/ClickHouse/ClickHouse/pull/125028) ([Groene AI](https://github.com/groeneai)).
* Display non-printable control characters as Unicode "Control Pictures" in the `Vertical` and `Pretty*` output formats by default, so they are no longer silently swallowed and no longer deform the table. `TAB`, the line feed, and `ESC` are excluded, because a terminal interprets them rather than swallowing them. The new setting `output_format_pretty_display_control_characters` can be disabled to restore raw-byte output. [#101774](https://github.com/ClickHouse/ClickHouse/pull/101774) ([Yash ](https://github.com/Onyx2406)).
* Expired authentication methods are now removed from a user automatically. Every `ALTER USER` drops the authentication methods whose `VALID UNTIL` deadline has already passed and keeps all the others, so short-lived credentials can be rotated indefinitely with `ALTER USER ... ADD IDENTIFIED WITH ... VALID UNTIL ...` without the expired ones accumulating against `max_authentication_methods_per_user`. A method added by the same statement is not affected, and a user whose every method is expired keeps them rather than being left with no way to authenticate. [#118880](https://github.com/ClickHouse/ClickHouse/pull/118880) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* On `ReplicatedMergeTree`, the sync value `3` (`mutations_sync`, `lightweight_deletes_sync`, `alter_sync`) now waits for the active replicas, as documented, instead of all of them, so an inactive replica no longer causes `UNFINISHED`. This also affects `OPTIMIZE`, `TRUNCATE`, `DROP`/`DETACH PARTITION`, `REPLACE PARTITION`, and `MOVE PARTITION TO TABLE`. [#120592](https://github.com/ClickHouse/ClickHouse/pull/120592) ([Nikolay Degterinsky](https://github.com/evillique)).
* A number written directly as the first argument of `CAST` is now read with the target type when that type reads it more precisely than the number itself carries it, such as a `Decimal` or an integer wider than 64 bits. `Nullable`, `Array`, and `LowCardinality` of those types take the same exact path. [#116043](https://github.com/ClickHouse/ClickHouse/pull/116043) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* `TTL ... GROUP BY (a, b, c)` is now accepted and means the same as `TTL ... GROUP BY a, b, c`, matching how `ORDER BY (a, b, c)` works. Previously the parenthesized form was rejected with `TTL Expression GROUP BY key should be a prefix of primary key`. [#118426](https://github.com/ClickHouse/ClickHouse/pull/118426) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* `sequenceMatch`, `sequenceCount`, and `sequenceMatchEvents` now accept a `DateTime64` timestamp instead of failing. Events are ordered at the column's full precision, so two events within the same second are no longer ambiguous. [#118427](https://github.com/ClickHouse/ClickHouse/pull/118427) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* `argMin` and `argMax` now consistently return the value from the first row among rows with the same minimum or maximum within a block, matching `argMinIf` and `argMaxIf`. [#122892](https://github.com/ClickHouse/ClickHouse/pull/122892) ([Raúl Marín](https://github.com/Algunenano)).
* Added the setting `analyzer_compatibility_allow_cte_redefinition`. When enabled, a CTE name may be defined more than once in a single `WITH` clause; a later definition shadows the earlier one as the query analysis before 24.3 did. `MATERIALIZED` CTEs and CTEs in `WITH RECURSIVE` cannot be redefined. [#121623](https://github.com/ClickHouse/ClickHouse/pull/121623) ([Dmitry Novik](https://github.com/novikd)).
* Added settings `semi_join_include_columns_from_both_sides` and `anti_join_include_columns_from_both_sides` (enabled by default) for `SEMI` and `ANTI` joins in the analyzer. When enabled, behavior is unchanged: columns from both sides are accessible after the join. Disable either setting to enforce SQL-standard semantics, where only the preserved side's columns are visible after the join. [#96662](https://github.com/ClickHouse/ClickHouse/pull/96662) ([Zhang Yifan](https://github.com/zhangyifan27)).
* The setting `aggregate_function_input_format` with the values `value` and `array` now works in every input format, including `RowBinary`, `Native`, and `Parquet`, and for `AggregateFunction` nested in `Array`, `Tuple`, and `Map`. In the JSON formats the value is now a JSON value, for example `{"x": [1, 2, 3]}`, not a string containing it. [#121120](https://github.com/ClickHouse/ClickHouse/pull/121120) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Compression codec names and their keyword arguments are now matched case-insensitively, so `CODEC(zstd)` works like `CODEC(ZSTD)` and `ALP(std)` like `ALP(STD)`. Previously a codec whose name is mixed-case, such as `Delta`, `DoubleDelta`, `Gorilla` or `Quantized`, could not be used in the `default_compression_codec`, `marks_compression_codec` and `primary_key_compression_codec` settings, nor in the `` section of the server configuration, because those paths upper-cased the codec name. [#119313](https://github.com/ClickHouse/ClickHouse/pull/119313) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Added aliases `allow_suspicious_indexes`, `ignore_data_skipping_indexes`, `force_data_skipping_indexes`, and `secondary_indexes_enable_bulk_filtering` for the settings spelled with `indices`, so both plural forms are accepted. [#122565](https://github.com/ClickHouse/ClickHouse/pull/122565) ([Mohammed Sohail](https://github.com/msohail22)).
* `APPLY (f, 'prefix')` now keeps the table qualifier in generated column names. [#122702](https://github.com/ClickHouse/ClickHouse/pull/122702) ([Groene AI](https://github.com/groeneai)).
* Async insert now supports eligible single-block local `INSERT ... SELECT` queries, with synchronous fallback for larger, multi-block, empty, transactional, or non-parallel-quorum inserts. [#111663](https://github.com/ClickHouse/ClickHouse/pull/111663) ([Mikhail f. Shiryaev](https://github.com/Felixoid)).
* Added the opt-in `optimize_row_order_if_no_order_by` setting for `MergeTree` tables with an empty sorting key (`ORDER BY ()` / `ORDER BY tuple()`). When enabled, it applies row-order optimization automatically to inserts into such tables. [#104591](https://github.com/ClickHouse/ClickHouse/pull/104591) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* `WHATIF` can now estimate hypothetical projections without reading the whole table: past `max_rows_to_scan` rows it estimates from a sample of granules and reports the resulting range in `marks_span`, `max_rows_to_read` lowers that budget, and it follows `(prefer|force)_optimize_projection`. It now also uses the real projection-optimizer weighing logic, so its verdicts, reasons, and pruned ranges track the optimizer more closely. [#118233](https://github.com/ClickHouse/ClickHouse/pull/118233) ([Yarik Briukhovetskyi](https://github.com/yariks5s)). [#121766](https://github.com/ClickHouse/ClickHouse/pull/121766) ([Yarik Briukhovetskyi](https://github.com/yariks5s)). [#122060](https://github.com/ClickHouse/ClickHouse/pull/122060) ([Yarik Briukhovetskyi](https://github.com/yariks5s)). [#123540](https://github.com/ClickHouse/ClickHouse/pull/123540) ([Yarik Briukhovetskyi](https://github.com/yariks5s)). [#123587](https://github.com/ClickHouse/ClickHouse/pull/123587) ([Yarik Briukhovetskyi](https://github.com/yariks5s)).
* Added the setting `parallel_replicas_for_queries_with_multiple_tables` (default `true`) to control whether parallel replicas are used for queries joining multiple tables. When disabled, parallel replicas are not used for queries with `JOIN`, where the non-leftmost side is read in full on every replica. The setting does not affect a `UNION` query without a `JOIN`, where each branch is an independent single-table read, nor `ARRAY JOIN`. [#76595](https://github.com/ClickHouse/ClickHouse/pull/76595) ([Igor Nikonov](https://github.com/devcrafter)).
* `max_joined_block_size_rows` and `max_joined_block_size_bytes` now also bound the result blocks of `parallel_hash` and `grace_hash` joins: squashing of the join output no longer merges blocks past these limits. Closes [#124198](https://github.com/ClickHouse/ClickHouse/issues/124198). [#124304](https://github.com/ClickHouse/ClickHouse/pull/124304) ([Groene AI](https://github.com/groeneai)).
* Added the setting `query_plan_filter_push_down_below_limit_by` (default `1`), controlling whether filters on `LIMIT BY` key columns are pushed below the `LIMIT BY` step. Setting it to `0` restores the plan shape used before 26.7, for queries where the pushed predicate makes index analysis costlier than the scan it saves. [#121675](https://github.com/ClickHouse/ClickHouse/pull/121675) ([Groene AI](https://github.com/groeneai)).
* Added the `use_aggregation_memory_tracker` setting to choose how `GROUP BY` measures memory when deciding on two-level aggregation. `compatibility` below `26.9` restores the measurement used before 26.7. [#124439](https://github.com/ClickHouse/ClickHouse/pull/124439) ([Hechem Selmi](https://github.com/m-selmi)).
* `system.query_log` and `system.processes` now report the metrics of each task of a distributed query plan (`make_distributed_plan = 1`) in a row of its own: a task is a secondary query with its own `query_id`, correlated to the statement that started it by `initial_query_id`. The initiator's row reports its own work instead of the volume its tasks read. [#120949](https://github.com/ClickHouse/ClickHouse/pull/120949) ([Groene AI](https://github.com/groeneai)).
* `system.query_log` now records the databases, tables, and columns read by a replica that executes a query plan shipped to it, which happens with `parallel_replicas_plan_based`. [#122657](https://github.com/ClickHouse/ClickHouse/pull/122657) ([Igor Nikonov](https://github.com/devcrafter)).
* Queries with `send_logs_level` now also forward text logs from stateless `make_distributed_plan` workers through the coordinator, so worker-side exception context reaches the client. [#118603](https://github.com/ClickHouse/ClickHouse/pull/118603) ([Antonio Filipovic](https://github.com/antoniofilipovic)).
* The setting `parallel_replicas_insert_select_local_pipeline` is obsolete. It was a workaround for a performance problem fixed in 25.5, and it duplicated `parallel_replicas_local_plan`, which already decides whether the initiator reads its own share of a distributed `INSERT SELECT`. Use `parallel_replicas_local_plan = 0` to leave all the reading to the remote replicas. [#121653](https://github.com/ClickHouse/ClickHouse/pull/121653) ([Igor Nikonov](https://github.com/devcrafter)).
* Distributed `SELECT` queries now emit one OpenTelemetry span per remote shard read, with attributes such as `clickhouse.cluster`, `clickhouse.shard_num`, `clickhouse.processed_stage`, `clickhouse.query_id`, `clickhouse.initial_query_id`, and `clickhouse.target_host`, so slow or failed shards can be identified directly from `system.opentelemetry_span_log`. [#115784](https://github.com/ClickHouse/ClickHouse/pull/115784) ([Diego Gomes Tomé](https://github.com/diegomestre2)).
* Reads with parallel replicas are now covered by OpenTelemetry spans: a summary span with the totals of the coordination, one span per announcement and per read request handled by the coordinator, and `clickhouse.replica_num` on the per-replica spans, so the work distribution between replicas can be inspected in `system.opentelemetry_span_log`. [#118570](https://github.com/ClickHouse/ClickHouse/pull/118570) ([Diego Gomes Tomé](https://github.com/diegomestre2)).
* Added profile events for network activity: `DNSRequests`, `DNSRequestMicroseconds`, and `DNSRequestError`; `DNSReverseRequests`, `DNSReverseRequestMicroseconds`, and `DNSReverseError`; `TLSHandshakes`, `TLSHandshakeMicroseconds`, and `TLSHandshakeErrors`; `TLSServerHandshakes`, `TLSServerHandshakeMicroseconds`, and `TLSServerHandshakeErrors`; and `HTTPServerConnectionsErrors`. DNS now exposes timing as well as error counts, and TLS handshakes are now observable. [#116136](https://github.com/ClickHouse/ClickHouse/pull/116136) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Added the `AsyncInsertFlush` profile event. Compare it with `AsyncInsertQuery` to see how many queries are batched into one asynchronous `INSERT` flush. [#120187](https://github.com/ClickHouse/ClickHouse/pull/120187) ([Sema Checherinda](https://github.com/CheSema)).
* Add the `RuntimeFilterLookupsBeforeBuildFinished` profile event, counting blocks that a JOIN runtime filter passed through unfiltered because its build side had not finished yet (for example with `join_overflow_mode = 'break'` and a finite `max_rows_in_join` / `max_bytes_in_join`). [#107108](https://github.com/ClickHouse/ClickHouse/pull/107108) ([Groene AI](https://github.com/groeneai)).
* Added `last_error_symbols` and `last_error_lines` to `system.errors` and `system.error_log`. Closes [#74561](https://github.com/ClickHouse/ClickHouse/issues/74561). [#100374](https://github.com/ClickHouse/ClickHouse/pull/100374) ([Narasimha Pakeer](https://github.com/npakeer)).
* `system.processors_profile_log` now has entries for queries that fail with an exception, and new columns `exception_code` and `exception`. [#121503](https://github.com/ClickHouse/ClickHouse/pull/121503) ([Aleksandr Efimov](https://github.com/alexandrefimov)).
* `DROP TABLE` and `DROP DATABASE` now write a `RemovePart` event to `system.part_log` for every part of the dropped table, as merges, `DROP PARTITION`, and `TRUNCATE` already do. [#122093](https://github.com/ClickHouse/ClickHouse/pull/122093) ([Garrett Thomas](https://github.com/garrettthomaskth)).
* Added the server setting `min_allocation_size_to_log_stack_trace`. When a single charge to the global memory tracker reaches it, the stack trace is written to the server log and to `system.trace_log` with trace type `MemoryLargeAllocation`. This helps attribute a global tracked total that has grown far beyond real memory usage, a state in which the server refuses every allocation while far below its limit. Default `0` keeps it off. [#119527](https://github.com/ClickHouse/ClickHouse/pull/119527) ([Groene AI](https://github.com/groeneai)).
* Show throttler and workload IO scheduler wait time in the client progress bar (`ThrottlerSleepMicroseconds`, `SchedulerIOReadWaitMicroseconds` and `SchedulerIOWriteWaitMicroseconds` are summed into the `waited` figure, and the stalled sections of the bar are colored yellow). [#118536](https://github.com/ClickHouse/ClickHouse/pull/118536) ([Azat Khuzhin](https://github.com/azat)).
* `EXPLAIN ANALYZE time=1` shows more information about time and parallelism of every step. [#114786](https://github.com/ClickHouse/ClickHouse/pull/114786) ([Kirill Kopnev](https://github.com/Fgrtue)).
* Peak-memory reporting under `EXPLAIN ANALYZE` now accounts for aggregation correctly. [#123324](https://github.com/ClickHouse/ClickHouse/pull/123324) ([Azat Khuzhin](https://github.com/azat)).
* Removed nine unneeded `ProfileEvents`: the eight never-incremented `DistributedIndexAnalysisParts`, `ParallelReplicasDeniedRequests`, `WasmMemoryAllocated`, `S3QueueSetFileProcessingMicroseconds`, `S3QueueSetFileProcessedMicroseconds`, `S3QueueSetFileFailedMicroseconds`, `FileSegmentRemoveMicroseconds`, and `ExternalDataSourceLocalCacheReadBytes`, plus the duplicate `CachedReadBufferPredownloadedBytes`, which always matched `CachedReadBufferPredownloadedFromSourceBytes`. This reduces per-query memory and bookkeeping overhead; queries and dashboards should use `CachedReadBufferPredownloadedFromSourceBytes`. [#123040](https://github.com/ClickHouse/ClickHouse/pull/123040) ([Raúl Marín](https://github.com/Algunenano)). [#123042](https://github.com/ClickHouse/ClickHouse/pull/123042) ([Raúl Marín](https://github.com/Algunenano)).
* Killing a query that is loading skip-index marks from object storage now stops the read promptly: the remote read path checks query cancellation before each buffer fill, instead of reading on for minutes after the query was already cancelled. [#113436](https://github.com/ClickHouse/ClickHouse/pull/113436) ([Groene AI](https://github.com/groeneai)).
* Reduced cancellation latency for `GROUP BY ... WITH TOTALS` queries: `KILL QUERY` now interrupts totals accumulation within a single chunk instead of waiting for all aggregate states to be merged. [#119470](https://github.com/ClickHouse/ClickHouse/pull/119470) ([Roman Vasin](https://github.com/rvasin)).
* `KILL QUERY` and Ctrl+C in `clickhouse-client` now cancel long-running functions inside `WHERE` and `HAVING` filters instead of waiting for the function to finish. [#112705](https://github.com/ClickHouse/ClickHouse/pull/112705) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* `KILL MUTATION`, `SYSTEM STOP MERGES`, `DETACH`/`DROP` of a table, `REPLACE`/`ATTACH PARTITION ... FROM` and server shutdown now stop a running mutation within a fraction of a second when the mutation's predicate has an `IN (subquery)` whose subquery works without reading new data (for example a cross join). Previously they waited until the whole set was built, and `REPLACE`/`ATTACH PARTITION ... FROM` gave up with `TIMEOUT_EXCEEDED` after 120 seconds. `KILL MUTATION` now also stops a mutation that is already writing its new part. [#124122](https://github.com/ClickHouse/ClickHouse/pull/124122) ([Groene AI](https://github.com/groeneai)).
* `KILL QUERY` and `max_execution_time` (with the default `timeout_overflow_mode = 'throw'`) now interrupt writing the `Parquet` format in the middle of a block that is split into many row groups (for example with a small `output_format_parquet_row_group_size`), instead of only after the whole block is written. [#125489](https://github.com/ClickHouse/ClickHouse/pull/125489) ([Groene AI](https://github.com/groeneai)).
* `DROP TABLE`, `DETACH TABLE`, server shutdown, and `ALTER TABLE ... MODIFY SETTING refresh_statistics_interval` no longer wait for a background refresh of the statistics cache of a `MergeTree` table to read every part. On object storage with thousands of parts this wait could take minutes per table and delay a restart. Closes [#125136](https://github.com/ClickHouse/ClickHouse/issues/125136). [#125165](https://github.com/ClickHouse/ClickHouse/pull/125165) ([Groene AI](https://github.com/groeneai)).
* `DROP TABLE` and other operations that cancel merges and mutations no longer wait for an in-progress `vector_similarity` index build to finish. [#123062](https://github.com/ClickHouse/ClickHouse/pull/123062) ([Raúl Marín](https://github.com/Algunenano)). [#123739](https://github.com/ClickHouse/ClickHouse/pull/123739) ([Raúl Marín](https://github.com/Algunenano)).
* `KILL QUERY WHERE query_id = ''` now cancels the caller's own query without requiring `SELECT` on `system.processes`. For a caller holding neither that grant nor `KILL QUERY`, an id that is not running as them cancels nothing and returns no rows. Any other `WHERE` condition keeps requiring the privileges it requires today. [#117999](https://github.com/ClickHouse/ClickHouse/pull/117999) ([Groene AI](https://github.com/groeneai)).
* Access to `system.jemalloc_profile_text`, `system.jemalloc_sampled_allocations`, `system.jemalloc_bins`, `system.jemalloc_arena_bins`, and `system.jemalloc_stats` now requires `SYSTEM_JEMALLOC`; the heap profiles flushed by `system.jemalloc_profile_text` and `system.jemalloc_sampled_allocations` are also removed after being returned. [#121622](https://github.com/ClickHouse/ClickHouse/pull/121622) ([Azat Khuzhin](https://github.com/azat)). [#121634](https://github.com/ClickHouse/ClickHouse/pull/121634) ([Azat Khuzhin](https://github.com/azat)).
* Added the `access_control_improvements.readonly_restricts_set_role` server setting, `false` by default. When enabled, `SET ROLE` is refused with `READONLY` in a session or query whose `readonly` setting is not zero. Previously `SET ROLE` was the only identity-changing statement that `readonly` did not refuse. [#118021](https://github.com/ClickHouse/ClickHouse/pull/118021) ([Groene AI](https://github.com/groeneai)).
* Secret arguments of table functions, table engines, database engines, backup engines, and dictionary sources are now declared next to each feature and are masked consistently in `SHOW CREATE`, system tables, query logs, and `EXPLAIN AST`, instead of relying on a central hardcoded parser list. [#123364](https://github.com/ClickHouse/ClickHouse/pull/123364) ([Raúl Marín](https://github.com/Algunenano)).
* The `PostgreSQL`, `MaterializedPostgreSQL`, `DataLakeCatalog`, `Cluster`, `Remote`, and `HDFS` database engines key the exemption for the server's replay of its own stored metadata on the metadata loader instead of on the query being internal. A `HDFS` database restored with `RESTORE DATABASE` is now checked against `remote_url_allow_hosts`. [#120280](https://github.com/ClickHouse/ClickHouse/pull/120280) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Allow `remote_url_allow_hosts` to match the bucket name of an `S3` URL. [#124453](https://github.com/ClickHouse/ClickHouse/pull/124453) ([Konstantin Vedernikov](https://github.com/scanhex12)).
* Support proxy credentials in the `http_proxy` and `https_proxy` environment variables. Previously the userinfo part of the proxy URI was discarded, so ClickHouse could not use an authenticating proxy. Proxy credentials are sent only to the proxy, rather than to the target server inside a `CONNECT` tunnel. [#123069](https://github.com/ClickHouse/ClickHouse/pull/123069) ([Akanshaak](https://github.com/Akanshaak)). [#124396](https://github.com/ClickHouse/ClickHouse/pull/124396) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Interserver authentication failures on a listener that uses the PROXY protocol now record the client address from the PROXY header in `system.session_log` when `auth_use_forwarded_address` is enabled, instead of the proxy address. [#125326](https://github.com/ClickHouse/ClickHouse/pull/125326) ([Groene AI](https://github.com/groeneai)).
* Added the `tcp_with_proxy_allow_interserver_mode` server setting, which allows disabling the native protocol's interserver mode on `tcp_with_proxy_port`. [#123188](https://github.com/ClickHouse/ClickHouse/pull/123188) ([Pradeep Chhetri](https://github.com/chhetripradeep)).
* Reject unexpected packets in the native protocol before deserializing their payload, avoiding unnecessary processing of data types and aggregate function states before returning `UNEXPECTED_PACKET_FROM_CLIENT`. [#119368](https://github.com/ClickHouse/ClickHouse/pull/119368) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Added the setting `kill_throw_if_noop`, enabled by default, which makes local `KILL QUERY` and `KILL MUTATION` statements throw `NO_QUERY_TO_KILL` when their selection produces no eligible target. `ON CLUSTER` execution remains tolerant of empty matches. Set `kill_throw_if_noop = false` to preserve the previous behavior. Related [#83348](https://github.com/ClickHouse/ClickHouse/issues/83348). [#85023](https://github.com/ClickHouse/ClickHouse/pull/85023) ([zwy991114](https://github.com/zwy991114)).
* Merges and queries on `S3` disks no longer hold one HTTP connection per open stream for their whole duration once connections are scarce. Previously this let a few merges of tables with many substreams, for example a `JSON` column, saturate `disk_connections_hard_limit`, stall each other, and fail every other request to the disks with `HTTP_CONNECTION_LIMIT_REACHED`. Once the `Disk` connection group is at or above `disk_connections_soft_limit`, reads from `S3` disks fetch each buffer fill with a separate request and return the connection to the pool between fills; the new profile event `ReadBufferFromS3RequestsCut` counts such requests. [#119730](https://github.com/ClickHouse/ClickHouse/pull/119730) ([Alexey Milovidov](https://github.com/alexey-milovidov)). [#124701](https://github.com/ClickHouse/ClickHouse/pull/124701) ([Groene AI](https://github.com/groeneai)).
* The `filesystem_cache_boundary_alignment` setting can now be changed per query. For disk reads, `0` means to use the cache configuration's `boundary_alignment`; for non-disk reads, `0` still disables alignment. [#118791](https://github.com/ClickHouse/ClickHouse/pull/118791) ([Kseniia Sumarokova](https://github.com/kssenii)).
* Added the filesystem cache setting `use_real_disk_size` (disabled by default), which accounts for cache reservations in filesystem allocation units instead of raw bytes. It makes `FilesystemCacheSize`, eviction-size metrics, and `current_size` in `system.filesystem_cache_settings` approximate the disk footprint. The accounting is block-aligned rather than exact and can include reserve-ahead bytes of in-flight reads. [#79490](https://github.com/ClickHouse/ClickHouse/pull/79490) ([codeworse](https://github.com/codeworse)).
* Custom HTTP headers configured for S3 are now handled case-insensitively by name, so a header spelled `X-Amz-Meta-Foo` reaches Google Cloud Storage translated to `x-goog-meta-foo`, as `x-amz-meta-foo` already did. [#120014](https://github.com/ClickHouse/ClickHouse/pull/120014) ([Sema Checherinda](https://github.com/CheSema)).
* Better error messages for S3 request retries: the HTTP response code is no longer printed as `18446744073709551615` when the request received no response at all, and the misleading message about a possible time skew is no longer printed on every retry. [#118439](https://github.com/ClickHouse/ClickHouse/pull/118439) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Allow `DESCRIBE FILESYSTEM CACHE` on the introspection port. [#115894](https://github.com/ClickHouse/ClickHouse/pull/115894) ([Groene AI](https://github.com/groeneai)).
* Files on encrypted disks now support positional reads, so a table with a `UNIQUE KEY` on an encrypted disk can be loaded again after a server restart. [#119991](https://github.com/ClickHouse/ClickHouse/pull/119991) ([johnjing](https://github.com/JingYanchao)).
* The `url` table function and the `URL` table engine now expand glob patterns lazily instead of materializing every address before the query starts. `glob_expansion_max_elements` now limits how many addresses a query actually generates rather than how large the pattern is, so a query that stops early - for example under a `LIMIT` - can use a pattern that describes far more addresses than the limit. [#115680](https://github.com/ClickHouse/ClickHouse/pull/115680) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* `Iceberg` manifest writing now uses sequence-number inheritance: `ADDED` entries have `NULL` `sequence_number` and `file_sequence_number` unless compaction assigns an explicit sequence number. [#120031](https://github.com/ClickHouse/ClickHouse/pull/120031) ([Asya Shneerson](https://github.com/asya-ch)).
* `Iceberg` manifest statistics are now written for `boolean` and `fixed` columns. [#121548](https://github.com/ClickHouse/ClickHouse/pull/121548) ([Konstantin Vedernikov](https://github.com/scanhex12)).
* When a table is created through a catalog, `CREATE TABLE catalog.table ENGINE = IcebergS3` can now omit explicit credentials and reuse the catalog credentials. [#114477](https://github.com/ClickHouse/ClickHouse/pull/114477) ([Konstantin Vedernikov](https://github.com/scanhex12)).
* `ALTER TABLE ... EXECUTE expire_snapshots` now works for `Iceberg` tables in transactional catalogs such as Iceberg REST and Unity. [#123248](https://github.com/ClickHouse/ClickHouse/pull/123248) ([alesapin](https://github.com/alesapin)).
* A `DataLakeCatalog` database whose catalog cannot be built no longer reports its tolerated table-listing failure as an error of the query that enumerated it: the skipped database is now logged at `debug` instead of `error`, so a query such as `SELECT ... FROM system.tables` or `system.iceberg_history` no longer sends a server-side exception to a client whose `send_logs_level` includes `error`. Set `show_data_lake_catalogs_in_system_tables = 1` to have the real exception raised instead. [#121475](https://github.com/ClickHouse/ClickHouse/pull/121475) ([Groene AI](https://github.com/groeneai)).
* When a `DeltaLake` write commit fails, ClickHouse now always reports the commit error rather than an error raised while removing the data files the failed `INSERT` had already uploaded, and every removal that fails during that cleanup is logged with the path it was left on. Previously the first failing removal replaced the commit error in the response, so the reason nothing was written was lost and no path was logged. Closes [#122023](https://github.com/ClickHouse/ClickHouse/issues/122023). [#122123](https://github.com/ClickHouse/ClickHouse/pull/122123) ([Groene AI](https://github.com/groeneai)).
* Reading an `Iceberg` table whose position delete file has no `pos` or `file_path` column now fails with `ICEBERG_SPECIFICATION_VIOLATION` naming the file and the missing column, instead of a `LOGICAL_ERROR` (missing `pos`) or a misleading `UNKNOWN_IDENTIFIER` (missing `file_path`). [#123583](https://github.com/ClickHouse/ClickHouse/pull/123583) ([Groene AI](https://github.com/groeneai)).
* `Paimon` `BOOLEAN` columns are now read as `Bool` instead of `Int8`, matching `Iceberg` and `DeltaLake`. `DESCRIBE` and `toTypeName` now report `Bool`, and text formats render the values as `false` and `true` instead of `0` and `1`. [#119404](https://github.com/ClickHouse/ClickHouse/pull/119404) ([JIaQi Tang](https://github.com/JiaQiTang98)).
* Avro files now include per-column size statistics in their metadata. [#121392](https://github.com/ClickHouse/ClickHouse/pull/121392) ([Konstantin Vedernikov](https://github.com/scanhex12)).
* The `Parquet` reader now rejects a column chunk whose metadata has a negative `num_values`, `total_uncompressed_size`, or `unencoded_byte_array_data_bytes` with `INCORRECT_DATA` instead of failing later with a misleading memory-allocation error. It also caps memory estimates derived from these fields at the reader's watermarks and ignores pre-allocations too large to ever succeed, so absurdly large values no longer cause an internal error. Closes [#124224](https://github.com/ClickHouse/ClickHouse/issues/124224). [#124330](https://github.com/ClickHouse/ClickHouse/pull/124330) ([Groene AI](https://github.com/groeneai)).
* Bumped the bundled `ORC` library so that an `ORC` file declaring a compression codec the reader does not implement is rejected with an error naming the codec, instead of an internal error that debug and sanitizer builds treat as a failed assertion. [#115889](https://github.com/ClickHouse/ClickHouse/pull/115889) ([Groene AI](https://github.com/groeneai)).
* `INSERT ... VALUES` over a stream that fails mid-row now reports that read failure directly, instead of retrying the failed read while recovering from a parse error. This affects an HTTP request body that is shorter than its declared `Content-Length` and is streamed to the input format. [#121916](https://github.com/ClickHouse/ClickHouse/pull/121916) ([Groene AI](https://github.com/groeneai)).
* ClickHouse Keeper no longer drops the client session when the outgoing request queue stays full for longer than `operation_timeout_ms`. The enqueue wait is now three times `session_timeout_ms`, so a short burst of backpressure no longer invalidates the session's ephemeral nodes and watches. [#121559](https://github.com/ClickHouse/ClickHouse/pull/121559) ([Kseniia Sumarokova](https://github.com/kssenii)).
* ClickHouse Keeper now reports orphaned nodes in a snapshot as `CORRUPTED_DATA` instead of an opaque internal error. With `keeper_server.remove_orphaned_nodes_on_startup = true` and `keeper_server.digest_enabled = false`, it can also remove those nodes during startup so the snapshot still loads. [#95761](https://github.com/ClickHouse/ClickHouse/pull/95761) ([Seva Potapov](https://github.com/seva-potapov)).
* The Keeper `rcfg` command now honors its `retry` count per action, stops once `max_total_wait_time_ms` is exhausted, and rejects a negative `retry` before running any action. [#122758](https://github.com/ClickHouse/ClickHouse/pull/122758) ([Groene AI](https://github.com/groeneai)).
* Updated `NuRaft` to fix handling of abandoned peers when a removed server rejoins. [#120736](https://github.com/ClickHouse/ClickHouse/pull/120736) ([Antonio Andelic](https://github.com/antonio2368)).
* Added the setting `get_zookeeper_lock_acquire_timeout_ms` so Keeper-backed queries such as reads from `system.zookeeper`, `zookeeperSessionUptime`, and `SYSTEM RECONNECT ZOOKEEPER` can fail fast while another thread is reconnecting Keeper. [#94836](https://github.com/ClickHouse/ClickHouse/pull/94836) ([c-end](https://github.com/c-end)).
* Activating a replica whose `active` or `is_active` node in `Keeper` is still held by another session is now reported as `REPLICA_ALREADY_EXISTS` instead of `LOGICAL_ERROR`, so it no longer aborts the server in debug and sanitizer builds. The same applies when that node is rewritten while it is being removed. [#114408](https://github.com/ClickHouse/ClickHouse/pull/114408) ([Groene AI](https://github.com/groeneai)).
* The ZooKeeper client, the Graphite metrics writer, the Redis source, `system.zookeeper_info`, the distributed query exchange, and host names in `listen_host` and `bind_host` now resolve through the ClickHouse DNS cache, so these lookups are cached, visible in `system.dns_cache` and subject to `dns_allow_resolve_names_to_ipv4` and `dns_allow_resolve_names_to_ipv6`. Previously they resolved names on their own, bypassing the cache. [#120831](https://github.com/ClickHouse/ClickHouse/pull/120831) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Added the `http_x_clickhouse_format_overrides_output_format` setting (default `true`). When disabled, the `X-ClickHouse-Format` HTTP header only sets `default_format`, as it did before 26.8, instead of overriding a query's `FORMAT` clause via `output_format`. [#121132](https://github.com/ClickHouse/ClickHouse/pull/121132) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* The Prometheus HTTP API accepts `RFC3339` times with `Z` or a `+hh:mm` offset and fractional seconds in `time`, `start`, and `end`, as Prometheus does, so clients like vmalert work. String time arguments of `prometheusQuery`, `timeSeriesSelector`, and the `timeSeries*ToGrid` functions accept `RFC3339` too. [#122808](https://github.com/ClickHouse/ClickHouse/pull/122808) ([Valery Petrov](https://github.com/valerypetrov)).
* PromQL regex matchers that list plain literals, such as `{job=~"api|web"}`, now use the primary key and return exactly the listed values, as in Prometheus. Before, only the first alternative was anchored at the start and only the last at the end, so such a matcher also returned values like `api-server` or `myweb`. [#122796](https://github.com/ClickHouse/ClickHouse/pull/122796) ([Valery Petrov](https://github.com/valerypetrov)).
* PromQL instant queries now return series in a deterministic order: `topk` and `bottomk` at the root are sorted by value, as Prometheus returns them, and other instant queries are sorted by their labels, like range queries, so repeated requests list the series in the same order. [#122347](https://github.com/ClickHouse/ClickHouse/pull/122347) ([James Cunningham](https://github.com/JTCunning)). [#122976](https://github.com/ClickHouse/ClickHouse/pull/122976) ([Valery Petrov](https://github.com/valerypetrov)).
* `/api/v1/format_query` and PromQL serialization now print durations in Prometheus units, so `sum(rate(x[5m]))` formats as itself rather than as `sum(rate(x[300]))`. [#120939](https://github.com/ClickHouse/ClickHouse/pull/120939) ([Valery Petrov](https://github.com/valerypetrov)).
* PromQL now validates label names in `label_join` and `label_replace`. [#118190](https://github.com/ClickHouse/ClickHouse/pull/118190) ([Minh Vu](https://github.com/fallintoplace)).
* A Prometheus remote-write or remote-read request whose body cannot be decompressed is now answered with `400` instead of `500`, and the error names the size of the block and the uncompressed length it declares. [#120938](https://github.com/ClickHouse/ClickHouse/pull/120938) ([Valery Petrov](https://github.com/valerypetrov)).
* Added the `merge_selector_min_age_to_disable_right_tail_heuristic` `MergeTree` setting. It lets the `Simple` and `StochasticSimple` merge selectors include small parts at the right end of a range in merge candidates once every part in the range is old enough. [#122638](https://github.com/ClickHouse/ClickHouse/pull/122638) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Added the `MergeTree` settings `merge_selector_small_parts_min_count`, `merge_selector_small_parts_threshold`, and `merge_selector_small_parts_max_age` to reduce the number of merge operations under rapid small-part insertion by requiring a minimum batch size before merging small fresh parts. [#100436](https://github.com/ClickHouse/ClickHouse/pull/100436) ([Amos Bird](https://github.com/amosbird)).
* Calculate projections using the query analyzer and reject missing projection columns rather than writing incomplete projection parts. Row policies and `additional_table_filters` for `system.one` no longer affect projection calculation. [#118375](https://github.com/ClickHouse/ClickHouse/pull/118375) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* `ALTER TABLE ... ADD COLUMN ..., MODIFY ORDER BY ...` now rejects a new sorting key that uses a subcolumn of the added `DEFAULT` or `MATERIALIZED` column, and its error message names whether the expression kind is `DEFAULT` or `MATERIALIZED` instead of always saying `default expression`. [#121873](https://github.com/ClickHouse/ClickHouse/pull/121873) ([GON](https://github.com/gonappuccino)).
* An unresolved name in a column `DEFAULT`, `MATERIALIZED`, or `ALIAS` expression is now reported by the name the user wrote, instead of an internal `_tmp_alter` alias that appears nowhere in the query and also broke the "Maybe you meant" hint. A sorting, primary, or partition key that contains a nullable column or a constant now names that column or constant. [#116871](https://github.com/ClickHouse/ClickHouse/pull/116871) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Web UI: save and load the list of tabs, their queries, and query parameters as a Markdown file. The tab bar is now always shown, and the connection settings always live behind the key button in its corner. [#121234](https://github.com/ClickHouse/ClickHouse/pull/121234) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Web UI: added a `Format` button to the query editor, which formats the query with `formatQuery`. [#121652](https://github.com/ClickHouse/ClickHouse/pull/121652) ([Alexey Milovidov](https://github.com/alexey-milovidov)). [#122477](https://github.com/ClickHouse/ClickHouse/pull/122477) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Web UI: clicking a cell of a `JSON` column pretty-prints the value with two-space indentation and syntax highlighting. [#118640](https://github.com/ClickHouse/ClickHouse/pull/118640) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* The graph view of the Web UI for `EXPLAIN ... graph = 1` now follows the light/dark theme instead of always drawing a white canvas with black lines, and its labels use a sans-serif font instead of the Graphviz default. Rendering a graph also works when `play.html` is opened as a local file. [#116208](https://github.com/ClickHouse/ClickHouse/pull/116208) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* In the Web UI, the digits of a long number in the result table are now grouped by a thin gap, as in `1 234 567`, instead of an underline. The gap is an empty element, so selecting or copying the number still yields the digits alone. [#119839](https://github.com/ClickHouse/ClickHouse/pull/119839) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Show a checkmark on the Play UI result-table copy button for 1.2 s after a cell value is copied to the clipboard. [#120617](https://github.com/ClickHouse/ClickHouse/pull/120617) ([yanglongwei](https://github.com/ylw510)).
* In the Web UI, the browser window title of a renamed query tab is now exactly the tab's name. [#122067](https://github.com/ClickHouse/ClickHouse/pull/122067) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Web UI: when a login last succeeded with an empty password, a stale password autofilled by the browser's password manager for that server and user is no longer used. [#118638](https://github.com/ClickHouse/ClickHouse/pull/118638) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* The schema visualizer now supports hiding and showing table categories by clicking their legend labels, with a Hide all / Show all control. [#124963](https://github.com/ClickHouse/ClickHouse/pull/124963) ([Mark Needham](https://github.com/mneedham)).
* The command-line client no longer shows as-you-type hints on a query recalled from the history or otherwise displayed at once, so pressing Up/Down keeps navigating the history until the line is edited. [#115065](https://github.com/ClickHouse/ClickHouse/pull/115065) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* The progress bar in `clickhouse-client` and `clickhouse-local` no longer flickers when the query result is redirected to a pipe or a file. [#123549](https://github.com/ClickHouse/ClickHouse/pull/123549) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* A bare table name can now use the archive path syntax in `clickhouse-local`, so `SELECT * FROM 'archive.tar.zst::data.native'` reads a file inside an archive, like `SELECT * FROM file('archive.tar.zst::data.native')`. The same applies to tables of a `URL` database with a `file://` target and of a `Filesystem` database. [#118170](https://github.com/ClickHouse/ClickHouse/pull/118170) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Clean up client output when a web terminal or SSH session is closed during a running query, avoiding spurious write-buffer errors. [#125558](https://github.com/ClickHouse/ClickHouse/pull/125558) ([Groene AI](https://github.com/groeneai)).
* A musl-built ClickHouse binary is now self-contained enough to run in a `FROM scratch` container image with no extra files: CA certificates are embedded, `localhost` resolves to loopback even without `/etc/hosts`, and DNS no longer falls back to the unreachable localhost when `/etc/resolv.conf` is missing. [#115389](https://github.com/ClickHouse/ClickHouse/pull/115389) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Hedged requests are now supported on macOS. Previously `use_hedged_requests` was silently ignored on macOS and distributed queries always used non-hedged connections. [#119915](https://github.com/ClickHouse/ClickHouse/pull/119915) ([Raúl Marín](https://github.com/Algunenano)).
* Determine the number of CPUs from the kernel's sysfs lists instead of the libc, so per-CPU structures and `auto` thread counts do not depend on the libc's interpretation of the affinity mask. [#118912](https://github.com/ClickHouse/ClickHouse/pull/118912) ([Konstantin Bogdanov](https://github.com/thevar1able)).
* Workloads created without a parent workload are now allowed; they become children of an implicit root workload, so several workload trees can coexist. [#118578](https://github.com/ClickHouse/ClickHouse/pull/118578) ([Sergei Trifonov](https://github.com/serxa)).
* `RANDOMIZE FOR` is now applied on each replica of a refreshable materialized view independently, so a random replica performs each refresh instead of the same one every time. Replicas no longer agree on `next_refresh_time`, so the value reported by `system.view_refreshes` on one replica is the time that replica would refresh at, not necessarily when the refresh happens. Closes [#78410](https://github.com/ClickHouse/ClickHouse/issues/78410). [#112979](https://github.com/ClickHouse/ClickHouse/pull/112979) ([Groene AI](https://github.com/groeneai)).
* `FileLog` now reads a file again from the beginning if, at the next read, it is shorter than the offset already read from it (for example after `logrotate` with `copytruncate`), instead of failing every read of the table with `CANNOT_READ_ALL_DATA` until the file grows back to its old size. [#123390](https://github.com/ClickHouse/ClickHouse/pull/123390) ([Groene AI](https://github.com/groeneai)).
* A relative path in the `FileLog` table engine is now resolved against `user_files_path`, like in the `file` table function, so `FileLog('nginx/', 'JSONEachRow')` reads `/nginx/`. A relative path that already points inside `user_files_path` from the server's working directory keeps its meaning. [#123397](https://github.com/ClickHouse/ClickHouse/pull/123397) ([Groene AI](https://github.com/groeneai)).
* Connections from the `MongoDB` table engine, table function, and dictionary source now identify themselves to the MongoDB server with the ClickHouse name and version in the driver handshake metadata. MongoDB operators can tell ClickHouse connections apart from other clients in server logs, `currentOp` output, and monitoring tools. [#122205](https://github.com/ClickHouse/ClickHouse/pull/122205) ([bisht2050](https://github.com/bisht2050)).
* Lookups of `YTsaurus` dictionaries can now be throttled. [#100044](https://github.com/ClickHouse/ClickHouse/pull/100044) ([MikhailBurdukov](https://github.com/MikhailBurdukov)).
* AI functions using the `openai`, `huggingface`, or `tei` provider send the query ID and the initial query ID in the `X-ClickHouse-Query-Id` and `X-ClickHouse-Initial-Query-Id` HTTP headers. [#123622](https://github.com/ClickHouse/ClickHouse/pull/123622) ([George Larionov](https://github.com/george-larionov)).
* `aiFilter` now requests structured JSON Schema output. [#121526](https://github.com/ClickHouse/ClickHouse/pull/121526) ([Andrew Wilkins](https://github.com/axw)).
* WebAssembly UDF calls with `ABI BUFFERED_V1` now measure the whole input batch instead of one serialization per row, so usage is priced by the stream the guest actually receives for formats whose cost is not additive across rows. [#118989](https://github.com/ClickHouse/ClickHouse/pull/118989) ([Vasily Chekalkin](https://github.com/bacek)).
* Allow the `ON CLUSTER` clause for `RENAME TABLE` and `EXCHANGE TABLES` on a `Replicated` or Cloud `Shared` database when the cluster name matches the database's automatic cluster name. The clause is treated as a no-op and the database engine propagates the DDL as usual, which lets scripts written for non-`Replicated` databases be ported without rewriting `ON CLUSTER` clauses. [#106192](https://github.com/ClickHouse/ClickHouse/pull/106192) ([Groene AI](https://github.com/groeneai)).
* Stored HTTP handler queries no longer break when a request supplies `max_parser_depth`, `max_parser_backtracks`, or `max_query_size`, and the `CREATE HANDLER`, `ALTER HANDLER`, and `DROP HANDLER` documentation is now published. [#114883](https://github.com/ClickHouse/ClickHouse/pull/114883) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Improve memory tracking for query sources, including recursive CTEs and external data sources, so their container allocations count toward memory limits. [#124952](https://github.com/ClickHouse/ClickHouse/pull/124952) ([Nikita Taranov](https://github.com/nickitat)).
* A subquery with its own `SETTINGS` clause now plans `GROUP BY` using the settings after constraints and `max_threads` clamping are applied, instead of reapplying the clause as written. This prevents nested `SETTINGS max_threads = ...` from bypassing settings constraints or expanding the aggregation pipeline to an excessive number of streams. [#123156](https://github.com/ClickHouse/ClickHouse/pull/123156) ([Groene AI](https://github.com/groeneai)).
* Improved the error message of `parseDateTime`. [#120489](https://github.com/ClickHouse/ClickHouse/pull/120489) ([Robert Schulze](https://github.com/rschu1ze)).
* Restoring an invalid data part from backup now reports `BACKUP_DAMAGED` instead of `CORRUPTED_DATA`. [#113085](https://github.com/ClickHouse/ClickHouse/pull/113085) ([Alexander Tokmakov](https://github.com/tavplubix)).
* Deserializing an aggregate function state that declares an oversized element count now reports `TOO_LARGE_ARRAY_SIZE` and names both the offending count and the limit, instead of a bare `POCO_EXCEPTION` carrying no numbers. [#121381](https://github.com/ClickHouse/ClickHouse/pull/121381) ([Groene AI](https://github.com/groeneai)).
* A setting given a value of the wrong type or out of range now names the setting and the value in the error message. [#116882](https://github.com/ClickHouse/ClickHouse/pull/116882) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* When a dictionary with a `PostgreSQL` source and a custom `QUERY` returns its columns in an order that does not match the dictionary structure, the error now names the destination dictionary column and the column order the query must return, instead of only reporting that a value could not be parsed. [#114212](https://github.com/ClickHouse/ClickHouse/pull/114212) ([Groene AI](https://github.com/groeneai)).
* A `PostgreSQL` dictionary whose `QUERY` returns fewer columns than the dictionary structure now fails to load with a `NUMBER_OF_COLUMNS_DOESNT_MATCH` error that names the column order the `QUERY` must use, instead of a `LOGICAL_ERROR`. A `QUERY` that returns too many columns gets the same column-order hint. [#125397](https://github.com/ClickHouse/ClickHouse/pull/125397) ([Groene AI](https://github.com/groeneai)).
* A column matcher (`*`, `t.*`, `COLUMNS('...')`) inside `additional_table_filters`, `additional_result_filter` or a row policy is now rejected with a clear `BAD_ARGUMENTS` diagnostic instead of the obscure `Unqualified matcher * cannot be resolved. There are no table sources`. `CREATE` / `ALTER ROW POLICY` with a matcher now fails immediately. A matcher inside a subquery of such a filter, for example `x IN (SELECT * FROM allowed)`, keeps working. [#119250](https://github.com/ClickHouse/ClickHouse/pull/119250) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* A matcher (`*`, `t.*`, `COLUMNS(...)`) used as a whole `LIMIT AFTER` or `LIMIT UNTIL` boundary is now rejected with `UNEXPECTED_EXPRESSION`, as in `WHERE`, instead of failing with `std::out_of_range` or silently using only its first column. [#123309](https://github.com/ClickHouse/ClickHouse/pull/123309) ([Groene AI](https://github.com/groeneai)).
* `CREATE FUNCTION` now rejects a SQL user-defined function whose lambda arguments cannot be evaluated, instead of storing a function that later fails with `BAD_ARGUMENTS` on every call. Closes [#121197](https://github.com/ClickHouse/ClickHouse/issues/121197). [#121370](https://github.com/ClickHouse/ClickHouse/pull/121370) ([Groene AI](https://github.com/groeneai)).
* A correlated subquery in `HAVING` of a `WITH TOTALS` query that also uses `max_rows_to_group_by` with `group_by_overflow_mode = 'any'` (and `totals_mode` other than `after_having_exclusive`) now fails with `NOT_IMPLEMENTED` instead of a logical error. [#122601](https://github.com/ClickHouse/ClickHouse/pull/122601) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* The `mergeTreeAnalyzeIndexes` and `mergeTreeAnalyzeIndexesUUID` table functions now reject a `vector_search_index_analysis` limit above `max_limit_for_vector_search_queries`, the bound under which the plan optimization rewrites a vector search query. A larger limit previously made the vector similarity index reserve memory proportional to it and exhaust the server's memory. [#122154](https://github.com/ClickHouse/ClickHouse/pull/122154) ([Groene AI](https://github.com/groeneai)).
* An unconditioned `CROSS JOIN` is no longer reported as `INNER` in `EXPLAIN` and in the join columns of `system.query_log` when the `dpsub` join order algorithm runs with a conflict detector enabled. Query results were not affected. [#122236](https://github.com/ClickHouse/ClickHouse/pull/122236) ([Fisnik Kastrati](https://github.com/fkastrati)).
* Formatting a query where an `IN` is the left operand of a tuple element (`(x IN (1)).1`) inside a multi-argument function call is now stable across a format-parse-format round trip. [#124325](https://github.com/ClickHouse/ClickHouse/pull/124325) ([Groene AI](https://github.com/groeneai)).
* Exchanging `-Merge` aggregate states with older servers now stays compatible: the state version of a `-Merge` function follows the state version of the function it merges only for peers that announce the new protocol revision `54494`. [#123070](https://github.com/ClickHouse/ClickHouse/pull/123070) ([Groene AI](https://github.com/groeneai)).
* An aggregate function parameter whose value has no unambiguous bare literal form, such as a `Decimal`, a wide integer, a `UUID`, an `IPv4` or `IPv6`, or a non-negative `Int64`, is now always printed with an explicit `::Type` suffix, and inside an array or tuple parameter the suffix goes on the elements. Such a parameter therefore reads back as the same value for every family, instead of only for the ones that had opted in. The typed form also travels over the `Native` protocol, so an insert into a column whose parameter was spelled without the type is now rejected there too, as it already was locally. [#121725](https://github.com/ClickHouse/ClickHouse/pull/121725) ([Groene AI](https://github.com/groeneai)).
* Diagnostics about slowly acquired locks are now logged at `Information` level instead of `Warning`, so they no longer reach clients that use `send_logs_level = 'warning'` while still being written to the server log with a stack trace. [#123797](https://github.com/ClickHouse/ClickHouse/pull/123797) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Adaptive aggregation now logs less noisily by reducing the severity of its messages. [#123312](https://github.com/ClickHouse/ClickHouse/pull/123312) ([Azat Khuzhin](https://github.com/azat)).
* `kqlRangeCount` now rejects the `Int256` minimum span with step `-1` instead of incorrectly reporting an empty range. [#117212](https://github.com/ClickHouse/ClickHouse/pull/117212) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* A distributed query whose shards plan aggregation with the experimental `enable_cascades_optimizer` no longer hits the logical error `GroupingAggregatedTransform pushed bucket N twice` on the initiator. [#119814](https://github.com/ClickHouse/ClickHouse/pull/119814) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Local execution of distributed query plans (`distributed_plan_execute_locally = 1`) now materializes constant columns in its in-memory exchange like serialized exchanges do, fixing a query that could fail with a `LOGICAL_ERROR` when it sorted by a constant expression. [#124097](https://github.com/ClickHouse/ClickHouse/pull/124097) ([Groene AI](https://github.com/groeneai)).
* The internal function `__bitSwapLastTwo` now raises the same `BAD_ARGUMENTS` error for unsupported argument types when the expression is JIT-compiled as when it is interpreted. [#117613](https://github.com/ClickHouse/ClickHouse/pull/117613) ([Groene AI](https://github.com/groeneai)).
* Fix a UBSan failure during parallel parsing of `TabSeparated` input with an empty buffer. [#122636](https://github.com/ClickHouse/ClickHouse/pull/122636) ([Ray Winkelman](https://github.com/rwinkelman)).
* The `ErrorCode` registry is now sparse, so ClickHouse can reserve gaps between error codes without preallocating counters for them. [#111796](https://github.com/ClickHouse/ClickHouse/pull/111796) ([Maxim Orlovsky](https://github.com/UberDever)).
* Fixed a signed integer overflow when a negative or huge `lock_acquire_timeout` value is used as the timeout for scheduling a background task. [#117898](https://github.com/ClickHouse/ClickHouse/pull/117898) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Cancelled marks-loading background tasks are no longer counted as errors in `system.errors` and `system.error_log`. Previously `ASYNC_LOAD_CANCELED` was recorded during normal operation whenever a reader was dropped before its asynchronously loaded marks were needed. [#118928](https://github.com/ClickHouse/ClickHouse/pull/118928) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* `ALTER TABLE ... EXECUTE expire_snapshots` for `Iceberg` tables now counts a file as deleted only when its removal succeeds, reports the removals that return an error in a new `failed_deletions_count` metric like `remove_orphan_files`, and counts a file that several expired manifests list only once. Closes [#125332](https://github.com/ClickHouse/ClickHouse/issues/125332). [#125379](https://github.com/ClickHouse/ClickHouse/pull/125379) ([Groene AI](https://github.com/groeneai)).
* Reading an archive that libarchive fails to open without giving a reason (for example a `.tar.gz` with a truncated gzip trailer) now throws `CANNOT_UNPACK_ARCHIVE` instead of `STD_EXCEPTION` (`fmt::format_error: string pointer is null`). Closes [#125620](https://github.com/ClickHouse/ClickHouse/issues/125620). [#125650](https://github.com/ClickHouse/ClickHouse/pull/125650) ([Groene AI](https://github.com/groeneai)).
* `RESTORE` from a tar backup with a non-empty `password` setting now fails with `NOT_IMPLEMENTED`, like `BACKUP` to a tar archive, instead of `LOGICAL_ERROR`. Closes [#125648](https://github.com/ClickHouse/ClickHouse/issues/125648). [#125666](https://github.com/ClickHouse/ClickHouse/pull/125666) ([Groene AI](https://github.com/groeneai)).
#### Bug Fix (user-visible misbehavior in an official stable release)
* Fixed silent data loss when writing to an S3 key that already holds an object, for example `INSERT INTO FUNCTION s3(...)` with `s3_truncate_on_insert = 1`. Closes [#114348](https://github.com/ClickHouse/ClickHouse/issues/114348). [#118829](https://github.com/ClickHouse/ClickHouse/pull/118829) ([Sema Checherinda](https://github.com/CheSema)).
* Fix possible data loss when a part's `checksums.txt` is repaired (recalculated and written on load, or by `CHECK TABLE`) and the server loses power afterwards. The metadata rewrite is now durable and atomic (write to a temporary file, fsync, atomically rename), and an empty `checksums.txt` is now recalculated on load instead of detaching the whole part as broken. [#111414](https://github.com/ClickHouse/ClickHouse/pull/111414) ([Groene AI](https://github.com/groeneai)).
* Fix a part being detached as broken, losing its rows, when `columns.txt` or `metadata_version.txt` survives a power loss at length zero. Such a file is now treated like an absent one, which the load path already handles safely. [#119582](https://github.com/ClickHouse/ClickHouse/pull/119582) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fix data loss when loading a part with a broken projection: a marks file damaged by an interrupted write could be accepted as an empty part instead of being detached as broken. [#119586](https://github.com/ClickHouse/ClickHouse/pull/119586) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed replica recovery of a `Replicated` database deleting the data of a `KeeperMap` table, for example after the server was killed during an `ALTER` of that table. A `KeeperMap` table that still exists in Keeper is now kept or renamed with its data, instead of being dropped and re-created empty. Closes [#111957](https://github.com/ClickHouse/ClickHouse/issues/111957). [#122917](https://github.com/ClickHouse/ClickHouse/pull/122917) ([Groene AI](https://github.com/groeneai)).
* `DROP DATABASE` of a `Replicated` database now drops a materialized view with `ENGINE = TimeSeries` instead of failing with `It's not initial query` and leaving the database half-dropped. [#123663](https://github.com/ClickHouse/ClickHouse/pull/123663) ([Groene AI](https://github.com/groeneai)).
* Fixed data loss when a single `ALTER TABLE` renamed a `Nested` member, or another column with a dot in its name, and modified the renamed column. Such an `ALTER` is now rejected with `NOT_IMPLEMENTED`, as it already was for other columns. [#122794](https://github.com/ClickHouse/ClickHouse/pull/122794) ([Groene AI](https://github.com/groeneai)).
* Fixed merges deleting all rows of a part whose rows TTL was never calculated, although none of its rows had expired: a part attached with `ATTACH PARTITION ... FROM` from a table without that rows TTL, or written before `MODIFY TTL` with `materialize_ttl_after_modify = 0` added it, for example after `MODIFY COLUMN ... REMOVE TTL`. The rows were lost in background TTL merges and in merges with fully expired parts. Closes [#121124](https://github.com/ClickHouse/ClickHouse/issues/121124). [#123068](https://github.com/ClickHouse/ClickHouse/pull/123068) ([Groene AI](https://github.com/groeneai)).
* Fixed a race in `MergeTree` where an `ALTER TABLE ... UPDATE` or `DELETE` mutation submitted concurrently with another mutation could be silently skipped on some parts while being reported as done. [#124167](https://github.com/ClickHouse/ClickHouse/pull/124167) ([Murphy](https://github.com/murphy-4o)).
* A mutation on a `Replicated*` table whose predicate contains a lambda can no longer prune to too few partitions when a lambda parameter name matches an `ALIAS` or `EPHEMERAL` column definition. Previously some matching rows were left unmutated while the mutation still finished successfully. [#121193](https://github.com/ClickHouse/ClickHouse/pull/121193) ([Groene AI](https://github.com/groeneai)).
* Fix background merges with TTL silently stopping for the whole server. A merge with TTL that was selected and then dropped before it ran — for example because its table was dropped right after the expired rows were inserted — leaked one of the `max_number_of_merges_with_ttl_in_pool` slots, which are shared by all tables. After two such merges no table would delete expired rows any more until the server was restarted. [#121236](https://github.com/ClickHouse/ClickHouse/pull/121236) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Make the asynchronous startup of a `ReplicatedMergeTree` table robust against a concurrent `DETACH`, which could previously hang the startup forever or leave background tasks running on a table that was already shut down. [#121672](https://github.com/ClickHouse/ClickHouse/pull/121672) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fix corrupted shared data of nested `JSON` objects after a failed attempt to parse a value during insert. It could lead to errors like `Unexpected version of JSON type binary encoding` or `Unknown type code` when reading the data after merges or when serializing it in binary formats. [#123898](https://github.com/ClickHouse/ClickHouse/pull/123898) ([Rory Shanks](https://github.com/rorylshanks)).
* The server no longer terminates when a transient error such as `MEMORY_LIMIT_EXCEEDED`, a network error, or concurrent `SYSTEM RESTART REPLICA` happens while outdated data parts are loading in the background. Such errors are now retried later instead of aborting the server. [#117981](https://github.com/ClickHouse/ClickHouse/pull/117981) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed silent row loss when a `MergeTree` table with a projection is read with a `WHERE` in which an `AND` is used with negative polarity, under a `NOT`, as an operand of a comparison, or as the branch condition of `if`/`multiIf`/`CASE`, and one of that `AND`'s conjuncts references a column the projection does not store. [#120286](https://github.com/ClickHouse/ClickHouse/pull/120286) ([Groene AI](https://github.com/groeneai)).
* Fixed some `SELECT` queries silently returning fewer rows when the table has a projection that exists only in some of its parts, for example one added with `ALTER TABLE ... ADD PROJECTION` after data was inserted, and `query_plan_remove_unused_columns` is `0`, which `compatibility` up to `25.11` sets. [#124022](https://github.com/ClickHouse/ClickHouse/pull/124022) ([Groene AI](https://github.com/groeneai)).
* Fixed wrong query results with skip indexes on `SummingMergeTree`, `AggregatingMergeTree`, `CoalescingMergeTree`, and `GraphiteMergeTree` tables: with `optimize_on_insert`, the default, an `INSERT` built every skip index whose expression is not a plain column from the rows before they were merged, so queries using the index could skip granules with matching rows. `SummingMergeTree` also no longer keeps rows whose summed columns total zero because of such an index. [#123291](https://github.com/ClickHouse/ClickHouse/pull/123291) ([Groene AI](https://github.com/groeneai)).
* Fixed wrong results when a `WHERE` clause mixing `AND` and `OR` was evaluated with skip indexes (`use_skip_indexes_for_disjunctions`, enabled by default). If a `minmax` or `set` index could not evaluate one atom of the predicate for a granule, the per-atom verdicts recorded for that granule were shifted, so one atom's verdict was applied to another and granules holding matching rows were skipped. [#124303](https://github.com/ClickHouse/ClickHouse/pull/124303) ([Groene AI](https://github.com/groeneai)).
* Fixed a query silently returning fewer rows after an unrelated `JOIN` had run: a join runtime filter moved into a read's `PREWHERE` made the read record a false "no matching rows" verdict in the query condition cache. [#119823](https://github.com/ClickHouse/ClickHouse/pull/119823) ([Groene AI](https://github.com/groeneai)).
* Fixed the query condition cache serving one session's granule verdicts to another when the two differ only in a setting a conversion function captured, such as `precise_float_parsing`, which silently dropped matching rows from the second session's result. [#119168](https://github.com/ClickHouse/ClickHouse/pull/119168) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed `LEFT`, `RIGHT`, `FULL`, and `ANY` outer `JOIN` silently dropping non-matched rows when the `WHERE` filter reads a `Date32` or `Enum` column of the non-preserved side. Closes [#121115](https://github.com/ClickHouse/ClickHouse/issues/121115). [#121181](https://github.com/ClickHouse/ClickHouse/pull/121181) ([Groene AI](https://github.com/groeneai)).
* Fixed a join runtime filter silently dropping rows whose join key is a float. When the build side had a single distinct value the filter replaced set membership with `equals`, but a hash join compares float keys bitwise, so `NaN` did not match itself and `0.0` matched `-0.0`. [#119720](https://github.com/ClickHouse/ClickHouse/pull/119720) ([Groene AI](https://github.com/groeneai)).
* Fix wrong values after lazy materialization expands a sparse column during a `JOIN`: rows could receive values from other rows. [#124442](https://github.com/ClickHouse/ClickHouse/pull/124442) ([Nikolai Kochetov](https://github.com/KochetovNicolai)).
* `ALTER TABLE ... EXECUTE expire_snapshots` on an `Iceberg` table now always keeps the head snapshot of every branch, even when the table property `history.expire.min-snapshots-to-keep` is `0`. Previously such a table could lose all its data files. Closes [#124333](https://github.com/ClickHouse/ClickHouse/issues/124333). [#125365](https://github.com/ClickHouse/ClickHouse/pull/125365) ([Groene AI](https://github.com/groeneai)).
* Fixed an `ssl_certificate` authentication bypass where an embedded NUL byte in a certificate's Common Name (for example `john\0.evil.com`) was truncated server-side to `john`, letting a holder of such a certificate authenticate as a different user. [#117403](https://github.com/ClickHouse/ClickHouse/pull/117403) ([Konstantin Bogdanov](https://github.com/thevar1able)).
* Fixed one failed write to a non-replicated `MergeTree` table's deduplication log (with `non_replicated_deduplication_window` greater than zero) making every following `INSERT` into that table fail with `Cannot write to canceled buffer` until the server was restarted. The log now replaces a writer that a failed flush left unusable, no longer finalizes such a writer while rotating or shutting down, and no longer stops removing its outdated files, which could also make `ALTER TABLE ... MODIFY SETTING non_replicated_deduplication_window` fail. [#118350](https://github.com/ClickHouse/ClickHouse/pull/118350) ([Groene AI](https://github.com/groeneai)).
* Fixed wrong results after `ALTER TABLE ... MODIFY COLUMN AFTER ` on a column used in `PARTITION BY`. Closes [#92834](https://github.com/ClickHouse/ClickHouse/issues/92834). [#120862](https://github.com/ClickHouse/ClickHouse/pull/120862) ([Groene AI](https://github.com/groeneai)).
* Fixed a merge or a mutation making a table unreadable (`Stream ... is not found`) when a column that a part does not hold is dropped and its name is also the name of a subcolumn of another column, for example `a.size0` next to an `Array` column `a`. [#118246](https://github.com/ClickHouse/ClickHouse/pull/118246) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fix wrong rows returned by `ORDER BY ... LIMIT` over a `MergeTree` table read in the order of a function of its sorting key, for example `ORDER BY toStartOfMonth(date) DESC, i`, when the sorting-key column uses sparse serialization. [#109424](https://github.com/ClickHouse/ClickHouse/pull/109424) ([Groene AI](https://github.com/groeneai)).
* `ALTER TABLE ... DROP PARTITION` and other partition commands with an invalid or out-of-range `Date` or `DateTime` literal, such as `'2024-02-30'` or `'9999-01-01'`, no longer silently act on a different partition. They now raise an error. [#122419](https://github.com/ClickHouse/ClickHouse/pull/122419) ([DeviousCardi](https://github.com/DeviousCardi)).
* Fixed wrong query results and unsorted parts in `MergeTree` tables whose sorting, primary or partition key reads a subcolumn of a column (for example ``PRIMARY KEY cityHash64(`c1.1`)`` or `ORDER BY t.a`) when a column `TTL` or an `UPDATE` changes that column. A column `TTL` on such a column is now refused as on any other key column, `UPDATE` of a column that a `MATERIALIZED` key column of this kind is computed from is refused, and TTL merges of a table already stored with such a `TTL` fail instead of writing unsorted parts. [#123628](https://github.com/ClickHouse/ClickHouse/pull/123628) ([Groene AI](https://github.com/groeneai)).
* After a canary OOM, only the merges and mutations that are already running are cancelled. Newly scheduled ones now run as usual instead of all later merges and mutations staying cancelled until server restart. Closes [#121748](https://github.com/ClickHouse/ClickHouse/issues/121748). [#123870](https://github.com/ClickHouse/ClickHouse/pull/123870) ([Javier G. Sogo](https://github.com/jgsogo)).
* Fixed a spurious `Cannot schedule a task: no free thread ... (CANNOT_SCHEDULE_TASK)` error that rejected a valid `SELECT` over a `MergeTree` table when it had more parts to analyse than the query had threads and their analysis took longer than `lock_acquire_timeout`. Index analysis now runs one pool job per thread instead of one per part, which also makes it faster for queries over many parts. [#116822](https://github.com/ClickHouse/ClickHouse/pull/116822) ([Groene AI](https://github.com/groeneai)).
* Fixed wrong results and `CANNOT_READ_ALL_DATA` or `INCORRECT_DATA` errors when reading `MergeTree` parts in packed storage (`min_bytes_for_full_part_storage`), for example with parallel replicas, with a patch part of a lightweight update or delete, or when reading a `JSON` subcolumn. [#116920](https://github.com/ClickHouse/ClickHouse/pull/116920) ([Groene AI](https://github.com/groeneai)).
* Fixed `ILLEGAL_COLUMN` (`Illegal column ... of first argument of function to...`) raised by every query touching a column that was dropped and re-added with a different type, for as long as a part still carried the old column. The re-added column now reads as its default, as it does once the drop's mutation rewrites the part. Queries served from a projection no longer return the old values of such a column. [#118585](https://github.com/ClickHouse/ClickHouse/pull/118585) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed reading stale data, or a `Sizes of nested column and null map of Nullable column are not equal` / `Got empty stream for SerializationLowCardinality keys` error, from a column that was turned into `ALIAS` or `EPHEMERAL` (or dropped while its partition was detached) and later made physical again, when a mutation that rewrites only some columns (for example `MATERIALIZE INDEX`) ran on a Wide part in between. [#124516](https://github.com/ClickHouse/ClickHouse/pull/124516) ([Groene AI](https://github.com/groeneai)).
* Fixed a use-after-free (on some versions a crash with `Pure virtual function called!`) on `INSERT`, merge or `SELECT ... FINAL` of a `SummingMergeTree` table with a `Nested` column whose name ends in `Map` and whose element type has `LowCardinality` inside an `Array` or `Map`, for example `Array(LowCardinality(String))`. [#125533](https://github.com/ClickHouse/ClickHouse/pull/125533) ([Groene AI](https://github.com/groeneai)).
* Fix a `MergeTree` table with a rows `TTL` and a `text` index never dropping its expired parts: the `TTLDrop` merge failed with `Text index transform for index ... not found` and retried forever. [#113385](https://github.com/ClickHouse/ClickHouse/pull/113385) ([Groene AI](https://github.com/groeneai)).
* Fixed dropping whole parts with TTL (`ttl_only_drop_parts = 1`) still reading all data from large, fully expired parts. [#108626](https://github.com/ClickHouse/ClickHouse/pull/108626) ([Michael Jarrett](https://github.com/EmeraldShift)).
* Fixed a server crash on `CREATE TABLE` or `ALTER TABLE ... MODIFY TTL` when a `TTL` expression uses the result of `arrayMap` with a constant lambda, such as `toString(arrayMap(x -> CAST(1, 'Dynamic'), arr))`. [#122868](https://github.com/ClickHouse/ClickHouse/pull/122868) ([Groene AI](https://github.com/groeneai)).
* Fixed `NOT_FOUND_COLUMN_IN_BLOCK` (`Not found column _row_exists in block`) that permanently blocked all further mutations of a `MergeTree` table after a lightweight `DELETE` run with `lightweight_delete_mode = 'lightweight_update'` was followed by a heavyweight `ALTER TABLE ... UPDATE` and then by another mutation rewriting all columns. Closes [#115570](https://github.com/ClickHouse/ClickHouse/issues/115570). [#115665](https://github.com/ClickHouse/ClickHouse/pull/115665) ([Groene AI](https://github.com/groeneai)).
* Fixed `ALTER DELETE` and `ALTER UPDATE` silently skipping rows when the predicate references an `ALIAS` column whose definition contains a non-deterministic function such as `now`. [#117273](https://github.com/ClickHouse/ClickHouse/pull/117273) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed a patch part whose `source_parts.dat` lost its content to a zeroed block loading as an empty index, which silently unapplied an acknowledged lightweight `UPDATE` and then let background cleanup delete the only copy of it. Such a part is now detached as broken. [#119585](https://github.com/ClickHouse/ClickHouse/pull/119585) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed `ALTER TABLE ... DELETE` and `ALTER TABLE ... UPDATE` skipping a whole partition when the parts the initiating replica holds in it are all empty: rows another replica had acknowledged in that partition survived the mutation on every replica. [#119149](https://github.com/ClickHouse/ClickHouse/pull/119149) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed a pending lightweight `DELETE` read with `apply_mutations_on_fly = 1` evaluating its predicate over patch parts created after it, which made rows disappear from the result and reappear after the mutation materialized. Closes [#118049](https://github.com/ClickHouse/ClickHouse/issues/118049). [#118919](https://github.com/ClickHouse/ClickHouse/pull/118919) ([Alexey Milovidov](https://github.com/alexey-milovidov)). [#119306](https://github.com/ClickHouse/ClickHouse/pull/119306) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed lightweight `UPDATE` for parts adopted from another table via `REPLACE PARTITION` or `ATTACH PARTITION FROM`: after such a part was cloned again (by a mutation that does not modify it, by a clone instead of a fetch of a replicated mutation, or by a move between disks), applying patch parts could silently drop updated rows in release builds and raise the `current_version != existing_version` exception in debug and sanitizer builds. [#115979](https://github.com/ClickHouse/ClickHouse/pull/115979) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed lightweight `UPDATE ... ON CLUSTER` on `ReplicatedMergeTree` tables running on every replica of a shard instead of once per shard, which applied assignments such as `SET v = v + 1` once per replica. A plain `UPDATE` in a `Replicated` database with more than one shard had the same problem. [#122393](https://github.com/ClickHouse/ClickHouse/pull/122393) ([Pratham Nayak](https://github.com/protomn)).
* Fixed a concurrent heavyweight `ALTER TABLE ... UPDATE`/`DELETE` silently dropping an acknowledged lightweight `UPDATE` on a plain `MergeTree` table. [#119155](https://github.com/ClickHouse/ClickHouse/pull/119155) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed mutations such as `ALTER TABLE ... UPDATE` failing with `CANNOT_READ_ALL_DATA` on every attempt, and never completing, when they read a column together with its `LowCardinality` subcolumn in a Wide part: a `Dynamic` column and its `LowCardinality(String)` subcolumn, or a `Map` with `map_serialization_version = 'with_buckets'` and its `keys` or `values` subcolumn. The problem appeared in 26.6. [#123160](https://github.com/ClickHouse/ClickHouse/pull/123160) ([Groene AI](https://github.com/groeneai)).
* Fixed an acknowledged lightweight `UPDATE` being invisible on `ReplicatedMergeTree` when it targets a column whose `RENAME COLUMN` mutation has not materialized yet. [#119144](https://github.com/ClickHouse/ClickHouse/pull/119144) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed a lightweight `UPDATE` made before `ALTER TABLE ... RENAME COLUMN` on a `ReplicatedMergeTree` table being lost when a merge ran before the rename's mutation (for example with `apply_patches_on_merge = 0`): queries returned the old value, and the mutation then dropped the update from disk. [#124653](https://github.com/ClickHouse/ClickHouse/pull/124653) ([Groene AI](https://github.com/groeneai)).
* Fixed a wrong result of a mutation of a `MergeTree` table when several pending mutations are executed as a single task and a patch part, created by a lightweight `UPDATE`, has a version in between: the patch was applied before the commands that precede it, so they were evaluated over data they must not see. [#119127](https://github.com/ClickHouse/ClickHouse/pull/119127) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed `ReplicatedMergeTree` TTL processing stalling indefinitely when a TTL merge that drops fully expired parts was larger than half the free disk space. Such a merge deletes every row and therefore needs no room for its source parts, but it was postponed on their size, and the postponed entry kept occupying the only `max_replicated_merges_with_ttl_in_queue` slot, so no TTL merge ran and no space was ever freed. It is now admitted when the table's only TTL is an unconditional rows TTL. Closes [#119775](https://github.com/ClickHouse/ClickHouse/issues/119775). [#119983](https://github.com/ClickHouse/ClickHouse/pull/119983) ([Groene AI](https://github.com/groeneai)).
* Fixed `ATTACH PARTITION` on `ReplicatedMergeTree` failing to rename a broken part in `detached/` aside, so every later `ATTACH PARTITION` for that partition kept failing on it. [#116734](https://github.com/ClickHouse/ClickHouse/pull/116734) ([Groene AI](https://github.com/groeneai)).
* Fixed the replication queue never draining when a part is present locally but its node in `ZooKeeper` is missing: the `GET_PART` entry for such a part re-downloaded it and failed with `DUPLICATE_DATA_PART` on every retry. [#119189](https://github.com/ClickHouse/ClickHouse/pull/119189) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Writing the empty covering part of a replicated table now happens before the covered parts are removed from the working set, so an exception during the operation no longer leaves the table with unexpected data parts and readonly after reload. [#122610](https://github.com/ClickHouse/ClickHouse/pull/122610) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Background Keeper users now retry a `get_zookeeper_lock_acquire_timeout_ms` timeout like other Keeper errors, so a `ReplicatedMergeTree` table attached during a transient Keeper outage no longer stays read-only. [#124327](https://github.com/ClickHouse/ClickHouse/pull/124327) ([Groene AI](https://github.com/groeneai)).
* A table read by a scalar subquery inside a `CONSTRAINT` is now a loading dependency of the table that declares the constraint. Previously such a table could be dropped, after which the server did not start, because attaching the dependent table executes the subquery. [#114923](https://github.com/ClickHouse/ClickHouse/pull/114923) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed a server startup failure after creating a table with a `quantile*` state column whose level is a `Decimal`, a wide integer, a `UUID`, an `IPv4`, or an `IPv6`. Such a level was persisted into the metadata as a quoted string, which reparsed as a `String` and was rejected, so metadata loading failed with `CANNOT_CONVERT_TYPE` and the server did not start. The same `CREATE` also failed outright on a `Replicated` database. [#119810](https://github.com/ClickHouse/ClickHouse/pull/119810) ([Groene AI](https://github.com/groeneai)).
* A table whose stored definition carries a column `TTL` inherited from its source table now loads again on engines that do not support `TTL` (`Merge`, `Buffer`, `Distributed`, `Remote`). Previously such a table could not be loaded, which failed the load of the whole database, and with `async_load_databases = 0` the server refused to start. The `TTL` stays in the definition and has no effect; `ALTER TABLE ... MODIFY COLUMN ... REMOVE TTL` removes it. [#122273](https://github.com/ClickHouse/ClickHouse/pull/122273) ([Mohammed Sohail](https://github.com/msohail22)).
* Fix a `Remote` or `Cluster` database without a local shard making `SELECT count()` through the `merge` table function return `0`, and making the server fail to start when a dictionary reads one of its tables. Closes [#122612](https://github.com/ClickHouse/ClickHouse/issues/122612). [#122661](https://github.com/ClickHouse/ClickHouse/pull/122661) ([Groene AI](https://github.com/groeneai)).
* Fix `Part ... intersects previous part ...` when attaching a `MergeTree` table after `REPLACE PARTITION`, if parts outdated by an earlier `DROP PART` were still on disk. The server could fail to start because of it. [#120980](https://github.com/ClickHouse/ClickHouse/pull/120980) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fix `Part ... intersects next part ...` when loading a `MergeTree` table after `REPLACE PARTITION` into it ran concurrently with `MOVE PARTITION` from it. The server could fail to start because of it. [#123780](https://github.com/ClickHouse/ClickHouse/pull/123780) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed `S3`, `HDFS`, `AzureBlobStorage`, and `URL` tables over a named collection with `format = 'auto' NOT OVERRIDABLE` failing to load with `Override not allowed for 'format'`, which could stop the server from starting. The format that ClickHouse inferred and stored at `CREATE` time is now accepted when the table is loaded again; a format written by the user over the locked value is still refused. [#124215](https://github.com/ClickHouse/ClickHouse/pull/124215) ([Groene AI](https://github.com/groeneai)).
* Restored compatibility with Azure Blob Storage endpoints that omit the `ETag` header. [#120419](https://github.com/ClickHouse/ClickHouse/pull/120419) ([alesapin](https://github.com/alesapin)).
* Fix `Part ... intersects previous part ...` when loading a `MergeTree` table after a `TRUNCATE`, `DROP PARTITION` or `MOVE PARTITION TO TABLE` failed to commit (e.g. because of a memory limit or a disk error) and a merge ran before the restart. The server could fail to start because of it. [#122375](https://github.com/ClickHouse/ClickHouse/pull/122375) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* A `PROJECTION` that could not be analyzed when the table was loaded at server startup is no longer deleted from the table's persisted metadata by the next `ALTER`, which also orphaned its already-materialized data with no error at any step. While such a declaration is present, an `ALTER` that rewrites the table metadata is now refused (`ALTER TABLE ... DROP PROJECTION` and `CLEAR PROJECTION` still work), so it survives until the cause is removed or the user drops it. [#118378](https://github.com/ClickHouse/ClickHouse/pull/118378) ([Groene AI](https://github.com/groeneai)).
* Fixed non-deterministic conditions being moved to `PREWHERE` in `SELECT ... FINAL` when `optimize_move_to_prewhere` is enabled. [#109538](https://github.com/ClickHouse/ClickHouse/pull/109538) ([Yarik Briukhovetskyi](https://github.com/yariks5s)).
* Fixes wrong results with `query_plan_optimize_lazy_final` when the primary key is nullable and holds a `NULL`: the `NULL`-keyed row was silently missing from the result of a `FINAL` query. [#112857](https://github.com/ClickHouse/ClickHouse/pull/112857) ([Groene AI](https://github.com/groeneai)).
* Fixed rows silently dropped by index analysis when a `DateTime64` column is compared with a constant of another scale and the sorting or partition key contains a `CAST` of that column, such as `ORDER BY d::String`. [#118688](https://github.com/ClickHouse/ClickHouse/pull/118688) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fix rows silently dropped by partition, primary-key, and skip-index pruning, and by `Iceberg` partition pruning, when a string constant is compared with a `DateTime` or `DateTime64` column whose type name carries no time zone and the effective `session_timezone` differs from the one that column's type was built with. [#120114](https://github.com/ClickHouse/ClickHouse/pull/120114) ([Groene AI](https://github.com/groeneai)).
* Fixed a `minmax` skip index, a `set` skip index, part-level minmax pruning, and statistics-based part pruning dropping rows that hold a `NaN` when the query negates a float comparison, for example `WHERE NOT (val BETWEEN 0 AND 3)`. Closes [#106533](https://github.com/ClickHouse/ClickHouse/issues/106533). Closes [#106948](https://github.com/ClickHouse/ClickHouse/issues/106948). [#107074](https://github.com/ClickHouse/ClickHouse/pull/107074) ([Groene AI](https://github.com/groeneai)).
* Fixed silently missing rows for a range predicate on `toDayOfWeek(key, mode)` with the Sunday-first modes `2` and `3` over a date primary key. [#117683](https://github.com/ClickHouse/ClickHouse/pull/117683) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed `ngrambf_v1`, `tokenbf_v1`, and `sparse_grams` skip indexes silently dropping matching rows when an `IPv6` column is compared with a string literal, as in `WHERE ip = '2001:db8::'`. [#113157](https://github.com/ClickHouse/ClickHouse/pull/113157) ([Groene AI](https://github.com/groeneai)).
* Fixed a `set` skip index whose expression has type `Dynamic` or `Variant`, which includes an undeclared `JSON` path such as `j.a`, silently returning no rows for `!=` and `IS NULL`. [#120780](https://github.com/ClickHouse/ClickHouse/pull/120780) ([Groene AI](https://github.com/groeneai)).
* Fixed wrong results when a query converts a `Date` or `Date32` column to `DateTime` and the column's values leave the range of day numbers that fits into 32-bit seconds. Key analysis, statistics part pruning, and reading in sorting-key order assumed the conversion preserves order, so a filter could skip parts holding matching rows or answer `count` from metadata without filtering, and `ORDER BY` could return rows out of order. Affects `toDateTime`, `toDateTime32`, `CAST(... AS DateTime)`, and `accurateCast`. [#117031](https://github.com/ClickHouse/ClickHouse/pull/117031) ([Groene AI](https://github.com/groeneai)).
* Fix rows silently dropped by primary-key pruning when `toDayOfWeek` is applied to a `DateTime` column whose time zone differs from the session one, or over a `Date32`/`DateTime64` key that leaves the `Date` range. `toDayOfWeek` with a Sunday-first `week_mode` can use the primary key again. [#118655](https://github.com/ClickHouse/ClickHouse/pull/118655) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed rows silently missing from a query over a table whose primary key is a `Tuple` with a `Nullable` element holding `NULL`: primary-key analysis dropped whole granules of matching rows. [#118945](https://github.com/ClickHouse/ClickHouse/pull/118945) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fix a `JSONAllPaths` skip index silently pruning every granule for a filter on a subcolumn inside a declared typed path of a `JSON` column (for example `json.a.b` for `JSON(a JSON)` or `JSON(a Tuple(b Int64))`). Such a filter no longer uses the index. [#119321](https://github.com/ClickHouse/ClickHouse/pull/119321) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fix rows silently dropped by primary key and partition pruning when a `MergeTree` key expression applies a timezone-observing function such as `toYYYYMM`, `toString` or a `CAST` to `String` to a `DateTime`/`DateTime64` column and a compared constant declares a different timezone. Both a scalar comparison constant and an `IN`-set element are affected, including when the differing timezone sits under an `Array`, `Map`, `Tuple`, `Nullable`, `LowCardinality` or `Variant` wrapper that only one side carries, when a custom type name such as `SimpleAggregateFunction` wraps that composite on one side only, and when a sibling leaf differs only by a custom type name (`Bool` against `UInt8`). Also fix the same loss when a compared `Tuple` and the key column's disagree on explicit element names, which `toJSONString` renders as an object against an array; no timezone difference is needed. [#113781](https://github.com/ClickHouse/ClickHouse/pull/113781) ([Groene AI](https://github.com/groeneai)).
* Fixed rows silently dropped, or counted without being filtered, when a `DateTime64` constant of a finer scale than the column is compared with `!=`, `NOT IN`, or `IN`: index analysis truncated the constant and treated the truncated value as the exact point the query asked for, pruning the granule or partition that held a matching row. [#118957](https://github.com/ClickHouse/ClickHouse/pull/118957) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed index analysis for a condition that wraps the primary key in a widening integer cast such as `toInt64` and then applies another monotonic function such as `negate` or `abs`. Such a condition could silently drop matching rows, or fail with `LOGICAL_ERROR: abs's argument does not match the expected data type`. Present since 26.5. [#116699](https://github.com/ClickHouse/ClickHouse/pull/116699) ([Groene AI](https://github.com/groeneai)).
* Fixed wrong results from primary-key analysis for predicates such as `toDate(dt64_key) >= ...` and `toDateTime(date32_key) >= ...`: at the default `date_time_overflow_behavior = 'ignore'` the conversion wraps for values the result type cannot hold, so matching rows silently disappeared and `count()` could overcount. [#117394](https://github.com/ClickHouse/ClickHouse/pull/117394) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed partition pruning skipping a partition whose rows match a filter like `NOT (c <=> f(partition_key))` when `f` returns `NULL` for that partition's key value (for example `moduloOrNull` or `nullIf`). Such queries returned fewer rows than with `use_partition_pruning = 0`. [#124041](https://github.com/ClickHouse/ClickHouse/pull/124041) ([Groene AI](https://github.com/groeneai)).
* Fixed `use_skip_indexes = 0` also disabling part pruning by the partition-key min-max index since 26.5, which made such queries read every part of the table. [#123403](https://github.com/ClickHouse/ClickHouse/pull/123403) ([Ashish Kumar Choubey](https://github.com/aschoube)).
* Fixed missing rows in queries mixing `AND` and `OR` when a `minmax` or `set` skip index over an expression with `mortonEncode` or `hilbertEncode` is combined with other skip indexes (`use_skip_indexes_for_disjunctions`, enabled by default). Closes [#124452](https://github.com/ClickHouse/ClickHouse/issues/124452). [#124784](https://github.com/ClickHouse/ClickHouse/pull/124784) ([Groene AI](https://github.com/groeneai)).
* Fix a query that compared a `Dynamic` or `JSON` column with a constant, such as `d = '2024-01-05'` or `d = toDate('2024-01-05')`, and returned fewer rows when the table was ordered by a transform of that column, such as `ORDER BY d::String`. Such a comparison no longer uses the primary key; compare the key expression itself, as in `d::String = '2024-01-05'`, to keep using it. [#124476](https://github.com/ClickHouse/ClickHouse/pull/124476) ([Ashish Kumar Choubey](https://github.com/aschoube)).
* Fixed a `text` index dropping matching rows when a `FixedString` is involved in the comparison. [#118972](https://github.com/ClickHouse/ClickHouse/pull/118972) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed wrong results of `hasPhrase`, `hasToken`, `hasAnyTokens`, and `hasAllTokens` over a text index with a `postprocessor` or `preprocessor` when direct read from the text index could not answer the function, for example `NOT hasPhrase` with a phrase whose tokens are all removed by a stop-word postprocessor. [#125118](https://github.com/ClickHouse/ClickHouse/pull/125118) ([Groene AI](https://github.com/groeneai)).
* Fixed text-index search functions returning wrong results, including silently dropped rows, on a column whose text index declares a preprocessor. [#117774](https://github.com/ClickHouse/ClickHouse/pull/117774) ([Elmi Ahmadov](https://github.com/ahmadov)).
* Fixed wrong results after a mutation of a wide data part that does not store a column added by a metadata-only `ALTER TABLE ... ADD COLUMN`: the mutation wrote a column statistic for that column, so statistics-based part pruning could drop a part holding matching rows and `min` and `max` could be answered with the pre-`ALTER` default. [#121936](https://github.com/ClickHouse/ClickHouse/pull/121936) ([Groene AI](https://github.com/groeneai)).
* Fixed wrong results for `min`, `max`, and filtered `count` on a `MergeTree` column that carries a column `TTL`. When the `TTL` emptied the column, the part kept a statistic for it and queries were answered from that stale statistic instead of from the rows the part stores. [#122058](https://github.com/ClickHouse/ClickHouse/pull/122058) ([Groene AI](https://github.com/groeneai)).
* Fixed wrong results from `use_query_condition_cache_for_top_k`: `SELECT ... SAMPLE ... ORDER BY ... LIMIT n` no longer reuses cache entries written by the same query without `SAMPLE`, and Top-K query condition cache entries are no longer written for reads with on-the-fly mutations or patch parts. Closes [#122564](https://github.com/ClickHouse/ClickHouse/issues/122564). [#122538](https://github.com/ClickHouse/ClickHouse/pull/122538) ([Nikita Fomichev](https://github.com/fm4v)). [#122617](https://github.com/ClickHouse/ClickHouse/pull/122617) ([Nikita Fomichev](https://github.com/fm4v)).
* Fix an exception `NOT_FOUND_COLUMN_IN_BLOCK` and, in other queries, wrong results when a lambda argument has the same name as an identifier of an expression that is bound to an alias outside of that lambda, for example `SELECT number + 1 AS n, arrayMap(number -> number + n, [1, 2]) FROM numbers(2)`. [#115544](https://github.com/ClickHouse/ClickHouse/pull/115544) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed wrong results when a `GROUP BY`, `DISTINCT`, `LIMIT BY`, or window `PARTITION BY` key was `plus` or `minus` of a partition column with a non-integer constant. [#120182](https://github.com/ClickHouse/ClickHouse/pull/120182) ([Groene AI](https://github.com/groeneai)).
* Fixed a regression in 26.8 where columns of a parameterized view could not be qualified by the view name (`SELECT pv.col FROM pv(p = 1)` failed with `UNKNOWN_IDENTIFIER`) and a parameterized view used as a `JOIN` operand required an explicit alias. Closes [#119837](https://github.com/ClickHouse/ClickHouse/issues/119837). [#112481](https://github.com/ClickHouse/ClickHouse/pull/112481) ([Groene AI](https://github.com/groeneai)). [#120698](https://github.com/ClickHouse/ClickHouse/pull/120698) ([Dmitry Novik](https://github.com/novikd)).
* Fixed `CANNOT_INSERT_NULL_IN_ORDINARY_COLUMN` and `CANNOT_PARSE_TEXT` when a `PREWHERE` guard predicate and a throwing expression, such as a `CAST` or `toUInt64(substring(...))`, end up in the same read step: either because they read subcolumns of the same column, for example a `JSON` or `Map` column, or because a JOIN runtime filter's key computation was merged into the guarded subquery. Such a query used to fail because the throwing expression was evaluated on rows the guard had rejected. [#111954](https://github.com/ClickHouse/ClickHouse/pull/111954) ([Groene AI](https://github.com/groeneai)).
* Fix wrong window function results when a `QUALIFY` condition, or a comparison derived from it by `optimize_and_compare_chain`, turns into an `indexHint` that prunes rows below the window. Closes [#121177](https://github.com/ClickHouse/ClickHouse/issues/121177). [#122975](https://github.com/ClickHouse/ClickHouse/pull/122975) ([Yarik Briukhovetskyi](https://github.com/yariks5s)).
* Fixed wrong aggregate values with `optimize_aggregation_in_order_limit` when the `ORDER BY` is a strict prefix of the `GROUP BY` key and a group's rows span multiple parts. Closes [#116849](https://github.com/ClickHouse/ClickHouse/issues/116849). [#117573](https://github.com/ClickHouse/ClickHouse/pull/117573) ([Konstantin Bogdanov](https://github.com/thevar1able)).
* Fixed wrong results of `sum`, `min`, `max`, and `avg` over arithmetic with a `Decimal` operand and a constant, for example `min` greater than `max`, a changed `sum` of a division, or a missing `DECIMAL_OVERFLOW`: `optimize_arithmetic_operations_in_aggregate_functions` no longer moves such arithmetic out of the aggregate. [#117779](https://github.com/ClickHouse/ClickHouse/pull/117779) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fix `IfOrNullIf` and `IfOrDefaultIf` ignoring the outer condition when used without `GROUP BY` keys or as a window function with non-`Nullable` arguments. [#122908](https://github.com/ClickHouse/ClickHouse/pull/122908) ([Raúl Marín](https://github.com/Algunenano)).
* Fixed a possible hang of a distributed `GROUP BY` query with `uniqExact` and `distributed_aggregation_memory_efficient = 0` when merging large states of two-level aggregation. [#123352](https://github.com/ClickHouse/ClickHouse/pull/123352) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed missing rows of an empty grouping set `()` in `GROUP BY GROUPING SETS` queries without aggregate functions. For example, `SELECT number FROM numbers(3) GROUP BY GROUPING SETS ((number), ())` returned 3 rows instead of 4, and `GROUPING SETS (())` returned one row per input row. Closes [#61461](https://github.com/ClickHouse/ClickHouse/issues/61461). [#123539](https://github.com/ClickHouse/ClickHouse/pull/123539) ([Groene AI](https://github.com/groeneai)).
* The `uniq` aggregate function returned garbage (for example `18446743978444128518`) for cardinalities above roughly thirty billion, because its state kept only 32 bits of each hash and the correction formula overflowed. The state now additionally keeps a small sample of full 64-bit hashes (state version `1`) which the estimate switches to at about two billion elements: `SELECT uniq(number) FROM numbers_mt(100000000000)` returns `99360630405` (−0.64%), and the estimate stays accurate (about 1%) up to trillions. Below two billion nothing changes: the estimates, the memory usage, and the state format are exactly as before, and states written by older versions remain readable and merge correctly in mixed-version clusters. [#115393](https://github.com/ClickHouse/ClickHouse/pull/115393) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fix wrong results for `uniq*`, `GROUP BY`, `LIMIT n BY`, `ORDER BY` after `GROUP BY`, and window `PARTITION BY` over `toString` of a `DateTime`/`DateTime64` in a time zone with a daylight-saving transition, and over `toFixedString` of a `String`. Both functions claimed to be injective while mapping distinct arguments onto the same result, and the default-on optimizations that take that claim as a proof then eliminated the wrapper. [#117238](https://github.com/ClickHouse/ClickHouse/pull/117238) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed `optimize_rewrite_aggregate_function_with_if` (enabled by default) turning a short-circuit-guarded aggregate such as `sum(if(number = 0, 0, intDiv(42, number)))` into a query failure: the rewritten `sumIf(intDiv(42, number), number != 0)` evaluates its argument for every row, so the guarded expression ran on the rows the condition excluded and threw. The rewrite is now refused when the lifted branch relies on short-circuit evaluation. Closes [#85784](https://github.com/ClickHouse/ClickHouse/issues/85784). [#118697](https://github.com/ClickHouse/ClickHouse/pull/118697) ([Groene AI](https://github.com/groeneai)).
* Fixed wrong results and errors of `min`, `max`, `sum`, and `avg` over an arithmetic operation with a constant with `optimize_arithmetic_operations_in_aggregate_functions` enabled (the default): on an `Array` or `Tuple` operand (`min(arr * -1)`), on an `IPv4` or `IPv6` operand (`sum(ip * 1)` threw `ILLEGAL_TYPE_OF_ARGUMENT`), for `avg` of a date, time, or interval (`avg(t + INTERVAL 500 MILLISECOND)`), for multiplication or division by zero, infinity, or `NULL` (`min(x / -0.0)`), and for a day or longer added to a `DateTime` or a `Time64` across a DST change or a month end. Closes [#122647](https://github.com/ClickHouse/ClickHouse/issues/122647). [#123908](https://github.com/ClickHouse/ClickHouse/pull/123908) ([Groene AI](https://github.com/groeneai)).
* Fixed `hasAll`, `hasAny`, `hasSubstr`, `startsWith`, and `endsWith` returning wrong results on `Array(Nullable(T))`. A `NULL` element was compared as whatever value was physically stored beneath it, so these functions disagreed with `has` on identical input: `hasAll([1, 2, NULL, 4], [0])` returned `1` while `has([1, 2, NULL, 4], 0)` returned `0`. Closes [#68310](https://github.com/ClickHouse/ClickHouse/issues/68310). [#116239](https://github.com/ClickHouse/ClickHouse/pull/116239) ([Groene AI](https://github.com/groeneai)).
* Fixed wrong results from JIT-compiled conversions between integers and `Decimal`. With the default `compile_expressions = 1`, a conversion the destination could not hold silently wrapped instead of raising `DECIMAL_OVERFLOW` once the expression crossed `min_count_to_compile_expression`. Closes [#118958](https://github.com/ClickHouse/ClickHouse/issues/118958). [#118994](https://github.com/ClickHouse/ClickHouse/pull/118994) ([Groene AI](https://github.com/groeneai)).
* Fixed `if`, `multiIf`, and `CASE` returning a wrapped value instead of raising `DECIMAL_OVERFLOW` once JIT-compiled, when a `Decimal`, `DateTime64`, or `Time64` branch is lifted to a larger scale (with default settings, after the query had run a few times). [#123186](https://github.com/ClickHouse/ClickHouse/pull/123186) ([Groene AI](https://github.com/groeneai)).
* Fixed wrong results of `extract` and `replaceRegexpAll` (and its alias `regexp_replace`) under the default-enabled `optimize_rewrite_regexp_functions`: `extract` could return a different occurrence when a leading greedy `^.*` was stripped, or a truncated result for a pattern ending with `.*$` whose only parentheses are an inline flag group, such as `(?i)b.*$`; `replaceRegexpAll` could silently lose replacements when a pattern that can match more than once (with an inline `(?m)` flag, or a tail that can match the empty string, such as `o*$`) was rewritten to `replaceRegexpOne`; and both mishandled a trailing `.*$` or `$` that is literal text inside an unterminated `\Q`. [#117228](https://github.com/ClickHouse/ClickHouse/pull/117228) ([Alexey Milovidov](https://github.com/alexey-milovidov)). [#117227](https://github.com/ClickHouse/ClickHouse/pull/117227) ([Alexey Milovidov](https://github.com/alexey-milovidov)). [#118361](https://github.com/ClickHouse/ClickHouse/pull/118361) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed rows silently missing from the result of `match` with a pattern that has a zero-allowing quantifier behind an inline flag group or an empty `\Q\E` quote. [#118351](https://github.com/ClickHouse/ClickHouse/pull/118351) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed the best-effort date/time parsers reading one byte past the end of the value. The parsed result of a row of a `String` column could depend on the text of the following row: a valid value was rejected as `NULL` or zero, or `addMonths` and the rest of the add-interval family returned date and time fields taken from the neighbouring row. [#122246](https://github.com/ClickHouse/ClickHouse/pull/122246) ([Groene AI](https://github.com/groeneai)).
* Fixed `toStartOfMinute`, `toStartOfHour`, `toStartOfDay`, `toStartOfFiveMinutes`, `toStartOfTenMinutes`, `toStartOfFifteenMinutes`, `timeSlot`, `toTimeWithFixedDate`, `toStartOfInterval` and `dateTrunc` returning a value one second later, possibly in the next interval, for a `DateTime64` before 1970 with a fractional part. For example, `toStartOfMinute(toDateTime64('1969-12-31 23:58:59.500', 3))` returned `23:59:00`. Also fixed `toStartOfInterval` with an origin and a `MONTH`, `QUARTER` or `YEAR` interval returning a value after its argument when the argument was earlier in the day than the origin, and rounding a bucket start clipped to the end of a shorter month to the previous bucket. [#122138](https://github.com/ClickHouse/ClickHouse/pull/122138) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed accepting a column whose two serialization streams map to the same file name (for example ``Nullable(JSON(`null` Int64))`` or ``Tuple(`a` Tuple(`b` UInt64), `a.b` UInt64)``). Such a table was created successfully, but its parts were written with both streams in one file and could not be read, merged, or checked. Creating such a column now fails with `BAD_ARGUMENTS`, as a collision between two different columns already did. Existing tables still attach, with the collision logged. [#115632](https://github.com/ClickHouse/ClickHouse/pull/115632) ([Pavel Kruglov](https://github.com/Avogar)).
* Fix a valid `JOIN ON` query rejected with `TYPE_MISMATCH` by `optimize_redundant_comparisons`, which is enabled by default since 26.7. It affects a join expression whose `AND` has a `Nothing`-typed operand, for example a join key compared against an `ARRAY JOIN []` alias. [#117476](https://github.com/ClickHouse/ClickHouse/pull/117476) ([Groene AI](https://github.com/groeneai)).
* Fixed wrong results, or an `ILLEGAL_COLUMN` error, of a `JOIN` whose condition equates both a column and an expression of that column (for example `ON t1.k = t2.k AND intDiv(t1.k, 2) = intDiv(t2.k, 2)`) when a filter on that expression is pushed down to the other side of the join: the pushed-down copy applied the expression twice. Closes [#122613](https://github.com/ClickHouse/ClickHouse/issues/122613). [#122686](https://github.com/ClickHouse/ClickHouse/pull/122686) ([Groene AI](https://github.com/groeneai)).
* Fixed `SAMPLE` on the first table of a `JOIN` being applied to the other joined tables too, which returned too few rows, or failed with `SAMPLING_NOT_SUPPORTED` when a joined table had no sampling key. [#124767](https://github.com/ClickHouse/ClickHouse/pull/124767) ([awss](https://github.com/awss1i)).
* Fixed missing rows from a `Distributed` or `remote` query whose `WHERE` has a `NOT` over an `AND` containing a conjunct that cannot be converted to an AST, such as a lambda or `dictGet`: the pushed-down predicate became stronger than the original one. [#117620](https://github.com/ClickHouse/ClickHouse/pull/117620) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fix wrong results when a query selects an `ALIAS` column together with a window function with `enable_analyzer = 1`, over a `Distributed` table (or `remote`) with two or more shards, or over a table read with parallel replicas. Values could be returned in the wrong columns with no error, or the query could fail with `NUMBER_OF_COLUMNS_DOESNT_MATCH` or `CANNOT_PARSE_DATETIME`. [#116498](https://github.com/ClickHouse/ClickHouse/pull/116498) ([Groene AI](https://github.com/groeneai)).
* Fixed a distributed `SELECT` silently returning a partial result when `connection_pool_max_wait_ms` is set to a finite value and `skip_unavailable_shards = 1`. A shard whose replica the initiator had no free connection slot for was reported as an unavailable shard and dropped, so a two-shard query could return one shard's rows with exit code `0`. Such a shard now fails the query with `ALL_CONNECTION_TRIES_FAILED`, the same error the default `skip_unavailable_shards = 0` already produces. Closes [#120832](https://github.com/ClickHouse/ClickHouse/issues/120832). [#120969](https://github.com/ClickHouse/ClickHouse/pull/120969) ([Groene AI](https://github.com/groeneai)).
* Fixed asynchronous TLS connections occasionally failing with an unrelated OpenSSL error left by another connection on the same OS thread. This could terminate distributed queries with a misleading network exception. [#116692](https://github.com/ClickHouse/ClickHouse/pull/116692) ([Dmitriy Borisenko](https://github.com/otselnik)).
* Fixed a query over a `Distributed` table silently returning too few rows when its `WHERE` calls `joinGet`: the condition was sent to the shards, and each one answered the call against its own local `Join` table rather than the initiator's. `joinGet` is now treated as non-deterministic and stays on the initiator. [#121822](https://github.com/ClickHouse/ClickHouse/pull/121822) ([Nikita Taranov](https://github.com/nickitat)).
* Fix `THERE_IS_NO_COLUMN` for a `Distributed` query that has an `IN` over the sharding key outside its `WHERE`, in the `SELECT` projection, in `GROUP BY`, in `ORDER BY`, or in `LIMIT BY`. The default-enabled `optimize_skip_unused_shards_rewrite_in` rewrote that `IN` per shard, which changed the result column's name, so the initiator could not bind the column the shard returned. [#117252](https://github.com/ClickHouse/ClickHouse/pull/117252) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed cancelling a distributed, `s3Cluster` or parallel-replicas `SELECT` taking up to `receive_timeout` (300 s by default) to take effect, and never reaching some of the remote sources, when one of them was draining the packets left over after a `LIMIT` was satisfied. [#118696](https://github.com/ClickHouse/ClickHouse/pull/118696) ([Groene AI](https://github.com/groeneai)).
* Fixed a server abort (`vector[] index out of bounds`) when reading a `Distributed` table with `prefer_global_in_and_join = 1` and an `IN` expression that the analyzer shares between two parent expressions. The local to `GLOBAL IN` rewrite now rewrites the `IN` function in place, so every reference to a shared node is promoted. [#120681](https://github.com/ClickHouse/ClickHouse/pull/120681) ([Groene AI](https://github.com/groeneai)).
* Fixed `INSERT INTO SELECT ... FROM url(...)`, and the same shape with `s3` or `azureBlobStorage`, with parallel replicas enabled inserting the data once per replica. Closes [#120485](https://github.com/ClickHouse/ClickHouse/issues/120485). [#120488](https://github.com/ClickHouse/ClickHouse/pull/120488) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fix `INSERT INTO SELECT ... FROM url(...)` (and `s3`, `azureBlobStorage`, ...) with parallel replicas enabled inserting the data once per shard of the destination cluster: the query forwarded to the shards now names the `*Cluster` table function with the cluster of the `Distributed` table, so every shard reads only its share of the files. Such an `INSERT` also no longer writes into the shards' local tables when the destination has a deterministic sharding key, because the rows a cluster table function hands to a shard cannot satisfy that key and the resulting placement made `optimize_skip_unused_shards` return partial results; it falls back to the ordinary `INSERT ... SELECT` instead, which places the rows through the `Distributed` sink. [#121070](https://github.com/ClickHouse/ClickHouse/pull/121070) ([Igor Nikonov](https://github.com/devcrafter)).
* Fixed duplicated rows returned by `ANY RIGHT JOIN` with `any_join_distinct_right_table_keys = 1` when parallel replicas are enabled. [#123683](https://github.com/ClickHouse/ClickHouse/pull/123683) ([Groene AI](https://github.com/groeneai)).
* Fixed `CREATE MATERIALIZED VIEW ... POPULATE` and `CREATE TABLE ... AS SELECT` in a `Replicated` database with parallel replicas enabled: each replica sent its population to other replicas, so its rows landed in other replicas' tables (duplicated there, missing on the replica itself), or the query failed with `UNKNOWN_TABLE`. The population now ignores the query's parallel replicas and `parallel_distributed_insert_select` settings, so each replica fills only its own table. Closes [#124446](https://github.com/ClickHouse/ClickHouse/issues/124446). [#124477](https://github.com/ClickHouse/ClickHouse/pull/124477) ([Groene AI](https://github.com/groeneai)).
* Fix `S3` client refresh overwriting static authentication settings and breaking subsequent queries. [#120433](https://github.com/ClickHouse/ClickHouse/pull/120433) ([alesapin](https://github.com/alesapin)).
* Fix a server abort when an Azure Blob Storage endpoint reports an asynchronous blob copy as completed without the optional `x-ms-copy-source` or `x-ms-copy-status-description` header. [#120935](https://github.com/ClickHouse/ClickHouse/pull/120935) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Reads from Azure Blob Storage now verify that the returned range starts at the requested offset, so an endpoint or proxy that ignores the request `Range` fails the read with `HTTP_RANGE_NOT_SATISFIABLE` instead of delivering the wrong bytes. [#120955](https://github.com/ClickHouse/ClickHouse/pull/120955) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* A bounded read from Azure Blob Storage whose response ends before the requested right bound is now reopened and, if the endpoint keeps answering short, fails with `UNEXPECTED_END_OF_FILE` instead of silently returning a truncated file. [#120963](https://github.com/ClickHouse/ClickHouse/pull/120963) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fix a buffer over-read on the sequential read path from Azure Blob Storage: an endpoint that answers a ranged request with more data than was requested could deliver bytes from outside the requested range to the caller. The end of a read is now decided by the locally set right bound, not by the `Content-Length` of the response, and a read is pinned to the listed generation of the blob with `If-Match`, so an object replaced during a read fails with `AZURE_OBJECT_CHANGED_DURING_READ` instead of being truncated (new setting `azure_validate_etag_on_read`, enabled by default). [#120910](https://github.com/ClickHouse/ClickHouse/pull/120910) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed a disk with `object_storage_type = 'local'` and a relative `path` removing its own root directory once the last blob in it was deleted. Anything else stored in that directory was lost with it; in particular, a disk whose `path` pointed at the directory of its own `local` metadata became unusable. [#119119](https://github.com/ClickHouse/ClickHouse/pull/119119) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed `S3` requests that keep failing with a retryable error being attempted `(s3_retry_attempts + 1)^2` times instead of `s3_retry_attempts + 1`. Fixed an error that a plain-HTTP `S3` endpoint sends before reading the whole request body (for example `NoSuchUpload` for an expired multipart upload) being retried as a `Broken pipe` network error instead of being reported. Closes [#124326](https://github.com/ClickHouse/ClickHouse/issues/124326). [#124557](https://github.com/ClickHouse/ClickHouse/pull/124557) ([Groene AI](https://github.com/groeneai)).
* Fixed a heap use-after-free in the `s3`, `azureBlobStorage`, `hdfs`, and similar object-storage table functions and engines when an exception such as `MEMORY_LIMIT_EXCEEDED` was thrown while creating the reader of a file in a row input format such as `CSV`. [#125090](https://github.com/ClickHouse/ClickHouse/pull/125090) ([Groene AI](https://github.com/groeneai)).
* Fixed exceptions such as `UNKNOWN_CODEC` when reading `MergeTree` tables through the userspace page cache (`use_page_cache_for_disks_without_file_cache = 1` with `remote_filesystem_read_method = 'read'`, or `use_page_cache_for_local_disks = 1`): files kept inside packed archives (statistics, skip indices, parts in packed storage) were read from the wrong offset. Closes [#122157](https://github.com/ClickHouse/ClickHouse/issues/122157). [#122949](https://github.com/ClickHouse/ClickHouse/pull/122949) ([Groene AI](https://github.com/groeneai)).
* Fix Parquet `time32`/`time64` columns being read as `DateTime64` and then silently shifted by `session_timezone` when inserted into a `Time64` target column. Parquet `TIME` logical types now map directly to `Time64`, and the missing `Time64 -> Time` cast is added. [#106019](https://github.com/ClickHouse/ClickHouse/pull/106019) ([Shaohua Wang](https://github.com/tiandiwonder)).
* Fixed a `Parquet` reader bug where a filter on an integer column read with a type hint that reorders the file's statistics (for example `UInt32` over a plain `INT32` column, `Enum8` over a `UINT_8` one, or `IPv4` over a `UINT_64` one) could silently return fewer rows than the file holds. Such statistics are no longer used for row group or page pruning, and a `DATE` value outside the requested type's range now raises the same error with pruning as without it. Closes [#118376](https://github.com/ClickHouse/ClickHouse/issues/118376). [#121033](https://github.com/ClickHouse/ClickHouse/pull/121033) ([Groene AI](https://github.com/groeneai)).
* Fixed an infinite loop in the Parquet reader on a ZSTD or Brotli compressed page that decompresses to fewer bytes than its header declares. Such a query could not be stopped by `max_execution_time` or `KILL QUERY`; it now fails with `INCORRECT_DATA`. Closes [#123274](https://github.com/ClickHouse/ClickHouse/issues/123274). [#123298](https://github.com/ClickHouse/ClickHouse/pull/123298) ([Groene AI](https://github.com/groeneai)).
* Fix `Unexpected number of rows in column subchunk` (`LOGICAL_ERROR`) when filtering a Parquet file whose `Bool` column is RLE-encoded (pyarrow's default for data page v2). The filter is now applied while decoding RLE-encoded and dictionary-encoded pages, which also makes `PREWHERE` over dictionary-encoded columns of Parquet files without a page index faster (ClickBench q31 1.92 s to 1.21 s). Closes [#123483](https://github.com/ClickHouse/ClickHouse/issues/123483). [#123618](https://github.com/ClickHouse/ClickHouse/pull/123618) ([Groene AI](https://github.com/groeneai)).
* Fixed wrong results when reading a `Parquet` file with a structure hint whose type differs from the stored one. Row-group and page pruning, bloom filters, and dictionary filters now hash and interpret the query constant in the stored physical type rather than the hinted one, which fixes cases such as narrowing, signedness flips, `Enum`, `Date`/`Date32`/`Time`, length-mismatched `String`/`FixedString`, and `Bool` over an integer column. Reading a `UINT_8` column with a `Bool` hint now also treats every nonzero value as `true`, so `x = true`, `x IN (true)`, and `WHERE x` agree. [#123864](https://github.com/ClickHouse/ClickHouse/pull/123864) ([Groene AI](https://github.com/groeneai)). [#121077](https://github.com/ClickHouse/ClickHouse/pull/121077) ([Groene AI](https://github.com/groeneai)). [#124285](https://github.com/ClickHouse/ClickHouse/pull/124285) ([Groene AI](https://github.com/groeneai)).
* Fixed `Parquet` output failing with `Capacity error: array cannot contain more than 2147483646 bytes` or `Uncompressed page is too big` when a batch of rows held more than 2 GiB of `String` or `FixedString` data. A batch is now bounded by bytes as well as by rows, which also lowers the peak memory of the write. [#122482](https://github.com/ClickHouse/ClickHouse/pull/122482) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed `SELECT ... FORMAT Arrow` failing with `Method getDataAt is not supported` for `JSON`, `Dynamic`, and `QBit` columns, and silently exporting heap addresses instead of the aggregate state for `AggregateFunction` columns. Added the `output_format_arrow_unsupported_types` setting (`throw` / `text` / `binary`, default `binary`), which supersedes `output_format_arrow_unsupported_types_as_binary`. Such columns can now also be read back into their original type, which previously failed or silently corrupted the value. `INSERT INTO ... ENGINE = ArrowFlight` now follows this setting too; it previously rejected such columns unconditionally, so an insert that used to fail may now write an opaque column. Set `output_format_arrow_unsupported_types = 'throw'` to keep rejecting it. [#115250](https://github.com/ClickHouse/ClickHouse/pull/115250) ([Yakov Olkhovskiy](https://github.com/yakov-olkhovskiy)).
* Fix `O(n^2)` decompression of gzip/zlib/deflate streams whose single DEFLATE block spans the whole stream, the shape zlib-ng produces at compression level 1 (the default of the official .NET SDK): a 24 MiB gzip HTTP body that took 11 s to ingest in 26.7 now takes 0.12 s, identical to a multi-block body, with memory bounded by the buffer size instead of the block size. [#114059](https://github.com/ClickHouse/ClickHouse/pull/114059) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed a segmentation fault or `std::length_error` when reading `TSV` formats with `input_format_tsv_crlf_end_of_line = 1` if an escape sequence ended exactly at the end of a read buffer. [#123861](https://github.com/ClickHouse/ClickHouse/pull/123861) ([Groene AI](https://github.com/groeneai)).
* Fixed lost rows when a query over a `MySQL`, `PostgreSQL`, `SQLite`, or ODBC/JDBC table compares a column, string, number, or `Decimal`, with an `Enum` constant, also inside a tuple, an `IN` list, `Nullable`, `Variant`, or `Dynamic`, at any depth. The filter sent to the external database used the `Enum`'s number, while ClickHouse compares a string column with the `Enum`'s name, and `PostgreSQL` rejected such a query. An `IN` list or row of `Variant` or `Decimal` constants is no longer sent as one quoted string. [#123843](https://github.com/ClickHouse/ClickHouse/pull/123843) ([Groene AI](https://github.com/groeneai)).
* Fixed wrong results of a negated `IN` with a `NULL` in the list, e.g. `x NOT IN (1, NULL)` or `NOT (x IN (1, NULL))`, over `MySQL`, `PostgreSQL`, `SQLite`, and `ODBC` tables: the filter pushed to the external database now leaves the `NULL` members out of the list, the way ClickHouse evaluates the set. [#124339](https://github.com/ClickHouse/ClickHouse/pull/124339) ([Groene AI](https://github.com/groeneai)).
* Fixed silent data loss when an `EmbeddedRocksDB` table is renamed. `RENAME TABLE` now moves the table's `RocksDB` directory to the table's new location, so the rows are still there after a server restart. Previously the directory was left behind, and after a restart the table opened a fresh empty `RocksDB` while the real rows stayed orphaned under the old path. [#112224](https://github.com/ClickHouse/ClickHouse/pull/112224) ([Groene AI](https://github.com/groeneai)).
* `optimize_inverse_dictionary_lookup` (enabled by default) no longer rewrites `dictGet(dict, attr, key) = const` when a `Variant`, `Dynamic`, or `JSON` appears in the type of `key` or in the dictionary's declared key type. The rewritten predicate is not equivalent there, so the query could fail with `CANNOT_INSERT_NULL_IN_ORDINARY_COLUMN`, `ILLEGAL_TYPE_OF_ARGUMENT`, or `NO_COMMON_TYPE`, or return wrong results. [#120888](https://github.com/ClickHouse/ClickHouse/pull/120888) ([Groene AI](https://github.com/groeneai)).
* Fixed SQL injection through identifiers in the `PostgreSQL` integration: relation, schema, column, publication, and replication-slot names used by the `PostgreSQL` table engine, the `postgresql` table function, `PostgreSQL` dictionary sources, and `MaterializedPostgreSQL` were escaped with backslashes, which PostgreSQL does not honour inside a quoted identifier, so a remote name containing a double quote could end the identifier and let the rest execute on the PostgreSQL server. Relations and columns whose names contain a double quote or a backslash can now be read and replicated, including those listed in `materialized_postgresql_tables_list`; an empty element in that setting is now rejected. [#119216](https://github.com/ClickHouse/ClickHouse/pull/119216) ([Groene AI](https://github.com/groeneai)). [#119103](https://github.com/ClickHouse/ClickHouse/pull/119103) ([Groene AI](https://github.com/groeneai)).
* Fixed `PARALLEL WITH`, `EXECUTE AS`, and the `QueryRunner` table engine skipping the access checks of the `CREATE` statements they execute, which allowed creating tables and databases without the corresponding privileges and defeated the `readonly` and `allow_ddl` settings. [#119848](https://github.com/ClickHouse/ClickHouse/pull/119848) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed an `HDFS` database serving a table from its internal cache without the `READ ON HDFS` grant. The grant and the `remote_url_allow_hosts` filter were checked only while a table name was resolved for the first time, so once any user holding the grant had read a name, every user with `SELECT` on the database was served the contents of the file, and that table kept being served after its host was removed from the allow-list. `EXISTS TABLE`, which requires only `SHOW TABLES`, answered from the same cache and so reported which names other users had resolved. Both checks now run before the cache is consulted, and the existence probe no longer consults it. [#119523](https://github.com/ClickHouse/ClickHouse/pull/119523) ([Groene AI](https://github.com/groeneai)).
* Fixed filesystem containment checks accepting a path with an embedded NUL byte. A `DeltaLakeLocal` or `IcebergLocal` table could be pointed outside of `user_files` this way. [#119846](https://github.com/ClickHouse/ClickHouse/pull/119846) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed several engines disclosing an `Alias` table's target schema to a user who holds no privilege on that target. Reading the metadata of an `Alias` through any of them now requires table-level `SHOW COLUMNS` on its target, which is what a `DESCRIBE` of the target already requires. [#117572](https://github.com/ClickHouse/ClickHouse/pull/117572) ([Groene AI](https://github.com/groeneai)).
* `remote(, 'db', 'table', 'user', 'password')`, and the same form of `remoteSecure` and of the `Remote` and `RemoteSecure` table engines, no longer write the password into `system.query_log`, `system.text_log`, and the server log in cleartext. [#121474](https://github.com/ClickHouse/ClickHouse/pull/121474) ([Groene AI](https://github.com/groeneai)).
* Fixed SQL injection through identifiers when inserting into a table with the `SQLite` engine. It is now also possible to insert into a SQLite table whose name, or column name, legitimately contains a double quote or a backslash. [#117421](https://github.com/ClickHouse/ClickHouse/pull/117421) ([Groene AI](https://github.com/groeneai)).
* Fixed credential masking for `nats_url`, `rabbitmq_address`, the `jdbc` and `odbc` connection string, and the `format_avro_schema_registry_url`, `url_base`, and `s3_base` settings in `SHOW CREATE`, `system.tables`, and the query text in `system.query_log`. Closes [#121257](https://github.com/ClickHouse/ClickHouse/issues/121257). [#121425](https://github.com/ClickHouse/ClickHouse/pull/121425) ([Groene AI](https://github.com/groeneai)).
* Fixed a `Backup` database engine printing the credentials of its destination in plaintext. `SHOW CREATE DATABASE`, `system.databases.engine_full`, `system.query_log`, and the messages that reject a malformed locator no longer expose an `AzureBlobStorage` `account_key`, a connection string, or a presigned URL regardless of `format_display_secrets_in_show_and_select`. [#117429](https://github.com/ClickHouse/ClickHouse/pull/117429) ([Groene AI](https://github.com/groeneai)).
* `KILL TRANSACTION ... ON CLUSTER`, `KILL PART_MOVE_TO_SHARD ... ON CLUSTER`, `SYSTEM STOP THREAD FUZZER ON CLUSTER`, `SYSTEM START THREAD FUZZER ON CLUSTER`, and `SYSTEM RESET COVERAGE ON CLUSTER` no longer run without checking any privilege. Each now requires what its non-`ON CLUSTER` spelling has always required. [#118360](https://github.com/ClickHouse/ClickHouse/pull/118360) ([Groene AI](https://github.com/groeneai)).
* Fixed metadata disclosure through a chain of `Alias` tables. `DESCRIBE`, `hasColumnInTable`, `system.columns`, `system.tables`, `system.projections`, `system.constraints`, and `system.data_skipping_indices` now require the privilege on every table an `Alias` resolves through, as reading its rows already did. [#118967](https://github.com/ClickHouse/ClickHouse/pull/118967) ([Groene AI](https://github.com/groeneai)).
* Fixed a bug where `REVOKE GRANT OPTION FOR` was accepted but then omitted from `SHOW GRANTS`, from `system.grants`, and from the persisted access metadata whenever another revoked database, table, column, or named-collection name shared a prefix with it. The grant option therefore came back after a server restart, and the user could pass it on with `GRANT CURRENT GRANTS`. [#122078](https://github.com/ClickHouse/ClickHouse/pull/122078) ([Groene AI](https://github.com/groeneai)).
* Fixed settings constraints from a settings profile not being enforced against the other setting assignments in the same statement. `SET profile = 'p', = ` could override a `CONST`, `MIN`/`MAX`, or `readonly` constraint that profile `p` installs. The same escape existed through an in-query `SETTINGS` clause, HTTP URL parameters, and Arrow Flight session options. [#120376](https://github.com/ClickHouse/ClickHouse/pull/120376) ([Raúl Marín](https://github.com/Algunenano)).
* Fixed row policies on `Memory` tables being ignored when a read is executed from a serialized query plan, such as a distributed plan or a parallel-replicas plan. Since `Memory` gained `PREWHERE` support, such reads could return rows the policy excludes. [#122503](https://github.com/ClickHouse/ClickHouse/pull/122503) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed an integer underflow in the `MySQL` protocol handshake handler that could cause the server to buffer an unbounded amount of data from an unauthenticated client. [#115776](https://github.com/ClickHouse/ClickHouse/pull/115776) ([Dmitrii Tishkin](https://github.com/dmi03)).
* Statistics-based part pruning is now disabled for tables with row policies. [#122035](https://github.com/ClickHouse/ClickHouse/pull/122035) ([alesapin](https://github.com/alesapin)).
* A row policy on a `Set`-engine table was accepted but never applied: the right side of `IN` read the prebuilt set directly and returned the rows the policy hides. Such a query now fails with `ACCESS_DENIED`, because the `Set` engine has no read path that could filter those rows, and `IN set_table` now requires `SELECT` on all columns of the table. On `Replicated` databases, `ALTER ... DELETE`, `ALTER ... UPDATE`, `DELETE`, and `UPDATE` now run the initiator's checks as the submitting user, so the same row-policy and access checks apply there too; with `ON CLUSTER`, run the query on a host that has the right-hand `Set` table, or enable `distributed_ddl_use_initial_user_and_roles` on every host and set `distributed_ddl_entry_format_version` to at least `8`. Queries that used a `Set` table covered by a database-wide row policy ran unfiltered before and now throw. [#120312](https://github.com/ClickHouse/ClickHouse/pull/120312) ([Harikrishnan Prabakaran](https://github.com/harikrishnan94)). [#122141](https://github.com/ClickHouse/ClickHouse/pull/122141) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed the `Kafka` and `NATS` table engines ignoring `remote_url_allow_hosts`: broker addresses from `kafka_broker_list`, `nats_url`, and `nats_server_list` are now checked against the remote host filter. A forbidden address is rejected at `CREATE TABLE` with `UNACCEPTABLE_URL`, as the `RabbitMQ` engine already does. [#121825](https://github.com/ClickHouse/ClickHouse/pull/121825) ([János Benjamin Antal](https://github.com/antaljanosbenjamin)).
* HTTP headers in `HTTP` dictionary sources are now hidden in `SHOW CREATE DICTIONARY`, `system.tables`, and query logs, like passwords. They can still be shown with `display_secrets_in_show_and_select`. [#122673](https://github.com/ClickHouse/ClickHouse/pull/122673) ([Matheus Nerone](https://github.com/Manerone)).
* Fixed secret settings of `S3Queue` and `AzureQueue` tables written with the legacy `s3queue_` prefix, such as `s3queue_after_processing_move_secret_access_key`, being shown in cleartext in `SHOW CREATE TABLE`, `system.tables`, `system.query_log`, and the server log. They are now hidden as they are without the prefix. [#123060](https://github.com/ClickHouse/ClickHouse/pull/123060) ([Groene AI](https://github.com/groeneai)).
* Column-level `SELECT` privileges are now enforced for columns used only inside `indexHint` and for `ALIAS` columns referenced in `PREWHERE`. As in `WHERE`, referencing an `ALIAS` column in `PREWHERE` requires the grant on the alias name; a grant on its source columns is no longer sufficient. A metadata-only `ALTER` that changes a subcolumn read by a `MATERIALIZED` column through an `ALIAS` is now refused like a direct reference. [#120516](https://github.com/ClickHouse/ClickHouse/pull/120516) ([Shankar Iyer](https://github.com/shankar-iyer)).
* Fixed a row policy bypass: a direct `JOIN` with an `EmbeddedRocksDB`, `KeeperMap`, or `Redis` table in the legacy analyzer (`enable_analyzer = 0`) ignored the row policy of the right table and returned hidden rows, and `joinGet` on a `Join` table ignored its row policy in both analyzers. Such a table is now joined through its query plan, which keeps the filter, and `JOIN` or `joinGet` against a `Join` table under a row policy throws `ACCESS_DENIED`. [#121398](https://github.com/ClickHouse/ClickHouse/pull/121398) ([Vladimir Cherkasov](https://github.com/vdimir)).
* `CREATE OR REPLACE` in a `Replicated` database or with `ON CLUSTER` now requires the drop privilege for the kind of the table it replaces, so a user without `DROP DICTIONARY` can no longer replace a dictionary. [#122272](https://github.com/ClickHouse/ClickHouse/pull/122272) ([Nikolay Degterinsky](https://github.com/evillique)).
* A view with `SQL SECURITY DEFINER` or `SQL SECURITY NONE` that can hide rows is now read as a whole and is opaque to the optimizations of the query that reads it; previously an expression of the outer query could be evaluated on the hidden rows and reveal them, for example through an exception message. `EXPLAIN` shows the plan of such a view only to users who could have created it or who may display secrets, and seeing the plan of such a sealed view now also requires the `CREATE VIEW` privilege. [#122330](https://github.com/ClickHouse/ClickHouse/pull/122330) ([Alexey Milovidov](https://github.com/alexey-milovidov)). [#123325](https://github.com/ClickHouse/ClickHouse/pull/123325) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fix a credential written in cleartext to `system.query_log` and the server log when a `key = value` argument precedes the positional arguments of the `mongodb`, `redis`, `remote`, `arrowFlight`, and `ytsaurus` table functions or the `MongoDB`, `Redis`, `Remote`, `ArrowFlight`, `ExternalDistributed`, and `YTsaurus` table engines. A positional argument after a named one is now always hidden, and the value of a named-collection override whose key is written as an expression is hidden for every such engine. [#122770](https://github.com/ClickHouse/ClickHouse/pull/122770) ([Raúl Marín](https://github.com/Algunenano)).
* Rewriting the body of a view with `ALTER TABLE ... MODIFY QUERY` now needs the same grants as creating it with its SQL security: `SET DEFINER` on the definer of a `SQL SECURITY DEFINER` view, or `ALLOW SQL SECURITY NONE` for a `SQL SECURITY NONE` view. An `ON CLUSTER MODIFY QUERY` fails with `UNKNOWN_TABLE` unless it runs on a host that has the view. [#121629](https://github.com/ClickHouse/ClickHouse/pull/121629) ([Sema Checherinda](https://github.com/CheSema)).
* Fixed `GRANT ... ON db*.table` being silently rewritten to `db.table*`, which could cause incorrect privilege grants. The pattern `db*.table` is now rejected as a syntax error. `CREATE` / `ALTER` / `DROP ROW POLICY`, `SHOW POLICIES`, and `SHOW CREATE POLICY` now also reject prefix wildcards (`db*.*`, `db.table*`, `table*`), which were previously silently narrowed to the exact name (`db.*`, `db.table`, `table`). [#108063](https://github.com/ClickHouse/ClickHouse/pull/108063) ([Aditya Kumar](https://github.com/adityaksolves)).
* Update `mongo-c-driver` to 2.5.6 and `mongo-cxx-driver` to r4.6.0, fixing an out-of-bounds write during MongoDB connection monitoring reconnects (CVE-2026-96746). [#119346](https://github.com/ClickHouse/ClickHouse/pull/119346) ([Actuele AI](https://github.com/actueleai)). [#124282](https://github.com/ClickHouse/ClickHouse/pull/124282) ([Actuele AI](https://github.com/actueleai)). [#124648](https://github.com/ClickHouse/ClickHouse/pull/124648) ([Actuele AI](https://github.com/actueleai)).
* Fixed access entities (users, roles, row policies, and others) of the `local_directory` access storage being lost after a restart, or a dropped row policy making every query fail with `FILE_DOESNT_EXIST`. This happened to entities created or dropped within a minute after `SYSTEM RELOAD USERS` if the server was then killed, or at any time after `SYSTEM RELOAD USERS` failed to write the storage's `.list` files. [#125058](https://github.com/ClickHouse/ClickHouse/pull/125058) ([Groene AI](https://github.com/groeneai)).
* The web terminal and the SSH interface no longer reset the settings of the user (from settings profiles, roles, and `CREATE USER ... SETTINGS`) to default values. Previously, restrictions such as `readonly`, resource limits, and `additional_table_filters` were not applied in these interfaces. [#125515](https://github.com/ClickHouse/ClickHouse/pull/125515) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Update `expat` to 2.9.0, fixing a denial of service through a crafted backup manifest during `RESTORE` (CVE-2026-66046) and the other 2.8.3–2.9.0 security fixes. [#124255](https://github.com/ClickHouse/ClickHouse/pull/124255) ([Actuele AI](https://github.com/actueleai)).
* Fixed failures during pipeline expansion, such as external sorting or the merge stage of a `GROUP BY`, when the memory limit is exceeded. The query now reports the original exception instead of an inconsistent-pipeline error, a segmentation fault, or a read of freed memory. Closes [#125251](https://github.com/ClickHouse/ClickHouse/issues/125251). [#121502](https://github.com/ClickHouse/ClickHouse/pull/121502) ([Alexey Milovidov](https://github.com/alexey-milovidov)). [#125283](https://github.com/ClickHouse/ClickHouse/pull/125283) ([Groene AI](https://github.com/groeneai)).
* Fixed a stored query combining `UNION` with a parenthesized `INTERSECT`/`EXCEPT` group losing its parentheses when serialized, so `X UNION ALL (Y EXCEPT Z)` was read back as `(X UNION ALL Y) EXCEPT Z`. Views returned wrong results after a server restart, and a materialized view could end up with metadata the server refuses to load, which prevented it from starting. [#111931](https://github.com/ClickHouse/ClickHouse/pull/111931) ([Groene AI](https://github.com/groeneai)).
* Fixed the `compatibility` setting: `compatibility = '26.8'` no longer reverts five defaults that 26.8 shipped or forces `MergeTree` `patch_parts_version` back to `v1`, and `compatibility = '26.1'` no longer disables `use_skip_indexes_on_data_read`, which 26.1 shipped enabled. [#118666](https://github.com/ClickHouse/ClickHouse/pull/118666) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed `compatibility = '25.11'` incorrectly resolving `query_plan_max_limit_for_lazy_materialization` to `10` instead of `100`. [#122768](https://github.com/ClickHouse/ClickHouse/pull/122768) ([Raúl Marín](https://github.com/Algunenano)).
* Setting the obsolete `enable_analyzer` (`allow_experimental_analyzer`) to `0` is accepted again and replaced with `1`, instead of failing with `SETTING_CONSTRAINT_VIOLATION` or `INCORRECT_QUERY`. Queries, sessions, settings profiles, and client configurations that still set it keep working after an upgrade, always with the analyzer, including configurations that spell the value as a `Float64` literal. [#122401](https://github.com/ClickHouse/ClickHouse/pull/122401) ([Nikita Fomichev](https://github.com/fm4v)). [#122763](https://github.com/ClickHouse/ClickHouse/pull/122763) ([Raúl Marín](https://github.com/Algunenano)).
* Fixed a server crash on AArch64 that could happen when the query profiler sampled a thread while it was connecting to a remote server, for example with `remote` or `remoteSecure`. Capturing stack traces, used for exceptions and by the query profiler, is also several times faster. [#122834](https://github.com/ClickHouse/ClickHouse/pull/122834) ([Raúl Marín](https://github.com/Algunenano)).
* Fixed `listen_host` `::` on hosts without a global IPv6 address, such as a container on an IPv4-only Docker network: it failed with a DNS error, so the official Docker image listened on IPv4 only and `localhost` over `::1` was refused. The server now listens on the dual-stack wildcard there. gRPC and Arrow Flight use one listener when `::` is the only wildcard, and `host_regexp` / `HOST REGEXP` / `HOST LIKE` restrictions match IPv4 clients of a dual-stack listener. [#122785](https://github.com/ClickHouse/ClickHouse/pull/122785) ([Groene AI](https://github.com/groeneai)).
* Fixed an issue where pressing Ctrl-R and then Ctrl-Z in the web terminal or the SSH interface suspended the whole server process. [#125512](https://github.com/ClickHouse/ClickHouse/pull/125512) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed `TOO_LARGE_STRING_SIZE` (`Too large sizes of FixedString to deserialize`) when reading a correctly written part whose `Array(FixedString(N))` column holds more than 1 GiB of elements in one read span. Such a span is now read in bounded steps instead of being rejected, so the affected parts can be read and merged again without being rewritten. Closes [#116772](https://github.com/ClickHouse/ClickHouse/issues/116772). [#117385](https://github.com/ClickHouse/ClickHouse/pull/117385) ([Groene AI](https://github.com/groeneai)).
* Fixed `CollapsingMergeTree` returning wrong rows when a row's `sign` is neither `1` nor `-1`. [#119900](https://github.com/ClickHouse/ClickHouse/pull/119900) ([Murphy](https://github.com/murphy-4o)).
* Fixed a table that exceeds `max_table_size_rows` never being able to come back under the limit: every merge threw `TABLE_SIZE_LIMIT_EXCEEDED`, so the table could not be compacted and its part count grew until inserts started failing. [#117229](https://github.com/ClickHouse/ClickHouse/pull/117229) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed a shutdown stall where a background merge or mutation left in a `MergeTree` background executor's queue kept holding its table lock, so any table lock taken later during shutdown waited for the full `lock_acquire_timeout` and then failed with `DEADLOCK_AVOIDED`. [#113653](https://github.com/ClickHouse/ClickHouse/pull/113653) ([Groene AI](https://github.com/groeneai)).
* Fixed `count()` returning the number of default values instead of the number of `NULL`s when `optimize_trivial_count_with_sparsity_filter` is used on a column widened to `Nullable` by a metadata-only `ALTER TABLE ... MODIFY COLUMN`. [#120245](https://github.com/ClickHouse/ClickHouse/pull/120245) ([Raúl Marín](https://github.com/Algunenano)).
* Fixed `MergeTree` tables with `non_replicated_deduplication_window` on object storage failing to load their deduplication log after being detached and attached back without inserts in between, and fixed the deduplication log possibly dropping its active file. [#121670](https://github.com/ClickHouse/ClickHouse/pull/121670) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed `ALTER TABLE ... COMMENT COLUMN` and `ALTER TABLE ... RENAME COLUMN` making reads of an `ALIAS` column's subcolumns, for example `arr.size0`, fail with `NO_SUCH_COLUMN_IN_TABLE` until the table was reloaded. Closes [#121421](https://github.com/ClickHouse/ClickHouse/issues/121421). [#121449](https://github.com/ClickHouse/ClickHouse/pull/121449) ([Groene AI](https://github.com/groeneai)).
* Fixed `CANNOT_READ_ALL_DATA` (`while reading prefix of column ...`) during query planning when a `MergeTree` table has an active empty Wide part, left by a `TTL` drop or by a mutation that deleted all rows of a part, and the query filters on a subcolumn, such as a key of a `Map(LowCardinality(String), String)` column. [#122756](https://github.com/ClickHouse/ClickHouse/pull/122756) ([Groene AI](https://github.com/groeneai)).
* Fixed `ATTACH PART` failing with `CORRUPTED_DATA` for a Compact part whose `default_compression_codec.txt` is missing, for example a part copied or restored without that file. [#119114](https://github.com/ClickHouse/ClickHouse/pull/119114) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed a `LOGICAL_ERROR` (`Sizes of nested column and null map of Nullable column are not equal after deserialization`) that made a `SELECT` of a `Nested` member fail with `Code: 49` until the server was restarted, after an `ALTER TABLE ... MODIFY COLUMN` on that member had been killed and a later mutation hardlinked the column into a new wide part. [#121561](https://github.com/ClickHouse/ClickHouse/pull/121561) ([Groene AI](https://github.com/groeneai)).
* Wide parts no longer split a fixed-width value across two compressed blocks when `max_compress_block_size` is not a multiple of the value size. This improves the compression ratio of type-specific codecs on such tables and fixes `CANNOT_COMPRESS` from `ALP`. [#122841](https://github.com/ClickHouse/ClickHouse/pull/122841) ([Raufs Dunamalijevs](https://github.com/rienath)).
* After `ALTER TABLE ... RENAME COLUMN`, the subcolumns of the renamed column, for example `c0.null` or `a.size0`, stayed resolvable under the old name. Reading them through a `Buffer` or `Merge` table, or using them in `OPTIMIZE ... DEDUPLICATE BY`, read uninitialized memory, and once a new column reused the old name they returned wrong values instead of throwing `UNKNOWN_IDENTIFIER`. [#122527](https://github.com/ClickHouse/ClickHouse/pull/122527) ([Groene AI](https://github.com/groeneai)).
* Fixed excessive memory usage when loading a data part with a corrupted `columns_substreams.txt`; such a part is now detached as broken. [#124157](https://github.com/ClickHouse/ClickHouse/pull/124157) ([Murphy](https://github.com/murphy-4o)).
* Fixed a `LOGICAL_ERROR` and silent data corruption when a column is named into the `skp_idx_` prefix so that its on-disk stream base equals a skip index's, making both share one marks file. Such a write is now rejected with `INCORRECT_FILE_NAME` naming both owners. [#113093](https://github.com/ClickHouse/ClickHouse/pull/113093) ([Groene AI](https://github.com/groeneai)).
* Fixed reads of a renamed `Nested` leaf column returning default values from wide parts while the `RENAME COLUMN` mutation was still pending. [#119134](https://github.com/ClickHouse/ClickHouse/pull/119134) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fix `CANNOT_COMPRESS` on merge or insert for a `Map` column with `with_buckets` serialization and `CODEC(T64)`. [#124695](https://github.com/ClickHouse/ClickHouse/pull/124695) ([Raufs Dunamalijevs](https://github.com/rienath)).
* Fixed a column added by `ALTER TABLE ... ADD COLUMN ... DEFAULT ` being filled with the type default instead of the evaluated expression when it is read through a single-conjunct explicit `PREWHERE` on the expression's dependency. [#117533](https://github.com/ClickHouse/ClickHouse/pull/117533) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed the order of rows in a data part written by a merge or a mutation with `TTL ... GROUP BY ... SET` when the `SET` clause assigns a new value to a column the sorting key is calculated from. Closes [#108514](https://github.com/ClickHouse/ClickHouse/issues/108514). [#119863](https://github.com/ClickHouse/ClickHouse/pull/119863) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed `NOT_FOUND_COLUMN_IN_BLOCK` when merging a table that has a rows TTL together with a move (`TO DISK`, `TO VOLUME`) or recompression (`RECOMPRESS`) TTL over a different column. [#121536](https://github.com/ClickHouse/ClickHouse/pull/121536) ([Murphy](https://github.com/murphy-4o)).
* Fixed `INSERT` into a table with a constant `TTL ... DELETE WHERE` whose condition is not exactly `UInt8`, for example `c > 10` over a `Nullable` column: a part where no row matched the condition was marked with the delete TTL and later rewritten by a needless TTL merge, and a condition that cannot be a filter, such as an `Array` column, was accepted instead of being rejected as in the other TTL code paths. [#122516](https://github.com/ClickHouse/ClickHouse/pull/122516) ([Groene AI](https://github.com/groeneai)).
* Fixed `INSERT` into a table whose `TTL` expression changes its type under a session setting, for example a `CAST` of a `Nullable` column under `cast_keep_nullable = 1`, which failed with `LOGICAL_ERROR` `Unexpected type ... of result TTL column`. Under such a setting, `ALTER TABLE ... MODIFY TTL` could also store a `TTL` that `CREATE TABLE` rejects, after which the table could not be attached again. A stored `TTL` is now analyzed with the server settings in `INSERT` and `ALTER`, as in `CREATE TABLE`. [#122973](https://github.com/ClickHouse/ClickHouse/pull/122973) ([Groene AI](https://github.com/groeneai)).
* Fixed an unsorted part with a primary index that did not match the data after a `TTL GROUP BY ... SET` merge that rewrites the column a subcolumn sorting key (such as `ORDER BY n.a`) is taken from. Queries with a condition on the sorting key could return wrong results. [#122373](https://github.com/ClickHouse/ClickHouse/pull/122373) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed `ALTER TABLE ... MODIFY TTL` accepting a TTL whose subquery reads a table function (for example `numbers` or `remote`), a view over one, a parameterized view, a temporary table, or the table itself. After such an `ALTER` the table could not be loaded again, so a server with synchronous table loading did not start. Now the `ALTER` fails. [#123561](https://github.com/ClickHouse/ClickHouse/pull/123561) ([Groene AI](https://github.com/groeneai)).
* Fixed standalone `UPDATE ... SET` substituting a `WITH` expression alias into a nested subquery that cannot resolve it. Where that name is a table name, the statement read the alias instead of the table, or silently succeeded where the equivalent `SELECT` raises `UNKNOWN_IDENTIFIER`. [#120026](https://github.com/ClickHouse/ClickHouse/pull/120026) ([Groene AI](https://github.com/groeneai)).
* `allow_non_metadata_alters = 0` now also rejects the `ALTER` commands that reach a `MergeTree` table as explicit mutations: `UPDATE`, `DELETE WHERE`, the five `MATERIALIZE` forms, `APPLY DELETED MASK`, `APPLY PATCHES`, and `REWRITE PARTS`. [#115287](https://github.com/ClickHouse/ClickHouse/pull/115287) ([Groene AI](https://github.com/groeneai)).
* Fixed `Cannot convert NULL value to non-Nullable type` in `ALTER TABLE ... UPDATE` with a scalar subquery when the subquery result is `Nullable` and the updated column is not. [#119926](https://github.com/ClickHouse/ClickHouse/pull/119926) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* `ALTER TABLE ... DROP COLUMN` and `ALTER TABLE ... CLEAR COLUMN` are now refused when they would leave a part with no columns at all, instead of wedging the mutation queue with a logical error or leaving an unreadable part. [#121104](https://github.com/ClickHouse/ClickHouse/pull/121104) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed a mutation such as `ALTER TABLE ... MODIFY COLUMN` or `RENAME COLUMN` committing a data part with no columns when the part held only columns the table no longer has (for example a partition detached before `DROP COLUMN` and re-attached after it), after which every read of the table failed with a logical error. Such a mutation now fails with `NO_SUCH_COLUMN_IN_TABLE`, like reads of that part, and the part and its data are kept. [#122400](https://github.com/ClickHouse/ClickHouse/pull/122400) ([Groene AI](https://github.com/groeneai)).
* Fixed `ALTER TABLE ... UPDATE` and `MATERIALIZE COLUMN` on a `Memory` table after `MODIFY COLUMN` of the updated column: later reads failed with `ILLEGAL_COLUMN` or returned wrong values, and `BACKUP` failed. [#123043](https://github.com/ClickHouse/ClickHouse/pull/123043) ([Groene AI](https://github.com/groeneai)).
* Fix `Found patch part ... that intersects mutation with version ...` on lightweight updates in a table created with `CREATE TABLE ... CLONE AS` or `ATTACH PARTITION ALL FROM` a table with lightweight updates. [#123620](https://github.com/ClickHouse/ClickHouse/pull/123620) ([Nikolay Degterinsky](https://github.com/evillique)).
* A synchronous mutation (`mutations_sync`) on a `MergeTree` table no longer reports success when the table is detached before the mutation runs; it fails with `UNFINISHED`, and the mutation continues after the table is attached again. [#124161](https://github.com/ClickHouse/ClickHouse/pull/124161) ([Murphy](https://github.com/murphy-4o)).
* `DELETE`, `UPDATE` and `ALTER ... DELETE/UPDATE` no longer refuse a `MergeTree` table of a database with `lazy_load_tables` that has not been accessed yet, and `SYSTEM DROP REPLICA ... FROM ZKPATH` no longer skips such a table when checking that the replica being dropped is not a live local one. [#118152](https://github.com/ClickHouse/ClickHouse/pull/118152) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed a `ReplicatedMergeTree` table whose metadata carries `table_readonly = 1` being unusable: its backup could not be restored, it could not be re-attached after `DETACH`, and `ALTER TABLE ... MODIFY SETTING table_readonly = 0` was refused. Converting a table with that setting to replicated is no longer done, by either the `convert_to_replicated` flag or `ATTACH TABLE ... AS REPLICATED`. [#119224](https://github.com/ClickHouse/ClickHouse/pull/119224) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* `CHECK TABLE` on a `ReplicatedMergeTree` replica whose Keeper session was lost now fails with `ABORTED` instead of returning `0`, which means that the check found broken data. Nothing was read in that case, so the healthy table was certified as broken. [#119381](https://github.com/ClickHouse/ClickHouse/pull/119381) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed the automatic `MergeTree` to `ReplicatedMergeTree` conversion silently not finishing for a table in a database with `lazy_load_tables`, which left the table read-only with no metadata in ZooKeeper and the conversion flag in place. [#118135](https://github.com/ClickHouse/ClickHouse/pull/118135) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fix an integer overflow in the DDL log retention check of `Replicated` databases that could cause premature removal of DDL log entries and replicas being incorrectly declared lost for a very large `logs_to_keep`. `logs_to_keep` is now limited to `2147483647`, so replicas on older releases also stay safe during a rolling upgrade: out-of-range values are rejected on `CREATE` and clamped, with a warning, when replayed from existing metadata, server config, or Keeper, and existing databases that hold a larger value in Keeper are fixed automatically when a replica on the new release starts. [#118103](https://github.com/ClickHouse/ClickHouse/pull/118103) ([Kirill Shokhin](https://github.com/kirillshokhin)). [#123105](https://github.com/ClickHouse/ClickHouse/pull/123105) ([Kirill Shokhin](https://github.com/kirillshokhin)).
* `ALTER DATABASE ... MODIFY COMMENT` on a database with `ENGINE = Backup` no longer writes a definition the server cannot read back, which made it refuse to start; metadata already written in that form now loads too. Backward incompatibility: a backup taken by an older server of a database with `ENGINE = Backup` stores the locator quoted into a string literal, and such a definition is no longer accepted from a `RESTORE`. [#118674](https://github.com/ClickHouse/ClickHouse/pull/118674) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Tables in a database with `lazy_load_tables` were missing from `system.parts`, `system.replicas` and related system tables, and refused by replica commands, after a restart. [#121332](https://github.com/ClickHouse/ClickHouse/pull/121332) ([Nikolay Degterinsky](https://github.com/evillique)).
* Fixed the server failing to start with `TABLE_ALREADY_EXISTS` or `Mapping for table with UUID=... already exists` after it was killed during `CREATE OR REPLACE TABLE`, `REPLACE TABLE`, or `CREATE TABLE ... AS SELECT` in an `Atomic` database whose metadata is on a `plain_rewritable` disk (`database_disk`). [#123902](https://github.com/ClickHouse/ClickHouse/pull/123902) ([Alexey Milovidov](https://github.com/alexey-milovidov)). [#123832](https://github.com/ClickHouse/ClickHouse/pull/123832) ([Groene AI](https://github.com/groeneai)).
* Fixed `EXISTS TABLE` returning `0` for a table that is still being loaded asynchronously after server startup. [#125729](https://github.com/ClickHouse/ClickHouse/pull/125729) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed `SELECT ... FINAL` returning a superseded row when the partition expression distinguishes floating-point values that the `FINAL` merge comparator treats as equal, such as `-0.0` versus `0.0` or different `NaN` payloads. `enable_automatic_decision_for_merging_across_partitions_for_final` no longer engages for such a key. [#117482](https://github.com/ClickHouse/ClickHouse/pull/117482) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Row policies over floating-point sorting key columns are now applied after `FINAL`, with `apply_row_policy_after_final` enabled, and such columns are excluded from index analysis of deferred filters. Previously a policy condition distinguishing `-0.0` from `0.0` or `NaN` payloads could filter out the winning row version before the merge and return stale data. [#121782](https://github.com/ClickHouse/ClickHouse/pull/121782) ([Yarik Briukhovetskyi](https://github.com/yariks5s)).
* `CREATE TABLE` and `ALTER TABLE ... ADD INDEX` now reject a skip index whose expression cannot be evaluated, such as `INDEX i c0 = c1 TYPE set(0)` over `String` and `Int8`, and an `ALTER TABLE ... MODIFY COLUMN` that would leave an existing index in that state is rejected too. Such a declaration used to be accepted, after which every `INSERT` and merge failed with `NO_COMMON_TYPE`, and `MATERIALIZE INDEX` retried that error forever. Closes [#69597](https://github.com/ClickHouse/ClickHouse/issues/69597). [#118373](https://github.com/ClickHouse/ClickHouse/pull/118373) ([Groene AI](https://github.com/groeneai)).
* Fixed `SELECT count()` returning more rows than the filter accepts when a `MergeTree` primary key is a `Tuple` holding a floating point element and the key data contains a `nan`. For example, with `ORDER BY t` over `t Tuple(Float64, Int32)`, `SELECT count() FROM t WHERE t >= (5., 3)` returned `6` while `SELECT * FROM t WHERE t >= (5., 3)` returned `2` rows. A `nan` nested in a tuple is not visible in the granule bounds, so primary key analysis reported a granule of non-matching rows as wholly matching and the exact-count optimization counted its rows without evaluating the filter. Closes [#117819](https://github.com/ClickHouse/ClickHouse/issues/117819). [#118683](https://github.com/ClickHouse/ClickHouse/pull/118683) ([Groene AI](https://github.com/groeneai)).
* Fixed `WHERE f IN (nan)` silently losing the `NaN` rows of a floating-point column: statistics-based part pruning and the `minmax` skip index use ranges that exclude `NaN`, so a part or granule holding `NaN` was pruned even though `IN` matches `NaN`. [#117453](https://github.com/ClickHouse/ClickHouse/pull/117453) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed wrong results when a `String` primary key column is compared against a `FixedString` constant wrapped in `Variant` or `Dynamic`. [#114353](https://github.com/ClickHouse/ClickHouse/pull/114353) ([Groene AI](https://github.com/groeneai)).
* Fixed wrong results for `f = 0.0` and `f != 0.0` over a float column when the primary key is an injective transform of it (for example `ORDER BY toString(f)`): the index treated the transformed constant as exact, although the transform distinguishes `-0.0` from `+0.0` while the comparison does not. [#117722](https://github.com/ClickHouse/ClickHouse/pull/117722) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Comparing an `Enum` column with a string literal that is not one of its elements no longer throws `UNKNOWN_ELEMENT_OF_ENUM` when `validate_enum_literals_in_operators` is disabled (the default) and the column is part of the primary key, the partition key, or a `bloom_filter` index. `!=` with such a literal now returns true for every row instead of throwing. Closes [#122235](https://github.com/ClickHouse/ClickHouse/issues/122235), [#111545](https://github.com/ClickHouse/ClickHouse/issues/111545). [#122672](https://github.com/ClickHouse/ClickHouse/pull/122672) ([Vladimir Cherkasov](https://github.com/vdimir)).
* Fixed an exception (such as `Division by zero`) thrown from index analysis when a monotonic function chain over a key column cannot be evaluated on a key range endpoint, for example `SELECT count() FROM t WHERE p != 1 AND intDiv(1, p - 1) > 0` with `use_skip_indexes = 0`. Also fixed a possible segmentation fault caused by a poisoned entry in the index analysis function result cache. [#117355](https://github.com/ClickHouse/ClickHouse/pull/117355) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fix a `bloom_filter` skip index on `mapValues` or `mapKeys` that dropped rows for `m['k'] IN (...)` when the map values are an `Enum` with negative values and the set contains the name of the value `0`. [#124232](https://github.com/ClickHouse/ClickHouse/pull/124232) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fix a wrong order (and wrong rows under `LIMIT`) from the read-in-order optimization when the `ORDER BY` expression maps a stored `inf` to `NaN`, as in `ORDER BY x / inf`. [#118720](https://github.com/ClickHouse/ClickHouse/pull/118720) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed primary key, partition key, and skip index analysis that could skip or over-count rows, and `ORDER BY` optimization that could return rows in the wrong order, for conditions on `timezoneOffset`, `toTimeWithFixedDate`, `toYYYYMMDDhhmmss`, `toHour`, and `toMinute` over a `DateTime` or `DateTime64` column when the key range spans a change of the UTC offset, for example a daylight saving time change in `America/New_York` or the 30-minute change in `Australia/Lord_Howe`. [#124474](https://github.com/ClickHouse/ClickHouse/pull/124474) ([Groene AI](https://github.com/groeneai)). [#124530](https://github.com/ClickHouse/ClickHouse/pull/124530) ([Groene AI](https://github.com/groeneai)).
* Fixed wrong results of `ORDER BY` with `optimize_read_in_order`, `GROUP BY` with `optimize_aggregation_in_order`, and `LIMIT BY` with the in-order optimizations when a `String` sorting-key column is compared with a `FixedString` constant, also one held by a `Variant` or `Dynamic` constant (for example `WHERE s = toFixedString('a', 2)` or `WHERE s = CAST(toFixedString('a', 2) AS Dynamic)`), or when a `Variant` or `Dynamic` expression, such as a JSON path, is compared with a constant (for example `WHERE j.a = 1` over `Int64` and `Float64` values). Such a comparison matches several values that sort differently, but the optimization treated them as one value and skipped sorting by them. [#123677](https://github.com/ClickHouse/ClickHouse/pull/123677) ([Ashish Kumar Choubey](https://github.com/aschoube)). [#125378](https://github.com/ClickHouse/ClickHouse/pull/125378) ([Samuel Krempaský](https://github.com/NIKTONIKTO717)).
* Fixed `count()` counting rows that the filter rejects when a whole-tuple comparison against a `Tuple` primary key involves a `NULL` or a `NaN` nested in the constant, or a `NaN` nested in the key data. [#118944](https://github.com/ClickHouse/ClickHouse/pull/118944) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed wrong result order (and wrong rows under `LIMIT`) from the read-in-order optimization when `ORDER BY` is a monotonically decreasing function of a `Float` sorting key containing `NaN`, e.g. `ORDER BY negate(x)`. The opposite request for the same shape, `ORDER BY negate(x) ASC NULLS FIRST`, is now read in order instead of being sorted. [#118469](https://github.com/ClickHouse/ClickHouse/pull/118469) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed repeated reading of text index posting lists in multi-threaded queries when the global text index caches are disabled. [#120844](https://github.com/ClickHouse/ClickHouse/pull/120844) ([Anton Popov](https://github.com/CurtizJ)).
* The `text`, `tokenbf_v1`, `ngrambf_v1`, and `sparse_grams` skip indexes are now used for `IN` when `transform_null_in = 1` and the set contains no `NULL`. Previously such a query read every granule, and one using `force_data_skipping_indices` failed with `INDEX_NOT_USED`. [#121375](https://github.com/ClickHouse/ClickHouse/pull/121375) ([Jimmy Aguilar Mena](https://github.com/Ergus)).
* Fixed wrong results and the exception `Column ... already added for reading` for a `FINAL` query with `query_plan_optimize_lazy_final = 1` that reads a `text` index directly, when the `ReplacingMergeTree` sorting key is `Nullable`, floating-point, or mixes `ASC` and `DESC` columns. [#122534](https://github.com/ClickHouse/ClickHouse/pull/122534) ([Groene AI](https://github.com/groeneai)).
* On a column whose `text` index has a postprocessor, `hasPhrase` rejoined the index tokens with a space before matching, so it returned wrong results unless that space matched how the tokenizer splits. Allowing `hasPhrase` to accept an `Array(String)` removes joining tokens completely. [#120859](https://github.com/ClickHouse/ClickHouse/pull/120859) ([Elmi Ahmadov](https://github.com/ahmadov)).
* Fixed a `text` index with `tokenizer = 'japanese'` returning fewer rows than a full scan: over a `LowCardinality` column every second row of a run of equal values was not indexed, and two search terms of the same byte length in one query (for example `hasAnyTokens(s, 'エンジン', 'japanese') AND hasAnyTokens(s, '形態解析', 'japanese')`) matched no rows. Indexes built before this fix keep the missing rows until `ALTER TABLE ... MATERIALIZE INDEX` is run. [#123389](https://github.com/ClickHouse/ClickHouse/pull/123389) ([Groene AI](https://github.com/groeneai)).
* Fixed a query failing with an exception like `Cannot parse UInt64 from String` on a table with a text index on `mapKeys` or `JSONAllPaths`, when the predicate cannot be evaluated on the value of a missing map key or JSON path. [#124612](https://github.com/ClickHouse/ClickHouse/pull/124612) ([Anton Popov](https://github.com/CurtizJ)).
* Fixed `count()` with a text index search function such as `hasToken`, `hasAnyTokens`, or `hasAllTokens` in `WHERE` and a constant `GROUP BY` key returning a row with `0` instead of no rows when nothing matches. [#124593](https://github.com/ClickHouse/ClickHouse/pull/124593) ([Groene AI](https://github.com/groeneai)).
* Fix `hasAnyTokens` with a `String` needle on a text index with the `sparseGrams` tokenizer returning fewer rows than the equivalent `Array` needle. Grams covered by a longer gram of the needle were dropped, which is only valid for `hasAllTokens`. [#124613](https://github.com/ClickHouse/ClickHouse/pull/124613) ([Jimmy Aguilar Mena](https://github.com/Ergus)).
* Fixed slow planning of queries with a text index on tables with many parts when other skip indices are stored in the packed `skp_idx.packed` archive. Checking for an absent optional text-index file no longer calls `stat` on disk for every part. [#125381](https://github.com/ClickHouse/ClickHouse/pull/125381) ([Anton Popov](https://github.com/CurtizJ)).
* Fix `ALTER TABLE ... MATERIALIZE STATISTICS` / `DROP STATISTICS` failing forever and wedging the table's mutation queue when a server profile sets `allow_statistics = 0` and the statement enables it per-session, the same opt-in `ADD STATISTICS` honours. Also close a hole where `MATERIALIZE STATISTICS` ignored `allow_statistics = 0` altogether under `validate_mutation_query = 0`. [#117351](https://github.com/ClickHouse/ClickHouse/pull/117351) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed a mutation silently dropping one of two swapped columns' statistics when the part carried a composed `RENAME COLUMN` pair that exchanged their names. [#118977](https://github.com/ClickHouse/ClickHouse/pull/118977) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* When the query cache is unable to store results (with `enable_writes_to_query_cache = 0`, in `clickhouse-local`, or with a zero limit in the `query_cache` server configuration), queries with `use_query_cache = 1` no longer fail with `QUERY_CACHE_USED_WITH_NONDETERMINISTIC_FUNCTIONS`, `QUERY_CACHE_USED_WITH_SYSTEM_TABLE` or `QUERY_CACHE_USED_WITH_NON_THROW_OVERFLOW_MODE`: these checks protect against caching wrong results, which cannot happen then. When a `query_cache` limit is reconfigured to 0, the existing entries are now dropped instead of lingering. [#123604](https://github.com/ClickHouse/ClickHouse/pull/123604) ([Konstantin Bogdanov](https://github.com/thevar1able)).
* `LIMIT [n] AFTER start_expr UNTIL end_expr` now checks `end_expr` only after `start_expr` first matches. Previously a match of `end_expr` anywhere before the first `start_expr` incorrectly made the result empty. [#120514](https://github.com/ClickHouse/ClickHouse/pull/120514) ([Nihal Z. Miaji](https://github.com/nihalzp)).
* Fixed `SELECT DISTINCT` and `LIMIT BY` over a floating point column returning a different number of rows depending on whether the in-order variant of the operator was used: `-0.0` and `0.0`, and distinct `NaN` payloads, are no longer merged by the in-order variant. [#118198](https://github.com/ClickHouse/ClickHouse/pull/118198) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed a higher-order function with a non-deterministic lambda body, such as `arrayMap(i -> rand64(i), ...)`, being evaluated once per source row instead of once per output row after `ARRAY JOIN` when lazy columns replication is enabled. [#120796](https://github.com/ClickHouse/ClickHouse/pull/120796) ([Yarik Briukhovetskyi](https://github.com/yariks5s)).
* Fixed a performance regression where a query whose `WHERE` requires the same expression to equal two different constants stopped being recognized as always false when `compatibility` was set below `26.7`, or when `optimize_redundant_comparisons` was disabled explicitly. Closes [#121007](https://github.com/ClickHouse/ClickHouse/issues/121007). Closes [#121012](https://github.com/ClickHouse/ClickHouse/issues/121012). [#121065](https://github.com/ClickHouse/ClickHouse/pull/121065) ([Groene AI](https://github.com/groeneai)).
* Fixed `NOT_AN_AGGREGATE` being thrown for a `GROUP BY` key referenced from a window function when `group_by_use_nulls` is enabled together with `ROLLUP`, `CUBE`, or `GROUPING SETS`, as in `SELECT rank() OVER (PARTITION BY k) FROM t GROUP BY k WITH ROLLUP`. [#118173](https://github.com/ClickHouse/ClickHouse/pull/118173) ([Groene AI](https://github.com/groeneai)).
* Fixed `AMBIGUOUS_IDENTIFIER` for a column qualified with the alias of a table expression when another table of the same query is named like that alias. Such a qualifier now refers to the alias, as it does in the old analyzer, both in a join that reported the ambiguity and in a two-table join that resolved it to the other side. [#119082](https://github.com/ClickHouse/ClickHouse/pull/119082) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed `NOT_FOUND_COLUMN_IN_BLOCK` when a query tree pass rewrites a window function's aggregate in place. A query whose only reference to a `Nullable` column was a windowed `count`, such as `SELECT count(n) OVER () FROM t`, was rejected at default settings because `optimize_functions_to_subcolumns` rewrote it into `sum(not(n.null))` and lost the node's window kind. `optimize_uniq_to_count` corrupted `uniq(n) OVER ()` over a `SELECT DISTINCT` subquery the same way. Closes [#119635](https://github.com/ClickHouse/ClickHouse/issues/119635). [#119681](https://github.com/ClickHouse/ClickHouse/pull/119681) ([Groene AI](https://github.com/groeneai)).
* Fix a wrong result from `optimize_injective_functions_in_group_by` on the two-argument form `toString(x, timezone)`. `GROUP BY toString(number, NULL)` could be rewritten to `GROUP BY number` and produce one group per row instead of one. [#117197](https://github.com/ClickHouse/ClickHouse/pull/117197) ([Ilya Yatsishin](https://github.com/qoega)).
* Fixed a server crash in `CREATE TABLE ... AS
` when an argument of the table function is a scalar subquery with a `JOIN` and `enable_join_runtime_filters_index_analysis` is enabled in the default settings profile. [#122795](https://github.com/ClickHouse/ClickHouse/pull/122795) ([Groene AI](https://github.com/groeneai)).
* Fixed table names not being qualified with the database when a `WITH` name declared elsewhere in the same query happened to match them: a view whose `UNION` branch referenced a table with the name of a `WITH RECURSIVE` CTE of another branch could not be read from another database, and `ALTER TABLE ... UPDATE` with a common table expression referenced from a subquery failed with `UNKNOWN_DATABASE` or read a table of the session database. [#114908](https://github.com/ClickHouse/ClickHouse/pull/114908) ([Groene AI](https://github.com/groeneai)).
* Fixed `IN` against a table-backed set (`ENGINE = Set`), or with `transform_null_in = 1`, throwing `CANNOT_CONVERT_TYPE` for probe values outside the set key type's range instead of evaluating them to false, which also made the query succeed or fail depending on how much the plan pruned. [#117606](https://github.com/ClickHouse/ClickHouse/pull/117606) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed a crash and wrong results with `convert_query_to_cnf = 1` when `WHERE` or `HAVING` references the same `SELECT` alias more than once. [#123414](https://github.com/ClickHouse/ClickHouse/pull/123414) ([Groene AI](https://github.com/groeneai)).
* Fixed wrong results, `Unexpected return type from tupleElement` errors and `NOT_FOUND_COLUMN_IN_BLOCK` errors when a `Nested` column is read through `ARRAY JOIN` with a numeric `tupleElement` index (for example `tupleElement(n, 3)`) while another subcolumn is unused, and the same expression is reused by `ORDER BY ALL`, `GROUP BY ALL` or an alias. [#123647](https://github.com/ClickHouse/ClickHouse/pull/123647) ([Groene AI](https://github.com/groeneai)).
* Fix `UNKNOWN_IDENTIFIER` in the analyzer when a table is referenced as `database.table` in `FROM` or `JOIN` and another table expression in the same query uses that database name as its alias, for example `FROM db.t1 AS db INNER JOIN db.t2 AS t ON ...`. Closes [#122239](https://github.com/ClickHouse/ClickHouse/issues/122239). [#124262](https://github.com/ClickHouse/ClickHouse/pull/124262) ([Dmitry Novik](https://github.com/novikd)).
* Fix a wrong result, a leaked totals row, and a `LOGICAL_ERROR` exception with `rewrite_in_to_join` when the subquery of `IN` uses `WITH TOTALS`. [#124096](https://github.com/ClickHouse/ClickHouse/pull/124096) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fix `Unexpected return type from __topKFilter` logical error raised by `ORDER BY ... LIMIT` over a `MergeTree` table with more than one part when the sort column contains a `Nullable` element, for example `Tuple(UInt64, Nullable(UInt64))`. `use_top_k_dynamic_filtering` is enabled by default, so no opt-in setting was required to hit this. [#113406](https://github.com/ClickHouse/ClickHouse/pull/113406) ([Groene AI](https://github.com/groeneai)).
* Reject a duplicate column alias name in a CTE or table expression, which previously could return an incorrect result instead of failing. Closes [#114427](https://github.com/ClickHouse/ClickHouse/issues/114427). [#114505](https://github.com/ClickHouse/ClickHouse/pull/114505) ([Yarik Briukhovetskyi](https://github.com/yariks5s)).
* Fixed `APPLY lambda(tuple(x), ...)` followed by an operator, as in `SELECT * APPLY lambda(tuple(x), toString(x)) > '0'`, which failed with `UNKNOWN_IDENTIFIER`. A view using `APPLY (lambda(...))` followed by an operator also stopped working after a server restart. [#124142](https://github.com/ClickHouse/ClickHouse/pull/124142) ([Groene AI](https://github.com/groeneai)).
* Fix a logical error `Equal values are not contiguous within the range assumed to be sorted` (and potential wrong `DISTINCT` results) when `optimize_distinct_in_order` is enabled and an `ORDER BY` over an `arrayJoin`-derived column is followed by another `ARRAY JOIN` that reproduces a column of the same name. [#110778](https://github.com/ClickHouse/ClickHouse/pull/110778) ([Groene AI](https://github.com/groeneai)).
* Fixed wrong results and a `LOGICAL_ERROR` (`Cannot capture column ... because it has incompatible type`) when a matcher such as `b.*`, `*`, `COLUMNS('...')`, or `b.* EXCEPT c` appears inside a lambda body. A matcher expanded inside a lambda kept its pre-`JOIN` column types, so `join_use_nulls = 1` did not turn columns from the `NULL` side of a `LEFT`/`FULL`/`RIGHT JOIN` into `Nullable` (unmatched rows produced a value computed over defaults instead of `NULL`), and `group_by_use_nulls = 1` with `WITH ROLLUP` / `WITH CUBE` / `GROUP BY GROUPING SETS` failed with `NOT_AN_AGGREGATE`. A matcher expanded inside a lambda now carries the same types it would have if the columns were written out explicitly, and a lambda inside `PREWHERE` is no longer promoted to `Nullable` by `join_use_nulls`. Also fixed wrong results for a matcher inside a lambda when `analyzer_compatibility_join_using_top_level_identifier = 1` makes a `JOIN ... USING` key resolve to a `SELECT` projection alias: the matcher selected the merged `USING` key instead of the right table's column. [#111993](https://github.com/ClickHouse/ClickHouse/pull/111993) ([Groene AI](https://github.com/groeneai)).
* Fixed wrong results and `NOT_FOUND_COLUMN_IN_BLOCK` for three-argument `multiIf` and `if`-chain `GROUP BY` keys with `ROLLUP`, `CUBE`, or `GROUPING SETS` and `group_by_use_nulls = 1`. Also fixed constant-condition keys reused through aliases with `enable_identifier_resolve_cache`, lost grouping sets when a key collapses to another key, and a `Bad cast` exception for a correlated subquery reading that column. Closes [#122404](https://github.com/ClickHouse/ClickHouse/issues/122404). Part of [#103419](https://github.com/ClickHouse/ClickHouse/issues/103419). [#123065](https://github.com/ClickHouse/ClickHouse/pull/123065) ([Groene AI](https://github.com/groeneai)). [#122512](https://github.com/ClickHouse/ClickHouse/pull/122512) ([Groene AI](https://github.com/groeneai)).
* Fixed wrong results of `ORDER BY`, `LIMIT BY`, and `GROUP BY` with `optimize_aggregation_in_order` over a function of the sorting key with a `NULL` constant argument, such as `toString(dt, NULL)` or `toString(dt, {tz:Nullable(String)})` with a `NULL` parameter. Such a function returns `NULL` for every row, but reading in order treated it as strictly monotonic and kept the next sorting key column in table order. [#125042](https://github.com/ClickHouse/ClickHouse/pull/125042) ([Groene AI](https://github.com/groeneai)).
* Fixed a server crash, wrong results, or a rejected query in `ORDER BY ... WITH FILL ... INTERPOLATE` when one `INTERPOLATE` expression has to be converted to its target type and another item reads the same column or literal, for example `INTERPOLATE (a AS b, b AS a)` with targets of different types. [#125129](https://github.com/ClickHouse/ClickHouse/pull/125129) ([Groene AI](https://github.com/groeneai)).
* A `WITH` list whose elements refer to the preceding ones, or a chain of common table expressions that read the previous one more than once, now fails with `TOO_BIG_AST` past `max_expanded_ast_elements` instead of exhausting the server's memory in `EXPLAIN AST optimize = 1`, `CREATE VIEW`, a full `ATTACH VIEW ... AS SELECT` and `ALTER TABLE ... MODIFY QUERY`. [#122362](https://github.com/ClickHouse/ClickHouse/pull/122362) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fix excessive memory usage for queries with `ARRAY JOIN` and filters on both rows and array elements: the row filter is now applied before expanding the array. [#125577](https://github.com/ClickHouse/ClickHouse/pull/125577) ([Konstantin Vedernikov](https://github.com/scanhex12)).
* Fixed `ORDER BY ... LIMIT` over a column of an `Interval` type (or `Nullable`, `LowCardinality`, `Tuple` or `Array` of one) failing with `TYPE_MISMATCH` when `use_top_k_dynamic_filtering` is enabled, which is the default. Closes [#125197](https://github.com/ClickHouse/ClickHouse/issues/125197). [#125221](https://github.com/ClickHouse/ClickHouse/pull/125221) ([Groene AI](https://github.com/groeneai)).
* Fixed a heap-use-after-free when a correlated subquery reading a `Merge` table was planned inside `EXPLAIN`, a subquery in `FROM`, a view, or an `IN` subquery. [#122475](https://github.com/ClickHouse/ClickHouse/pull/122475) ([Groene AI](https://github.com/groeneai)).
* Fix a correlated scalar subquery used as the whole `WHERE`, `HAVING`, or `QUALIFY` condition, e.g. `WHERE (SELECT count() > 0 FROM t AS i WHERE i.k = o.k)`, being rejected with `ILLEGAL_AGGREGATION` or `NOT_AN_AGGREGATE`, or failing with `NOT_IMPLEMENTED` (`NOT_FOUND_COLUMN_IN_BLOCK` on older versions) when the outer column it uses is not read elsewhere in the query. Closes [#124499](https://github.com/ClickHouse/ClickHouse/issues/124499). [#124594](https://github.com/ClickHouse/ClickHouse/pull/124594) ([Groene AI](https://github.com/groeneai)).
* Fixed `NOT_IMPLEMENTED` (`None of the algorithms enabled by the 'join_algorithm' setting ... can execute this SEMI/ANTI JOIN`) for a correlated `EXISTS`/`NOT EXISTS` subquery, for an `IN (subquery)` under `rewrite_in_to_join`, or for an `ANY LEFT JOIN` of an `ENGINE = Join` table under an always-false `WHERE`, when `join_algorithm` is set to `full_sorting_merge` or `partial_merge`. [#118315](https://github.com/ClickHouse/ClickHouse/pull/118315) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Comparing two deeply nested `Array`, `Tuple`, `Map`, or `Object` values doubled the work for every nesting level, because the ordering asked each equal element both whether it was less and whether it was greater. A single-value aggregate such as `min`, `max`, `argMin`, `groupArraySorted`, or an `-ArgMin` combinator over a 30-level nested argument therefore ran for minutes on a few hundred rows, and could not be interrupted by `max_execution_time`. Such a comparison now visits each element once. [#116455](https://github.com/ClickHouse/ClickHouse/pull/116455) ([Groene AI](https://github.com/groeneai)).
* Fixed a server double free when finalizing an aggregate function with the `-State` combinator nested under a combinator that transfers several substates in one call, such as `-Resample`, `-ForEach`, `-Map`, or `-Tuple`, if an exception is thrown part-way through the transfer. [#111287](https://github.com/ClickHouse/ClickHouse/pull/111287) ([Groene AI](https://github.com/groeneai)).
* Fixed wrong results from `quantileExactWeightedInterpolated`, `quantileInterpolatedWeighted`, and their `quantiles*` forms over integer-backed types. [#114571](https://github.com/ClickHouse/ClickHouse/pull/114571) ([Groene AI](https://github.com/groeneai)).
* Fixed `topK`, `topKWeighted`, `approx_top_k`, `approx_top_count`, `approx_top_sum`, `uniqUpTo`, `uniqCombined`, `uniqCombined64`, `exponentialMovingAverage`, `stochasticLinearRegression`, `stochasticLogisticRegression`, and `groupNumericIndexedVector` state columns with a `Decimal` or wide-integer parameter. The parameter was persisted as a quoted string that reparsed as `String`, so after a restart the table was unreadable, uninsertable, and undroppable. [#121491](https://github.com/ClickHouse/ClickHouse/pull/121491) ([Groene AI](https://github.com/groeneai)).
* Fixed a server abort when the `flameGraph` aggregate function was constructed on a thread without a query context, for example while attaching a stored table whose column type names `AggregateFunction(flameGraph, ...)`. [#121894](https://github.com/ClickHouse/ClickHouse/pull/121894) ([Groene AI](https://github.com/groeneai)).
* Fixed `runningAccumulate` returning an accumulation computed over only part of the rows when it reads a state column under `if`, `multiIf`, `and`, or `or` at the default `short_circuit_function_evaluation = 'enable'`. Inside a boolean predicate this also changed which rows passed the filter. An argument computed inline by another lazily evaluated function, whether it is the state or the grouping key, is still filtered. Closes [#117121](https://github.com/ClickHouse/ClickHouse/issues/117121). [#117126](https://github.com/ClickHouse/ClickHouse/pull/117126) ([Groene AI](https://github.com/groeneai)).
* Fixed `arrayIntersect` returning a `NULL` that is present only in its first argument, which made the result depend on the order of the arguments. `NULL` is now in the result only when every argument array contains one. [#118433](https://github.com/ClickHouse/ClickHouse/pull/118433) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* `arrayUniq`, `arrayEnumerateUniq`, `arrayEnumerateDense`, and `arrayJaccardIndex` now distinguish `NULL` from the nested type's default value for nullable arrays that use generic hashing. [#120676](https://github.com/ClickHouse/ClickHouse/pull/120676) ([xiaohuanlin](https://github.com/xiaohuanlin)).
* Fixed an out-of-bounds heap write in `stem`. The output buffer now grows when the stemmed word is longer than the estimate from the input. [#121402](https://github.com/ClickHouse/ClickHouse/pull/121402) ([Jimmy Aguilar Mena](https://github.com/Ergus)).
* Fix array and map search functions returning a match for a `NULL` `String` needle when an empty string is present. [#118741](https://github.com/ClickHouse/ClickHouse/pull/118741) ([Minh Vu](https://github.com/fallintoplace)).
* Fixed `least` and `greatest` returning wrapped-around values for a `LowCardinality` numeric argument of mixed signedness, `intDiv`/`%`/`positiveModulo` throwing `Division by zero` on NULL rows of a `LowCardinality(Nullable(...))` denominator, and `fromModifiedJulianDay`, `runningConcurrency`, `hasPhrase`, `formatRow`, `now`, and `CAST` rejecting valid `LowCardinality` arguments. [#117450](https://github.com/ClickHouse/ClickHouse/pull/117450) ([Alexey Milovidov](https://github.com/alexey-milovidov)). [#122418](https://github.com/ClickHouse/ClickHouse/pull/122418) ([Groene AI](https://github.com/groeneai)).
* Fix `has`, `notHas`, `indexOf`, `countEqual`, and `mapContains` silently finding nothing in a constant array or map with `Enum` keys searched for the name of an enum value, e.g. `mapContains(map('a', 1)::Map(Enum8('a' = 1), UInt8), 'a')` returned `0`. They now compare by the name of the enum value, consistently with `equals` and with the same functions over a non-constant argument. Also fix indexing a `Map` with `Enum` keys by a numeric value that is not in the `Enum` throwing `UNKNOWN_ELEMENT_OF_ENUM` during query analysis instead of returning the default value, and an exception in the analysis of a `bloom_filter` index over `mapKeys` of a `Map` with `Enum` keys. Also fix a `bloom_filter` index over an `Array(String)` or `Array(FixedString)` column wrongly pruning the granules that match `hasAny` or `hasAll` with a constant `Array(Enum)` argument. [#116093](https://github.com/ClickHouse/ClickHouse/pull/116093) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed comparison of tuples with an untyped `NULL` element, such as `(1, 2) != (3, NULL)` or `(1, 2) != toNullable((3, NULL))`: the result was `NULL` (or `0` for a `Nullable` tuple) even when another element decides it. It is now the same as with a typed `NULL`: `0` or `1` when another element decides the comparison, `NULL` otherwise. A filter and its negation no longer both drop a row, e.g. with `WHERE NOT (_partition_value > toNullable((..., NULL)))`. [#123896](https://github.com/ClickHouse/ClickHouse/pull/123896) ([Groene AI](https://github.com/groeneai)).
* Fixed `pointInPolygon` with a constant polygon returning wrong results for some points of ordinary polygons, for example `0` for the point `(0.76, 0.01)` inside the polygon `[(1, 0), (0, 1), (-1, 0), (0, -1)]`, or `1` for a point inside a small hole. The results now match those for a non-constant polygon. [#123767](https://github.com/ClickHouse/ClickHouse/pull/123767) ([Groene AI](https://github.com/groeneai)).
* Arithmetic between a `Decimal` and an integer that does not fit the native width of the decimal result now raises `DECIMAL_OVERFLOW` instead of silently wrapping the integer operand. [#118721](https://github.com/ClickHouse/ClickHouse/pull/118721) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed wrong results of `pointInPolygon` for polygons with huge coordinates. With a constant array polygon, a filter on a table whose primary key covers the point columns could also return fewer rows than a full scan. `pointInPolygon` now throws `BAD_ARGUMENTS` where it would compute with a polygon coordinate larger than `1e150` in absolute value. [#123740](https://github.com/ClickHouse/ClickHouse/pull/123740) ([Groene AI](https://github.com/groeneai)).
* Fixed `date_time_overflow_behavior` being ignored while parsing `Date` and `DateTime`. Closes [#113151](https://github.com/ClickHouse/ClickHouse/issues/113151). [#116099](https://github.com/ClickHouse/ClickHouse/pull/116099) ([Yarik Briukhovetskyi](https://github.com/yariks5s)).
* `toStartOfInterval` no longer widens `Date` and `DateTime` inputs to `Date32` and `DateTime64` when `enable_extended_results_for_datetime_functions = 1`; only `Date32` and `DateTime64` inputs keep the extended result types, matching the `toStartOfX` functions. This also removes the saturated result (`2106-02-07 06:28:15`) that `toStartOfInterval(, INTERVAL ... DAY)` returned under that setting for dates after `2106-02-07`. [#119806](https://github.com/ClickHouse/ClickHouse/pull/119806) ([Groene AI](https://github.com/groeneai)). [#121809](https://github.com/ClickHouse/ClickHouse/pull/121809) ([Kirill Kopnev](https://github.com/Fgrtue)).
* Fixed `age('week', ...)` sometimes being off by one week when the dates fall on different weekdays. [#122633](https://github.com/ClickHouse/ClickHouse/pull/122633) ([Samuel Krempaský](https://github.com/NIKTONIKTO717)).
* Fixed wrong results when an `Enum8` or `Enum16` value is converted to `DateTime` or `Date`. A negative member wrapped instead of saturating like the `Int8` or `Int16` it is stored as, so `toDateTime` of an enum returned a far-future timestamp and primary-key analysis discarded granules that did contain matching rows. [#118039](https://github.com/ClickHouse/ClickHouse/pull/118039) ([Groene AI](https://github.com/groeneai)).
* Fixed `toDateTime64`, `toDateTime` with a scale and `toTime64` throwing `CANNOT_PARSE_DATETIME` for a `Nullable(String)` or `Nullable(FixedString)` argument that contains `NULL`; such rows now return `NULL`. For `toDateTime64` this was a regression in 26.5, where `cast_string_to_date_time_mode` became `best_effort` by default. [#123311](https://github.com/ClickHouse/ClickHouse/pull/123311) ([Groene AI](https://github.com/groeneai)).
* Fixed `dateDiff` and `age` with unit `day` returning a result off by 65536 (for example `-65535` instead of `1`) when an argument is a `DateTime` on the local day 1969-12-31 in a time zone west of UTC, such as `toDateTime(0)` in `America/New_York`. If a table stores such a value in a sorting key, partition key, skip index, projection or `MATERIALIZED`/`DEFAULT` column, rebuild it. [#124555](https://github.com/ClickHouse/ClickHouse/pull/124555) ([Groene AI](https://github.com/groeneai)).
* Setting `date_time_overflow_behavior` is now honored by `CAST` and the conversion functions for numeric conversions to `Date`, `Date32`, `DateTime`, `Time`, `DateTime64`, and `Time64`. For `DateTime64` and `Time64`, the same now applies to the `INSERT ... VALUES` expression fallback and the `values` table function, and for `DateTime64` sort keys to numeric `WITH FILL` bounds. Previously an out-of-range value was silently clamped even in the `throw` mode. `accurateCast`, `accurateCastOrNull`, and `accurateCastOrDefault` no longer clamp an unrepresentable value into `DateTime64` or `Time64`, and saturation now reaches the extreme representable tick of the target rather than the last whole second. [#117667](https://github.com/ClickHouse/ClickHouse/pull/117667) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed a constant of `Variant` type reached through an `Array`, `Tuple`, or `Map` being mis-serialized to a secondary server, so a query that returned a result on a single node failed with `CANNOT_CONVERT_TYPE` through parallel replicas, `remote`, or `Distributed`. A `String` member of a multi-member `Variant` constant, scalar or nested, arrived there as whichever member its text parsed as, and an empty `Map` whose key or value is a `Variant` was rejected outright. [#117831](https://github.com/ClickHouse/ClickHouse/pull/117831) ([Groene AI](https://github.com/groeneai)).
* Fixed `LOGICAL_ERROR` when reading a `sizeN` subcolumn of a shared-data `JSON` path, for example a `size1` subcolumn over data of type `Array(Array(Nullable(Int64)))`. It affected parts written with the `advanced` shared data serialization version, which is the default for merged parts. [#120039](https://github.com/ClickHouse/ClickHouse/pull/120039) ([Pavel Kruglov](https://github.com/Avogar)).
* Fixed wrong results when reading the `null` subcolumn of a `Nullable` field of a `Variant`, `Dynamic`, or `JSON` element, for example ``value.`Tuple(a Nullable(UInt32), b String)`.a.null``. On rows holding a different alternative the subcolumn returned `0` although the field itself was `NULL`, so `optimize_functions_to_subcolumns` (enabled by default) rewriting `IS NULL` to that subcolumn silently dropped matching rows. Closes [#119935](https://github.com/ClickHouse/ClickHouse/issues/119935). [#120099](https://github.com/ClickHouse/ClickHouse/pull/120099) ([Groene AI](https://github.com/groeneai)).
* Fix `JSONHas` and `JSONExtractRaw` returning an absent result for a typed `JSON` path whose literal value is `NULL` but which contains a non-empty sub-object when `type_json_skip_null_typed_paths` is enabled. [#120321](https://github.com/ClickHouse/ClickHouse/pull/120321) ([JasonLi-cn](https://github.com/JasonLi-cn)).
* Fixed `max_memory_usage` and `max_server_memory_usage` not being respected when reading a `JSON` column with the `FLATTENED` serialization version from the `Native` format. [#117730](https://github.com/ClickHouse/ClickHouse/pull/117730) ([Pavel Kruglov](https://github.com/Avogar)).
* Fixed reading flattened `Nested` members next to a `JSON` member in `Wide` parts. [#122519](https://github.com/ClickHouse/ClickHouse/pull/122519) ([Mohammed Sohail](https://github.com/msohail22)).
* Allow the `JSON` type and the `JSON*` functions to parse documents whose `String` values hold bytes that are not valid UTF-8, which previously failed with `INCORRECT_DATA`. As a side effect, `isValidJSON` and the `JSONExtract*` family now accept such documents instead of reporting them invalid. [#119122](https://github.com/ClickHouse/ClickHouse/pull/119122) ([Groene AI](https://github.com/groeneai)).
* Fix stack exhaustion when reading a deeply nested `Dynamic` or `JSON` value as a `Field` or printing it in a text format. Both paths now raise `TOO_DEEP_RECURSION` instead of terminating the server. [#121441](https://github.com/ClickHouse/ClickHouse/pull/121441) ([Groene AI](https://github.com/groeneai)).
* Fix reading bucketed runtime `Map` values from `JSON` columns using `advanced` shared-data serialization. [#118577](https://github.com/ClickHouse/ClickHouse/pull/118577) ([Rory Shanks](https://github.com/rorylshanks)).
* Fixed a `Dynamic` constant losing the type of its value when a query is sent to other servers (`Distributed`, `remote`, parallel replicas): a constant holding `Enum8('7' = 3)` arrived as the number `3`, so `IN` and `NOT IN` matched the wrong rows and `=` failed with `NO_COMMON_TYPE`, and a `UInt64`, `IPv4`, or `Map` value arrived as a different type. Closes [#119745](https://github.com/ClickHouse/ClickHouse/issues/119745). [#118988](https://github.com/ClickHouse/ClickHouse/pull/118988) ([Groene AI](https://github.com/groeneai)).
* Fixed a crash on a query with a deeply nested `Dynamic` or `JSON` constant. [#120885](https://github.com/ClickHouse/ClickHouse/pull/120885) ([Pavel Kruglov](https://github.com/Avogar)).
* Fix inconsistent results and missing type errors when `optimize_functions_to_subcolumns` rewrites a `JSON` path accessed with `tupleElement` or `arrayElement` using an unsupported key type. Such expressions now behave the same with and without the optimization. [#125471](https://github.com/ClickHouse/ClickHouse/pull/125471) ([Groene AI](https://github.com/groeneai)).
* Fixed `TYPE_MISMATCH` when a `LowCardinality` join key is also selected from the NULL-extended side of a `LEFT`, `FULL`, or `ASOF LEFT` join with `join_use_nulls = 1` and `join_algorithm = 'full_sorting_merge'` or `'parallel_full_sorting_merge'`. Closes [#120424](https://github.com/ClickHouse/ClickHouse/issues/120424). [#120469](https://github.com/ClickHouse/ClickHouse/pull/120469) ([Groene AI](https://github.com/groeneai)).
* Fixed `ILLEGAL_PREWHERE` on sharded `GLOBAL RIGHT JOIN` queries that used `PREWHERE` on the left table. The filter is applied to the broadcast side before the join instead of being sent to a `Memory` temporary table that does not support `PREWHERE`. `PREWHERE` on a remote table in a join is also preserved when that table is read through a subquery wrap. [#119780](https://github.com/ClickHouse/ClickHouse/pull/119780) ([Anton Ivashkin](https://github.com/ianton-ru)).
* Fixed a `Pipeline stuck` exception when a query combined a merge join using `join_algorithm = 'parallel_full_sorting_merge'` with a step that glues independent streams together, such as reading from a `Merge` table, or a `UNION ALL` narrowed by `max_streams_for_union_step`. Such a query now runs instead of failing. [#121227](https://github.com/ClickHouse/ClickHouse/pull/121227) ([Groene AI](https://github.com/groeneai)).
* Fixed a query failing with an error such as `CANNOT_READ_ARRAY_FROM_TEXT` when a subquery's `SELECT` list computes an expression that the same subquery's `WHERE` guards against, and that subquery is the probe side of a `JOIN` for which a runtime join filter is built (`enable_join_runtime_filters = 1`, enabled by default). The guarded expression was evaluated on rows that the `WHERE` had already removed. [#122143](https://github.com/ClickHouse/ClickHouse/pull/122143) ([Groene AI](https://github.com/groeneai)).
* Fixed lost matches on a `Dynamic` join key when outer joins are reordered with a join order conflict detector enabled (`query_plan_optimize_join_order_conflict_detector`) and `join_use_nulls = 1`. [#123113](https://github.com/ClickHouse/ClickHouse/pull/123113) ([Fisnik Kastrati](https://github.com/fkastrati)).
* Fix `NOT_IMPLEMENTED` error for a `LEFT JOIN` over a dictionary or other key-value storage under `join_algorithm = 'direct'`. [#123491](https://github.com/ClickHouse/ClickHouse/pull/123491) ([Hechem Selmi](https://github.com/m-selmi)).
* Fix exponential planning time in the transitive outer-to-inner JOIN conversion when the expression DAG has shared nodes, such as a column used twice (x + x) across nested subqueries. The analysis now visits each node once instead of every path. [#123509](https://github.com/ClickHouse/ClickHouse/pull/123509) ([Hechem Selmi](https://github.com/m-selmi)).
* Fix a performance regression where the join runtime filter was skipped for joins that combine an `=` key with a null-safe `<=>` (`IS NOT DISTINCT FROM`) key once hash table statistics were collected. [#122618](https://github.com/ClickHouse/ClickHouse/pull/122618) ([Manuel](https://github.com/raimannma)).
* Fixed `indexHint` over the non-preserved side of an OUTER join silently returning extra rows, and `join_algorithm = 'direct'` failing with `NOT_IMPLEMENTED` when a column-free conjunct such as `materialize(1)` is added to the `WHERE` clause. [#117569](https://github.com/ClickHouse/ClickHouse/pull/117569) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fix `NOT_IMPLEMENTED` for an outer `JOIN` with `join_algorithm = 'full_sorting_merge'` when `optimize_and_compare_chain` derived a condition on the preserved side of the join from the `ON` clause. [#124233](https://github.com/ClickHouse/ClickHouse/pull/124233) ([Yarik Briukhovetskyi](https://github.com/yariks5s)).
* Fix `UNKNOWN_IDENTIFIER` errors in `INSERT ... SELECT` from a parameterized view when `parallel_distributed_insert_select` is enabled. The view is now analyzed with the analyzer instead of the legacy interpreter. [#119495](https://github.com/ClickHouse/ClickHouse/pull/119495) ([Yarik Briukhovetskyi](https://github.com/yariks5s)).
* Fixed a query over a `Distributed` table (or `cluster`/`remote`/`clusterAllReplicas` with an inner `view`) spanning more than one shard that references no column of the table anywhere in the query, such as `SELECT count(*) OVER () FROM distributed_table`. Such a query silently returned no rows, and returned `LOGICAL_ERROR` `Invalid number of columns in chunk pushed to OutputPort` when the table produced a constant. The fix covers the analyzer; `enable_analyzer = 0` is fixed separately by [#113955](https://github.com/ClickHouse/ClickHouse/issues/113955). [#113469](https://github.com/ClickHouse/ClickHouse/pull/113469) ([Groene AI](https://github.com/groeneai)).
* Fixed a server crash when a scalar or `IN` subquery inside a standalone expression, such as a `CHECK` constraint, a `TTL` expression, or a row policy, reads a `Distributed` table or the `remote` table function. [#121418](https://github.com/ClickHouse/ClickHouse/pull/121418) ([Groene AI](https://github.com/groeneai)). [#121639](https://github.com/ClickHouse/ClickHouse/pull/121639) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fix `NOT_FOUND_COLUMN_IN_BLOCK` for `grouping` over a `Distributed` table with `optimize_skip_unused_shards = 1`: a constant that a query tree pass builds is now named on a shard exactly as the initiator names it. [#119273](https://github.com/ClickHouse/ClickHouse/pull/119273) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Refuse a query with `ORDER BY` over a `Distributed` table whose declared column type differs from the shard table's type in a way that does not preserve the order, for example `Int8` declared over a `String` column. The shards sorted by their own type and the initiator merged the streams as if they were sorted by the declared type, which returned rows in the wrong order, cut the wrong rows with `LIMIT`, and duplicated values under `DISTINCT`. The check runs when a shard is the local server, where the shard table's types are known, and only for the columns the query sorts by. Exact widenings (`Float32` to `Float64`, `Date` to `Date32`, `DateTime` to `DateTime64`, a `Decimal` with no smaller scale and no fewer integer digits, `FixedString` to `String`) are now recognized as order-preserving by both this check and the one of the `Merge` engine. [#118445](https://github.com/ClickHouse/ClickHouse/pull/118445) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed queries over a `Distributed` table when `optimize_skip_unused_shards` skips every shard and the query uses `distributed_group_by_no_merge` or reads the table through another `Distributed` table. Such queries failed with `NUMBER_OF_COLUMNS_DOESNT_MATCH`, `CANNOT_CONVERT_TYPE`, or `std::out_of_range` (with `ALIAS` columns) instead of returning an empty result or the aggregate of an empty set. [#122982](https://github.com/ClickHouse/ClickHouse/pull/122982) ([Groene AI](https://github.com/groeneai)).
* Fixed queries that go through another server (`remote`, `Distributed`, parallel replicas, `GLOBAL IN`, and `QueryRunner` jobs sent to a cluster) failing with `SYNTAX_ERROR`, `UNKNOWN_CODEC`, or `CORRUPTED_DATA` when `output_format_native_encode_types_in_binary_format` or `input_format_native_decode_types_in_binary_format` is enabled. The blocks of these queries now carry type names on the wire, and a shard with this change also works with an initiator without it. `clickhouse-client --query_kind secondary_query` follows the same rule. [#123649](https://github.com/ClickHouse/ClickHouse/pull/123649) ([Groene AI](https://github.com/groeneai)). [#124716](https://github.com/ClickHouse/ClickHouse/pull/124716) ([Groene AI](https://github.com/groeneai)).
* Fixed `NOT_FOUND_COLUMN_IN_BLOCK` (or `THERE_IS_NO_COLUMN`) when a query sent to other servers (a `Distributed` table, `remote`, parallel replicas) has an `IN` over a parameterized view called without its database name inside an expression the servers return, for example `countIf(x IN (SELECT y FROM pv(p = 1)))`, a `GROUP BY` key, or a `SELECT` item. Also fixed `NOT_AN_AGGREGATE` when one query spells the same parameterized view call both with and without its database name. [#123662](https://github.com/ClickHouse/ClickHouse/pull/123662) ([Groene AI](https://github.com/groeneai)).
* Fixed `NOT_FOUND_COLUMN_IN_BLOCK` when reading a subcolumn (`Array` `.size0`, a `Tuple` element, `Map` `.keys`/`.values`, `Nullable` `.null`, a `JSON` path, or a `Dynamic` typed subcolumn) through a `VIEW` over a `Distributed` table. [#119293](https://github.com/ClickHouse/ClickHouse/pull/119293) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed wrong results of aggregations, `LIMIT`, `DISTINCT`, `LIMIT BY` and window functions over a `Buffer` table whose destination is a `Distributed` table that a single shard finishes (one shard, `distributed_group_by_no_merge`, or a `GROUP BY` by the sharding key): the rows still in the buffer and the rows of the destination were processed separately and both results were returned. [#124981](https://github.com/ClickHouse/ClickHouse/pull/124981) ([Groene AI](https://github.com/groeneai)).
* Fix wrong results when a condition outside a distributed subquery with `QUALIFY` was pushed into it and evaluated before the window functions `QUALIFY` filters by. [#125491](https://github.com/ClickHouse/ClickHouse/pull/125491) ([Nikita Taranov](https://github.com/nickitat)).
* Fixed `THERE_IS_NO_COLUMN` and `NOT_FOUND_COLUMN_IN_BLOCK` errors in queries over `remote` or with parallel replicas that compare tuples where one pair of elements is constant and false, such as `(n, 1) = (n, 2)`, or where `NULL` is compared with a column, such as `(n, s) = (NULL, s)`. [#125195](https://github.com/ClickHouse/ClickHouse/pull/125195) ([Groene AI](https://github.com/groeneai)).
* Fixed wrong results with `parallel_replicas_plan_based = 1` when the plan fragment sent to the replicas has no output columns, for example `SELECT count() FROM (SELECT 1 FROM t LIMIT 500)`. Such a query returned `0`, or an empty result set, instead of the correct value. [#115871](https://github.com/ClickHouse/ClickHouse/pull/115871) ([Groene AI](https://github.com/groeneai)).
* Fixed wrong results and a `LOGICAL_ERROR` when a query reads with parallel replicas inside a distributed sub-query whose `cluster_for_parallel_replicas` numbers its shards differently from the cluster the query is distributed over: a `VIEW` carrying its own `SETTINGS cluster_for_parallel_replicas`, a read through `clusterAllReplicas` of that same cluster, a cluster built by cluster discovery or by a `Replicated` database when the two servers see a different set of shards under one name, or a plain `remote_servers` cluster whose per-server copies number the shards differently while a configuration change rolls out. The shard number shipped by the initiator was applied to the other numbering and selected the wrong shard. Parallel replicas are now declined for such a read. [#113589](https://github.com/ClickHouse/ClickHouse/pull/113589) ([Groene AI](https://github.com/groeneai)). [#124724](https://github.com/ClickHouse/ClickHouse/pull/124724) ([Igor Nikonov](https://github.com/devcrafter)).
* Fixed `SELECT count()` returning a value multiplied by the number of replicas when executed inside a transaction with parallel replicas enabled. Trivial count optimization now is not rejected inside a transaction, so it is executed solely on the initiator. Followers no longer apply the trivial count optimization during query planning, which previously caused each of them to independently answer with the total row count read from the table's metadata whenever the query reached them. [#116365](https://github.com/ClickHouse/ClickHouse/pull/116365) ([Kirill Shokhin](https://github.com/kirillshokhin)).
* Fixed `max_bytes_to_read`, `max_bytes_to_read_leaf`, and read-speed and timeout limits being ignored for reads executed from a query plan shipped to another node, which happens with `parallel_replicas_plan_based` and `make_distributed_plan`. [#119958](https://github.com/ClickHouse/ClickHouse/pull/119958) ([Igor Nikonov](https://github.com/devcrafter)).
* Fixed `LOGICAL_ERROR` `Cannot find a matching set in the map of sets from single-replica plan`, and silently lost parallel replicas, when automatic parallel replicas were enabled and an `IN` subquery carried its own `SETTINGS` clause naming `force_primary_key` or `automatic_parallel_replicas_mode`. [#120799](https://github.com/ClickHouse/ClickHouse/pull/120799) ([Groene AI](https://github.com/groeneai)).
* Fix `UNKNOWN_FUNCTION` on a shard or a replica for a higher-order function whose lambda body is an `AND` of comparisons when `serialize_query_plan = 1` or `parallel_replicas_plan_based = 1`: a JIT-compiled lambda body was serialized into the plan. [#119332](https://github.com/ClickHouse/ClickHouse/pull/119332) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fix missing total rows in progress (and therefore a non-working progress bar) for queries with parallel replicas when `parallel_replicas_local_plan` is enabled (the default). [#123928](https://github.com/ClickHouse/ClickHouse/pull/123928) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed duplicate filter push-down in plan-based parallel replicas. [#117731](https://github.com/ClickHouse/ClickHouse/pull/117731) ([Nikita Taranov](https://github.com/nickitat)).
* Fixed wrong results and `UNKNOWN_IDENTIFIER` errors when a query reads a `MergeTree` table after reading one of its projections with the `mergeTreeProjection` table function, for example in a `JOIN` or `UNION ALL` of the two. With parallel replicas such a query could also fail with `Got read request from replica N for unknown stream`. Closes [#102182](https://github.com/ClickHouse/ClickHouse/issues/102182). [#123915](https://github.com/ClickHouse/ClickHouse/pull/123915) ([Groene AI](https://github.com/groeneai)).
* `FINAL` on table functions now disables parallel replicas the same way as `FINAL` on tables, so a `TimeSeries` table function such as `timeSeriesTags` no longer returns duplicate rows under parallel replicas. [#122492](https://github.com/ClickHouse/ClickHouse/pull/122492) ([Groene AI](https://github.com/groeneai)).
* Fixed parallel replicas not being used when reading a `Distributed` table whose underlying table is another `Distributed` table and every shard of the outer cluster has a single replica. [#123566](https://github.com/ClickHouse/ClickHouse/pull/123566) ([Igor Nikonov](https://github.com/devcrafter)).
* Fixed `TOO_MANY_ROWS` being raised for a query that stays within its `max_rows_to_read` budget when `parallel_replicas_min_number_of_rows_per_replica` is set. The estimate sizing the replica set enforced the limit against whole granules at planning time. [#121269](https://github.com/ClickHouse/ClickHouse/pull/121269) ([Groene AI](https://github.com/groeneai)).
* Fix a `NOT_IMPLEMENTED` exception for `JOIN` queries with `IN` subqueries when using plan-based parallel replicas. [#121508](https://github.com/ClickHouse/ClickHouse/pull/121508) ([Manuel](https://github.com/raimannma)).
* Parallel replicas now honor a `SETTINGS` clause that changes table eligibility when it is written inside a subquery or a view body. Such a clause was ignored, so a query over a view whose body sets `parallel_replicas_for_non_replicated_merge_tree = 0`, or sets `parallel_replicas_allow_view_over_mergetree = 0` and reads a further view, returned `max_parallel_replicas` times too many rows, and a `UNION` over a view overriding `parallel_replicas_allow_view_over_mergetree` per subquery could throw `Can't determine table for parallel replicas`. [#110020](https://github.com/ClickHouse/ClickHouse/pull/110020) ([Groene AI](https://github.com/groeneai)).
* A query that reads a `MATERIALIZED` CTE more than once, for example inside an `IN` subquery, now works with parallel replicas when the initiator also reads locally (`parallel_replicas_local_plan = 1`). The other replicas no longer fail with `UNKNOWN_TABLE` on the CTE's temporary table. Closes [#112642](https://github.com/ClickHouse/ClickHouse/issues/112642). [#123121](https://github.com/ClickHouse/ClickHouse/pull/123121) ([Groene AI](https://github.com/groeneai)).
* Fixed a `LOGICAL_ERROR` "Block structure mismatch in QueryPipeline stream" when selecting a computed column through the `merge` table function or the `Merge` engine. If constant folding folded that column for one matched table and not another, the query failed. [#115971](https://github.com/ClickHouse/ClickHouse/pull/115971) ([Groene AI](https://github.com/groeneai)).
* Fix the exception `No set is registered for key` for a `SELECT` that reads a `Distributed` table through a `Merge` table or the `merge` table function and whose `GROUP BY`, `DISTINCT`, or `LIMIT BY` key contains an `IN`-family function. [#117817](https://github.com/ClickHouse/ClickHouse/pull/117817) ([Groene AI](https://github.com/groeneai)).
* Fix wrong results when reading a subcolumn of a `Merge` table column whose type differs between the source tables. Such a subcolumn exists only in the common type `Merge` derives, so it was filled with the default value for every row instead of being read. Most visibly, `variantElement` over a `Merge` table returned `NULL` for every row unless the call sat in the top-level projection next to another use of the whole column. [#121462](https://github.com/ClickHouse/ClickHouse/pull/121462) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed a server crash when a `SELECT` with `serialize_query_plan = 1` read a `Merge` table through a table that forwards its reads, such as `Alias`, `Buffer` with a destination, or a `MATERIALIZED VIEW` with a `TO` target. Closes [#119899](https://github.com/ClickHouse/ClickHouse/issues/119899). [#119387](https://github.com/ClickHouse/ClickHouse/pull/119387) ([Groene AI](https://github.com/groeneai)).
* Fixed wrong results when a `Merge` table (or the `merge` table function) reads a subcolumn of a column that one of its child tables does not have: for that child, `x.null` of a missing `Nullable` column `x` was read as 0, so `x IS NULL` returned no rows from it. Element subcolumns of `Tuple`, `Variant` and `JSON` columns and the sizes of a missing flattened `Nested` member were affected the same way. Closes [#122523](https://github.com/ClickHouse/ClickHouse/issues/122523). [#123633](https://github.com/ClickHouse/ClickHouse/pull/123633) ([Groene AI](https://github.com/groeneai)).
* Fixed a `Merge` table returning the value of another column, or failing with a `CAST` error, for a column that one of its child tables does not have, when that child has a row policy or an `ALIAS` column. Such a column is now filled with its default value. [#124674](https://github.com/ClickHouse/ClickHouse/pull/124674) ([Groene AI](https://github.com/groeneai)).
* Fixed `merge` and `Merge` tables with a `Distributed` table among them returning the same `GROUP BY` group several times, each copy with a part of its aggregates, when the aggregation is two-level and a table lacks a grouping column or has it under another type than the common one. [#124720](https://github.com/ClickHouse/ClickHouse/pull/124720) ([Groene AI](https://github.com/groeneai)).
* Fixed a use-after-free when a query reads through an `Alias` table whose target is dropped concurrently. [#120098](https://github.com/ClickHouse/ClickHouse/pull/120098) ([Groene AI](https://github.com/groeneai)).
* Fix `CREATE MATERIALIZED VIEW ... POPULATE AS SELECT count() FROM ` counting rows inserted during the population twice when `materialized_views_populate_atomically` is enabled. [#123182](https://github.com/ClickHouse/ClickHouse/pull/123182) ([Murphy](https://github.com/murphy-4o)).
* Fixed a materialized view over a system log table such as `system.query_log` silently stopping to receive rows after the server renamed the table to `_N` because its definition changed (a server upgrade, or a change of `` or `` in the config). Closes [#124177](https://github.com/ClickHouse/ClickHouse/issues/124177). [#124217](https://github.com/ClickHouse/ClickHouse/pull/124217) ([Groene AI](https://github.com/groeneai)).
* Fixes wrong results when a materialized view reads an ordinary view over a table with a row policy that contains a subquery (`x IN (SELECT ...)` or a scalar subquery). The policy's subquery now reads the real source table instead of the block being inserted into the materialized view. [#124875](https://github.com/ClickHouse/ClickHouse/pull/124875) ([Aditya Kumar](https://github.com/adityaksolves)).
* `SYSTEM WAIT VIEW` on a refreshable materialized view in a `Replicated` or `Shared` database no longer returns `Ok.` while a refresh requested on another replica has not run yet. Requested refreshes are now published in `Keeper`. [#120623](https://github.com/ClickHouse/ClickHouse/pull/120623) ([Samuel Krempaský](https://github.com/NIKTONIKTO717)).
* Fixed a segmentation fault when a refreshable materialized view is started up and shut down at the same time, for example when a failed `ATTACH DATABASE` rolls the database back, or when the server shuts down while tables are still loading asynchronously. [#121037](https://github.com/ClickHouse/ClickHouse/pull/121037) ([Groene AI](https://github.com/groeneai)).
* Fixed a refreshable materialized view with `REFRESH DEPENDS ON` (or `REFRESH AFTER ... DEPENDS ON`) and no `REFRESH EVERY` re-running its refresh without limit after a failure used up `refresh_retries`. It now waits for its dependencies' next refresh. [#123369](https://github.com/ClickHouse/ClickHouse/pull/123369) ([Ashish Kumar Choubey](https://github.com/aschoube)).
* Fixed `plain_rewritable` disks leaving object storage and the in-memory filesystem in disagreement when a failed metadata transaction could not be reversed completely. Transient failures during reversal are now retried until object storage accepts the operation, and rollback runs for all exception types. Missing blobs are reported as `CORRUPTED_DATA`, and replacing a file with a missing source no longer deletes the existing target. The disagreement previously surfaced only after a restart, when a directory could appear under a name the server never committed. [#119235](https://github.com/ClickHouse/ClickHouse/pull/119235) ([Sema Checherinda](https://github.com/CheSema)). [#122696](https://github.com/ClickHouse/ClickHouse/pull/122696) ([Sema Checherinda](https://github.com/CheSema)).
* Fixed a query reading from `file`, `s3`, `url`, `azure`, or `hdfs` with `session_timezone` set getting the `DateTime` schema inferred by an earlier session with a different `session_timezone`, which formatted and computed the values in that other session's time zone. [#117811](https://github.com/ClickHouse/ClickHouse/pull/117811) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed unnecessary object-storage reads, and ``-level exception messages such as `Code: 499 ... The specified key does not exist ... (S3_ERROR)`, while destroying a data part on an object-storage disk when its skip indices are packed into `skp_idx.packed`. Evicting the part's index marks from the mark cache no longer inspects the part's on-disk layout, so it performs no I/O. [#113454](https://github.com/ClickHouse/ClickHouse/pull/113454) ([Groene AI](https://github.com/groeneai)).
* Fixed hive partition columns of glob-path object storage tables being permanently disabled when the first query over the table ran while the path matched no files. [#120308](https://github.com/ClickHouse/ClickHouse/pull/120308) ([Zach Rippas](https://github.com/zatchet)).
* Fixed unbounded memory and CPU usage when a path passed to `file`, `s3`, `azureBlobStorage`, or `hdfs` contains many `{a,b,c}` glob groups or long `{N..M}` ranges. Such a path is now rejected with an error. [#118467](https://github.com/ClickHouse/ClickHouse/pull/118467) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fix `copyObjectToAnotherObjectStorage` copying an object twice when the source and destination are the same object storage, which doubled the data transferred by a copy between two disks backed by that storage. [#120953](https://github.com/ClickHouse/ClickHouse/pull/120953) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed `UNKNOWN_IDENTIFIER` for a `DEFAULT` column that depends on a column used by a row policy, in tables with the `File`, `URL`, `S3`, and other object-storage engines. [#122714](https://github.com/ClickHouse/ClickHouse/pull/122714) ([Nikolai Kochetov](https://github.com/KochetovNicolai)).
* Fix object storage tables with `partition_strategy = 'hive'` being silently empty for formats whose name is not the file extension real files carry. The read glob was built from the lowercased format name (`**.jsoneachrow`, `**.csvwithnames`), so pointing a `JSONEachRow` table at a lake of `.json` / `.jsonl` files — or a `CSVWithNames` table at `.csv` files — read zero rows with no error or warning. The glob is now built from every file extension registered for the format (and for its `WithNames`/`WithNamesAndTypes` base format), plus additionally registered read extensions: `JSONEachRow` matches `.json`/`.jsonl`/`.ndjson` files and `TabSeparated` matches `.tsv`. Files written by ClickHouse itself keep matching. [#120319](https://github.com/ClickHouse/ClickHouse/pull/120319) ([Zach Rippas](https://github.com/zatchet)).
* Fixed reads of Hive-partitioned files (`.../key=9/...`) that need no column of the data file, such as `count()` with `optimize_count_from_files = 0` or `SELECT key, _row_number`, returning no rows (`Native` threw an exception) when a partition column was smaller than the data columns. The wrong `0` was also cached and returned by later `count()` queries. The same reads of a structure that lists only partition columns returned no rows or threw an exception for most formats. Affects `file`, `url`, `s3` and other object storages. [#123381](https://github.com/ClickHouse/ClickHouse/pull/123381) ([Groene AI](https://github.com/groeneai)).
* A query over an object storage table (e.g. `S3`) no longer waits for another query that is resolving the table's hive partitioning on its first use, so `KILL QUERY` and `max_execution_time` apply to it while the endpoint is slow or unreachable. [#123532](https://github.com/ClickHouse/ClickHouse/pull/123532) ([Groene AI](https://github.com/groeneai)).
* Fixed `BAD_ARGUMENTS` (`Expected positional arguments to go before key-value arguments`) for a valid `S3` argument list that combines `headers(...)` with a key-value argument, in either order, and for the engines and table functions sharing that parser (`Iceberg`, `DeltaLake`, `Hudi`, `Paimon`, `GCS`, `S3Queue`). With `file_like_engine_default_partition_strategy = 'wildcard'` the server persisted such a list itself, so a created table could no longer be attached and the server refused to start; affected tables load again. [#119070](https://github.com/ClickHouse/ClickHouse/pull/119070) ([Groene AI](https://github.com/groeneai)).
* Fix the logical error `Attempt to read beyond right offset` when the right bound of a read from Azure Blob Storage is lowered below bytes the reader has already buffered. [#120957](https://github.com/ClickHouse/ClickHouse/pull/120957) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed a `WHERE` condition 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 `_file` when the data file has a physical column with that name. Affects `file`, `url`, `s3`, and other object storages. [#124991](https://github.com/ClickHouse/ClickHouse/pull/124991) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed an exception when a `WHERE` condition on the `_file`, `_path`, or `_part` virtual column guards a branch with `if`, `and`, `or`, or `multiIf`, for example `WHERE _file LIKE 'events_%' AND toDate(substring(_file, 8, 10)) >= '2024-01-01'`. Pruning files and parts by virtual columns now respects `short_circuit_function_evaluation` instead of evaluating the excluded branch for every file or part name. The same path now also rebuilds copied `indexHint` expressions and reduced `and` expressions with the right arguments, avoiding argument-count exceptions during lazy evaluation. [#125033](https://github.com/ClickHouse/ClickHouse/pull/125033) ([Groene AI](https://github.com/groeneai)). [#125150](https://github.com/ClickHouse/ClickHouse/pull/125150) ([Groene AI](https://github.com/groeneai)). [#125126](https://github.com/ClickHouse/ClickHouse/pull/125126) ([Groene AI](https://github.com/groeneai)).
* Fixed loading, short `ATTACH`, and `UNDROP TABLE` for existing SQL-defined `S3` disks whose endpoints are absent from `remote_url_allow_hosts`; new full-definition `CREATE` and `ATTACH` still reject disallowed endpoints. [#124930](https://github.com/ClickHouse/ClickHouse/pull/124930) ([Alexey Bakharew](https://github.com/alexbakharew)).
* Fixed filesystem cache accounting when the directory for a new cache key cannot be created, for example because the cache disk is out of space or inodes. The failed reservation stayed counted in the cache until the query released the file segment. [#122211](https://github.com/ClickHouse/ClickHouse/pull/122211) ([Sema Checherinda](https://github.com/CheSema)).
* Fixed `Parquet` writing size statistics twice for a column chunk that falls back from dictionary encoding, which made `unencoded_byte_array_data_bytes` and the level histograms too large. The `ParquetMetadata` format now also reports `size_statistics` for each column chunk. [#120027](https://github.com/ClickHouse/ClickHouse/pull/120027) ([Erez Rokah](https://github.com/erezrokah)).
* Fix two `JSON` object-size-limit bugs: bytes before the opening bracket are now counted toward the limit, and valid data is no longer rejected just because earlier rows in the same block already used the shared buffer. [#115795](https://github.com/ClickHouse/ClickHouse/pull/115795) ([Pavel Kruglov](https://github.com/Avogar)).
* Schema inference for the `Freeform` format no longer exhausts memory on a wide row of strings: the search for the row structure is bounded by the setting `input_format_freeform_max_search_steps` (default `4096`, `0` means unlimited) and now also stops at `max_memory_usage`, `max_execution_time`, and `KILL QUERY`. [#122447](https://github.com/ClickHouse/ClickHouse/pull/122447) ([Mohammed Sohail](https://github.com/msohail22)). [#123238](https://github.com/ClickHouse/ClickHouse/pull/123238) ([Groene AI](https://github.com/groeneai)).
* Fix a crash when reading an ORC file whose root type is not a struct (for example, a file written with a `bigint` or `array` root type). Such files are now rejected with an `INCORRECT_DATA` error. Closes [#123305](https://github.com/ClickHouse/ClickHouse/issues/123305). [#123337](https://github.com/ClickHouse/ClickHouse/pull/123337) ([Groene AI](https://github.com/groeneai)).
* Fixed a possible out of bounds access when reading an ORC file. [#123464](https://github.com/ClickHouse/ClickHouse/pull/123464) ([Pedro Ferreira](https://github.com/PedroTadim)).
* Fix reading Avro files with a union whose named branches (records, enums, fixed) have the same structure. Before the fix, such files failed with `The number of (non-null) union types in Avro record (N) does not match the number of types in destination Variant type (M)`, even with the inferred schema. [#123236](https://github.com/ClickHouse/ClickHouse/pull/123236) ([Dmitry Kovalev](https://github.com/dk-github)).
* Avro schema parsing no longer overflows the stack on a deep chain of named types. [#124053](https://github.com/ClickHouse/ClickHouse/pull/124053) ([Groene AI](https://github.com/groeneai)).
* Fixed a crash (stack overflow) on an Avro schema with a long chain of named type references, in schema inference (`DESC`, or `SELECT` without an explicit structure, for `Avro` and `AvroConfluent`), in reads into a `Variant` column and in Iceberg manifest reading. Such a schema now fails with an error instead. [#124644](https://github.com/ClickHouse/ClickHouse/pull/124644) ([Groene AI](https://github.com/groeneai)).
* Fixes a crash when reading an ORC file whose metadata has fewer stripe statistics than the file has stripes (for example, after a corrupt `metadata_length`) with `input_format_orc_filter_push_down` enabled. The `ORC` input format now reads such files without stripe-level filtering. [#124315](https://github.com/ClickHouse/ClickHouse/pull/124315) ([Groene AI](https://github.com/groeneai)).
* Fixed a crash (stack overflow) when reading an Avro file with an explicit structure that does not read a field nested through a long chain of named types, or a field of a recursive type holding deeply nested data such as a long linked list. Such a file now fails with `TOO_DEEP_RECURSION` instead. Closes [#124925](https://github.com/ClickHouse/ClickHouse/issues/124925). [#124964](https://github.com/ClickHouse/ClickHouse/pull/124964) ([Groene AI](https://github.com/groeneai)).
* Fixed a stack overflow crash on a deeply nested `CapnProto` schema that the nesting depth check missed: a comment or a byte order mark between `import` and its path, an escape sequence in the import path, or a backtick text line. A backtick text line with many brackets is no longer rejected as nested too deeply. [#125487](https://github.com/ClickHouse/ClickHouse/pull/125487) ([Groene AI](https://github.com/groeneai)).
* Fixed a crash (stack overflow) on a `CapnProto` schema with a long chain of type expression suffixes (`Int32.a.a...`, `Int32()()...`) or of declarations that refer to each other (constants, aliases, struct fields, annotations, imports). Such a schema is now rejected with `The CapnProto schema is nested too deeply`. Closes [#125782](https://github.com/ClickHouse/ClickHouse/issues/125782). [#125900](https://github.com/ClickHouse/ClickHouse/pull/125900) ([Groene AI](https://github.com/groeneai)).
* Fixed a data race on the file list of a `File` engine table. Two concurrent `INSERT`s with `engine_file_allow_create_multiple_files = 1` could pick the same file name, which made `SELECT count()` over-report, rejected a valid `INSERT` with `CANNOT_APPEND_TO_FILE`, and could corrupt the heap. Closes [#121517](https://github.com/ClickHouse/ClickHouse/issues/121517). [#121598](https://github.com/ClickHouse/ClickHouse/pull/121598) ([Groene AI](https://github.com/groeneai)).
* Fixed `count()` over `file('*.csv', 'CSVWithNames')` with `optimize_count_from_files = 1` over-counting a CSV file by one row in rare cases. [#120552](https://github.com/ClickHouse/ClickHouse/pull/120552) ([Knut-Aage-Hofseth](https://github.com/Knut-Aage-Hofseth)).
* Fixed concurrent `INSERT`s and `SELECT`s on a table with the `File` engine stalling for `lock_acquire_timeout` (120 seconds by default) and then failing with `TIMEOUT_EXCEEDED`. A single `SELECT` can open several readers on one `File` table, and an `INSERT` arriving between two of them made the query wait for itself. Closes [#115931](https://github.com/ClickHouse/ClickHouse/issues/115931). [#121779](https://github.com/ClickHouse/ClickHouse/pull/121779) ([Groene AI](https://github.com/groeneai)).
* Fixed `TinyLog` returning fewer rows than the table contains when one of the data files being read ends before the others. An `Array`, `Map`, or `Nested` column contributes an elements file that holds one entry per element rather than per row, so it runs out early whenever the trailing rows hold empty containers, and a column holding only empty arrays contributes an elements file of zero bytes. The read stopped at the first data file by name to reach its end, cutting the result at a block boundary. [#120307](https://github.com/ClickHouse/ClickHouse/pull/120307) ([Groene AI](https://github.com/groeneai)).
* Fixed `BACKUP` and `RESTORE` queries with `SETTINGS = DEFAULT`: such a query either failed to parse or was formatted into text that could not be parsed back, and the other settings of the same clause were discarded. Repeated `async` items now use the last value, `async = '1'` no longer fails after the operation has started, and `compression` is rejected in the `SETTINGS` clause as in other queries. [#112978](https://github.com/ClickHouse/ClickHouse/pull/112978) ([Groene AI](https://github.com/groeneai)).
* Fixed `BACKUP` writing a `.backup` manifest that is not well-formed XML when a value in it contained `&`, `<`, or `>`, for example `BACKUP ... SETTINGS id = 'a&b'`, or an incremental backup whose `base_backup` path contained one of those characters. The backup reported `BACKUP_CREATED`, but every later `RESTORE` from it failed with `SAXParseException: Invalid token`, leaving the data unreachable. Such values are now escaped. Backups already written with an unescaped value remain unreadable and have to be taken again. [#118898](https://github.com/ClickHouse/ClickHouse/pull/118898) ([Julia Kartseva](https://github.com/jkartseva)).
* Fixed `RESTORE` of `system.functions` failing, and aborting the whole restore, when the backup holds a SQL user-defined function whose definition the version that created it accepted but `CREATE FUNCTION` now rejects, for example `CREATE FUNCTION f AS lambda(identity(x), x)` created on 25.5 or earlier. [#122912](https://github.com/ClickHouse/ClickHouse/pull/122912) ([Groene AI](https://github.com/groeneai)).
* Fixes `BACKUP ... ON CLUSTER` creating a backup that cannot be restored when a host names its data files differently from the initiator: with `data_file_name_generator = 'checksum'` and a `data_file_name_prefix_length` other than the hosts' `backups.data_file_name_prefix_length` (3 by default), or when a host's config sets `backups.data_file_name_generator = checksum` and the initiator uses the default generator. Backups already created this way still cannot be restored. [#122624](https://github.com/ClickHouse/ClickHouse/pull/122624) ([Groene AI](https://github.com/groeneai)).
* Fixed `RESTORE` of a lightweight snapshot from `Azure Blob Storage` when the source disk endpoint includes a key prefix below the container name. [#122697](https://github.com/ClickHouse/ClickHouse/pull/122697) ([Garrett Thomas](https://github.com/garrettthomaskth)).
* Fixed column comments of a `ReplicatedMergeTree` table being lost in a backup when they were changed after the last metadata `ALTER`. [#121309](https://github.com/ClickHouse/ClickHouse/pull/121309) ([Nikolay Degterinsky](https://github.com/evillique)).
* Fixed `BACKUP` / `RESTORE ... ON CLUSTER` hanging forever, unaffected by `KILL QUERY` and blocking server shutdown, when `compatibility` is set to `24.10` or older and a host fails on a `Keeper` error before it starts. Such a `compatibility` value no longer sets `backup_restore_finish_timeout_after_error_sec`, `backup_restore_failure_after_host_disconnected_for_seconds`, `backup_restore_keeper_max_retries_while_initializing`, and `backup_restore_keeper_max_retries_while_handling_error` to `0`, a combination no release ever used. [#123752](https://github.com/ClickHouse/ClickHouse/pull/123752) ([Groene AI](https://github.com/groeneai)).
* Fixed `BACKUP` failing with `A concurrent backup writing to the same destination ... detected` when nothing else was writing there. The lock file is claimed with a conditional write, and a retry of a request that had already been applied made the backup mistake its own lock for someone else's. [#116376](https://github.com/ClickHouse/ClickHouse/pull/116376) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* `BACKUP` and `RESTORE` to `S3` now retry requests that fail with `ExpiredToken` after refreshing credentials. The retry time limit is 120 seconds by default and can be changed with `backup_s3_expired_token_retry_timeout_ms`. [#123195](https://github.com/ClickHouse/ClickHouse/pull/123195) ([Nikolai Ovchinnikov](https://github.com/kolsha)).
* `BACKUP ... TO File(...)` / `Disk(...)` now fsyncs the backup data files, the `.backup` manifest and the containing directories before reporting `BACKUP_CREATED`, so an acknowledged backup to local storage survives power loss. The guarantee covers `backups.allowed_path` and everything the backup writes below it. On a `Disk(...)` over object storage that keeps its metadata in local files, those metadata files are fsynced instead, since the backup is reached only through them. Controlled by the new backup setting `fsync_backup_files` (default `true`). `S3(...)`/`AzureBlobStorage(...)` destinations are unaffected. [#111394](https://github.com/ClickHouse/ClickHouse/pull/111394) ([Groene AI](https://github.com/groeneai)).
* `Iceberg` tables whose manifest file headers carry a schema that conflicts with the schema registered for the same `schema-id` in `metadata.json` are now readable: the `metadata.json` schema is preferred and the divergent manifest header copy is ignored with a warning, no matter which of the two copies is read first, matching the behavior of other query engines such as Spark, Trino, PyIceberg, and DuckDB. Controlled by the new setting `iceberg_tolerate_conflicting_manifest_schemas` (default `true`); `compatibility` below `26.9` restores the previous strict behavior, which failed such queries with `ICEBERG_SPECIFICATION_VIOLATION`. [#119743](https://github.com/ClickHouse/ClickHouse/pull/119743) ([Melvyn Peignon](https://github.com/melvynator)).
* Fixed `Iceberg` manifest statistics recording the wrong file count for added files. [#120858](https://github.com/ClickHouse/ClickHouse/pull/120858) ([Konstantin Vedernikov](https://github.com/scanhex12)).
* Fixed `Iceberg` `INSERT` writing no `lower_bounds` or `upper_bounds` at all into the manifest entry when the table has a column whose type cannot be serialized into a statistics bound, or a column that is entirely `NULL`. Such a field is now omitted individually and the bounds of every other column are still written, so min/max file pruning keeps working. Closes [#112706](https://github.com/ClickHouse/ClickHouse/issues/112706). [#112934](https://github.com/ClickHouse/ClickHouse/pull/112934) ([Groene AI](https://github.com/groeneai)).
* Fixed `Iceberg` date partition transforms being computed in the server time zone instead of UTC. [#118583](https://github.com/ClickHouse/ClickHouse/pull/118583) ([Konstantin Vedernikov](https://github.com/scanhex12)).
* Fixed `SHOW TABLES` and `system.tables` failing on a database with the `DataLakeCatalog` engine over an `Iceberg` REST catalog when an unrelated namespace was dropped by another client while the listing was in flight. [#113740](https://github.com/ClickHouse/ClickHouse/pull/113740) ([Groene AI](https://github.com/groeneai)).
* Fixed validation of `Iceberg` manifest-list entries during writes. [#122829](https://github.com/ClickHouse/ClickHouse/pull/122829) ([Arsen Muk](https://github.com/arsenmuk)).
* Fixed metadata of empty `Iceberg` tables created by ClickHouse, so that Spark and other `Iceberg` Java-based tools can open them before the first insert and evolve their partition spec. [#122077](https://github.com/ClickHouse/ClickHouse/pull/122077) ([Asya Shneerson](https://github.com/asya-ch)).
* Prevent loss of newer committed `Iceberg` data by rejecting `OPTIMIZE` when `iceberg_metadata_file_path`, `iceberg_snapshot_id`, or `iceberg_timestamp_ms` is explicitly set. [#122683](https://github.com/ClickHouse/ClickHouse/pull/122683) ([Arsen Muk](https://github.com/arsenmuk)).
* Fixed reading an Iceberg table partitioned by `DateTime64` when a data file does not store the partition column: the query failed with `DECIMAL_OVERFLOW`. Decimal partition values stored in a manifest in their raw form are decoded as well, and `system.iceberg_files.partition` now shows partition values in a readable form instead of raw bytes. [#117090](https://github.com/ClickHouse/ClickHouse/pull/117090) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fix `CREATE TABLE` and `DROP TABLE` in Iceberg REST catalog databases: the catalog now writes the initial metadata file, `ORDER BY` and table properties are sent to the catalog, multi-level namespaces are created correctly, and `DROP TABLE` uses the correct endpoint. [#123631](https://github.com/ClickHouse/ClickHouse/pull/123631) ([Asya Shneerson](https://github.com/asya-ch)).
* Fix `SELECT count()` over `Iceberg` tables returning too few rows after compaction leaves dangling position-delete files. Closes [#123494](https://github.com/ClickHouse/ClickHouse/issues/123494). [#123851](https://github.com/ClickHouse/ClickHouse/pull/123851) ([Konstantin Vedernikov](https://github.com/scanhex12)).
* Fixed reading `Iceberg` tables through the `DataLakeCatalog` database engine when the catalog reports a column type in a spelling the Iceberg type parser did not know: `varbyte` (Glue's name for the Iceberg `binary` type), `list<...>` (the Iceberg spelling of `array<...>`, also written by Glue), and `timestamp with local time zone` (Hive 3's name for the Iceberg `timestamptz` type). Such tables were rejected with `Unknown Iceberg type`. Closes [#121850](https://github.com/ClickHouse/ClickHouse/issues/121850). Closes [#87716](https://github.com/ClickHouse/ClickHouse/issues/87716). [#121974](https://github.com/ClickHouse/ClickHouse/pull/121974) ([Groene AI](https://github.com/groeneai)).
* The `iceberg_metadata_staleness_ms` setting is now respected when parsing `Iceberg` metadata, so `Iceberg` table functions and `ON CLUSTER` workers no longer list the whole `metadata/` directory on every query. [#124113](https://github.com/ClickHouse/ClickHouse/pull/124113) ([Konstantin Vedernikov](https://github.com/scanhex12)).
* Fix a server abort when reading an `Iceberg` table whose sort order names a transform ClickHouse cannot parse, e.g. `bucket[xyz]`; ClickHouse now ignores that sort-order hint and keeps the table readable. [#121687](https://github.com/ClickHouse/ClickHouse/pull/121687) ([Ilias](https://github.com/iliasabk)).
* Fixed `OPTIMIZE TABLE` for OSS Iceberg tables so compaction no longer removes `version-hint.text` and breaks hint-based reads. [#122833](https://github.com/ClickHouse/ClickHouse/pull/122833) ([Arsen Muk](https://github.com/arsenmuk)).
* Fixed a crash (SIGSEGV) when reading a malformed deletion vector with the `Puffin` input format, for example one whose roaring run container has zero runs. Structurally invalid roaring bitmaps are now rejected with an error instead of crashing or returning wrong deleted-row positions. Closes [#124688](https://github.com/ClickHouse/ClickHouse/issues/124688). [#124735](https://github.com/ClickHouse/ClickHouse/pull/124735) ([Groene AI](https://github.com/groeneai)).
* Fixed an `INSERT` into a `Parquet` `Iceberg` table failing with `Logical error: 'Iceberg data file has 1 columns while its schema has 2 fields'` when `ALTER TABLE ... ADD COLUMN` committed while the `INSERT` was running. [#121821](https://github.com/ClickHouse/ClickHouse/pull/121821) ([Groene AI](https://github.com/groeneai)).
* Fixed `Iceberg` v3 virtual columns `_row_id` and `_last_updated_sequence_number`: filters on them no longer return no rows for a data file rewritten by copy-on-write when the manifest has statistics for the table columns but not for the row-lineage columns, and rows of files written before the table was upgraded to format version 3 no longer return `NULL` for these columns. Closes [#124271](https://github.com/ClickHouse/ClickHouse/issues/124271). [#124591](https://github.com/ClickHouse/ClickHouse/pull/124591) ([Groene AI](https://github.com/groeneai)). [#124598](https://github.com/ClickHouse/ClickHouse/pull/124598) ([Groene AI](https://github.com/groeneai)).
* Fixed `OPTIMIZE TABLE ... MANIFEST` failing with `BAD_ARGUMENTS` on an `Iceberg` table whose current snapshot summary omits an optional `total-records`, `total-files-size`, or `total-data-files` metric, which made manifest compaction permanently unavailable on tables written by engines that omit those metrics. Closes [#117000](https://github.com/ClickHouse/ClickHouse/issues/117000). [#117012](https://github.com/ClickHouse/ClickHouse/pull/117012) ([Groene AI](https://github.com/groeneai)).
* Fixed `Iceberg` min/max pruning skipping a data file that holds matching rows when the file's `uuid` bound was written by an external engine such as Spark, Trino, or PyIceberg. Such a bound now prunes only when its lower and upper bounds are equal. This fixes the `Iceberg` manifest bounds only: the `uuid` statistics of the `Parquet` data file itself are a separate defect, so a query at default settings can still miss rows. Closes [#118366](https://github.com/ClickHouse/ClickHouse/issues/118366). [#118380](https://github.com/ClickHouse/ClickHouse/pull/118380) ([Groene AI](https://github.com/groeneai)).
* Fixed `Iceberg` writes storing ClickHouse unsigned integers in a narrower `Iceberg` integer type than the source. [#118596](https://github.com/ClickHouse/ClickHouse/pull/118596) ([Konstantin Vedernikov](https://github.com/scanhex12)).
* `ALTER TABLE ... EXECUTE remove_orphan_files` on `Iceberg` tables now rejects an `older_than` that is less than `iceberg_orphan_files_min_retention_seconds` (default 1 day) before now, so it no longer deletes the files of a write that started within that window and has not committed yet. Setting `iceberg_orphan_files_min_retention_seconds` to `0` restores the previous behavior. Closes [#125331](https://github.com/ClickHouse/ClickHouse/issues/125331). [#125376](https://github.com/ClickHouse/ClickHouse/pull/125376) ([Groene AI](https://github.com/groeneai)).
* Fixed `DROP TABLE` in a `DataLakeCatalog` database with an `Iceberg` REST catalog ignoring `iceberg_delete_data_on_drop` from the server's default profile: ClickHouse always sent `purgeRequested=False`, so the catalog never deleted the table's data, and Microsoft OneLake rejected the drop with HTTP 405. ClickHouse now sends `purgeRequested=true` or `purgeRequested=false` (lowercase, as the `Iceberg` REST spec defines), chosen by that setting; a session-level `SET` does not reach this drop. Closes [#125410](https://github.com/ClickHouse/ClickHouse/issues/125410). [#125469](https://github.com/ClickHouse/ClickHouse/pull/125469) ([Groene AI](https://github.com/groeneai)).
* Fixed `add.modificationTime` in Delta Lake commit logs being written in seconds instead of the milliseconds the Delta protocol requires, so a data file written by ClickHouse appeared to Spark, `delta-rs`, and `delta-kernel-rs` as last modified in 1970. Closes [#120523](https://github.com/ClickHouse/ClickHouse/issues/120523). [#120564](https://github.com/ClickHouse/ClickHouse/pull/120564) ([Groene AI](https://github.com/groeneai)).
* Fixed wrong values and a `LOGICAL_ERROR` when reading a partitioned `DeltaLake` table with `allow_delta_kernel_rs = 0` and column types that differ from the ones in `_delta_log`. [#121544](https://github.com/ClickHouse/ClickHouse/pull/121544) ([Raúl Marín](https://github.com/Algunenano)).
* Fix reading Delta Lake tables with column mapping where a field name with a dot, like `a.b`, equals the path of a nested field (the field `b` of a struct `a`). Such a field returned the other field's values or `NULL`, `SELECT *` failed with `COLUMN_QUERIED_MORE_THAN_ONCE`, and a partitioned table failed with a `LOGICAL_ERROR`. [#123102](https://github.com/ClickHouse/ClickHouse/pull/123102) ([Groene AI](https://github.com/groeneai)).
* Fix `NOT_FOUND_COLUMN_IN_BLOCK` when a query reads a struct column of a `DeltaLake` table with column mapping together with one of its fields, such as `SELECT s, s.x`, `SELECT *, s.x`, or `SELECT s ... WHERE s.x = 1`. Closes [#123811](https://github.com/ClickHouse/ClickHouse/issues/123811). [#123852](https://github.com/ClickHouse/ClickHouse/pull/123852) ([Groene AI](https://github.com/groeneai)).
* Fixed `INSERT` into `DeltaLake` tables through a Unity `DataLakeCatalog`: the catalog now requests write credentials instead of reusing read-only ones. [#123543](https://github.com/ClickHouse/ClickHouse/pull/123543) ([Konstantin Vedernikov](https://github.com/scanhex12)).
* Fix DeltaLake statistics pruning for filters that compare a `Date32` column through `CAST`, `toDate`, or `toDate32`, including a wrong-results case where `1 >= d` was treated as `d >= 1`. [#119184](https://github.com/ClickHouse/ClickHouse/pull/119184) ([Arsen Muk](https://github.com/arsenmuk)).
* Fixed `INSERT` into a `DeltaLake` table with a `timestamp_ntz` column writing the `Parquet` data file with `isAdjustedToUTC=true`, which made the committed table unreadable by Spark and other Delta engines. Such a column is now annotated `TIMESTAMP(isAdjustedToUTC=false)`, as the Delta protocol requires. Closes [#120653](https://github.com/ClickHouse/ClickHouse/issues/120653). [#120863](https://github.com/ClickHouse/ClickHouse/pull/120863) ([Groene AI](https://github.com/groeneai)).
* Fixed `SHOW TABLES`, `system.tables` scans, and table resolution hanging indefinitely against a `paimon_rest` catalog whose listings paginate. [#115534](https://github.com/ClickHouse/ClickHouse/pull/115534) ([JIaQi Tang](https://github.com/JiaQiTang98)).
* Fixed data lake tables created on top of a server disk (`SETTINGS disk = '...'`): they no longer overwrite the disk's object storage settings with the table's or the query's settings, and they follow the disk's configuration on `SYSTEM RELOAD CONFIG` instead. [#117398](https://github.com/ClickHouse/ClickHouse/pull/117398) ([alesapin](https://github.com/alesapin)).
* Reading an Apache Paimon primary-key table now throws `NOT_IMPLEMENTED` instead of silently returning wrong results. Merge-on-read is not implemented, so the reader returned the raw union of the snapshot's data files, including the row versions superseded by later upserts. Closes [#113360](https://github.com/ClickHouse/ClickHouse/issues/113360). [#113460](https://github.com/ClickHouse/ClickHouse/pull/113460) ([Groene AI](https://github.com/groeneai)).
* Fixed `SHOW CREATE DATABASE` and `BACKUP` of a `DataLakeCatalog` database omitting its `COMMENT`, and `ALTER DATABASE ... MODIFY SETTING` erasing that comment from the stored metadata, so that it was lost after a restart. [#122942](https://github.com/ClickHouse/ClickHouse/pull/122942) ([Groene AI](https://github.com/groeneai)).
* Reject `Paimon` manifest and data paths that escape the table directory. A crafted table could previously read files outside its own directory through an absolute path or `..` components in metadata paths. [#123099](https://github.com/ClickHouse/ClickHouse/pull/123099) ([Konstantin Vedernikov](https://github.com/scanhex12)).
* Fixed a data race between concurrent queries on one `Hudi` table: the list of the table's data files was filled on first use without synchronization. [#119137](https://github.com/ClickHouse/ClickHouse/pull/119137) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed the Paimon incremental read silently duplicating and dropping data. Advancing the consumed-snapshot watermark in Keeper is now fenced by the `processing_lock` and monotonic, so a read that lost the lock can no longer commit over another consumer's progress. A cursor left ahead of the warehouse, and a snapshot that fails to load for any reason other than Paimon expiration, now raise an error instead of being silently skipped. [#117630](https://github.com/ClickHouse/ClickHouse/pull/117630) ([JIaQi Tang](https://github.com/JiaQiTang98)).
* Fixed two ways a table with the `Redis` engine mishandled an `MGET` reply. Reading the whole table stopped at the first key without a string value and silently dropped every key scanned after it, so one key of another Redis type was enough to truncate the result. A reply carrying a different number of elements than keys requested could terminate the server; such a reply is now rejected with `INTERNAL_REDIS_ERROR`. [#120230](https://github.com/ClickHouse/ClickHouse/pull/120230) ([Groene AI](https://github.com/groeneai)).
* Fixed a broker-side queue leak when dropping a `RabbitMQ` table. `DROP TABLE` asked the broker to delete the table's queues without waiting for its own consumer channels to close, so the broker could still see a registered consumer and refuse the deletion with `PRECONDITION_FAILED`. [#116050](https://github.com/ClickHouse/ClickHouse/pull/116050) ([Groene AI](https://github.com/groeneai)).
* Fixed spurious `NATS` connection failures when the vendored `nats-io` client gets `EINTR` while waiting for a socket, and picked up the upstream JetStream pull-subscription deadlock fix in the vendored client. [#120202](https://github.com/ClickHouse/ClickHouse/pull/120202) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed `arrowFlight` and the `ArrowFlight` table engine hanging forever when the remote Flight server accepts a request and never answers it. Requests are now bounded by the new `arrow_flight_request_timeout_sec` setting (300 seconds by default, `0` disables the bound), and a stalled read honors `KILL QUERY` and `max_execution_time`. [#120231](https://github.com/ClickHouse/ClickHouse/pull/120231) ([Groene AI](https://github.com/groeneai)).
* Fixed `SELECT` queries on an `EmbeddedRocksDB` table with a composite `PRIMARY KEY` returning fewer rows than match the predicate when the predicate combines `IN` sets with `OR` and one set's element type cannot be converted to the key type. Such a set no longer narrows the candidate keys. [#122261](https://github.com/ClickHouse/ClickHouse/pull/122261) ([Groene AI](https://github.com/groeneai)).
* Fixed a `FileLog` table that stopped reading all of its files forever after a single read error (such as a line that failed to parse or a partially written last line): every later poll reported `Another select query is running on this table` and every direct `SELECT` failed with `CANNOT_SELECT` until the server was restarted. Related to [#123368](https://github.com/ClickHouse/ClickHouse/issues/123368). [#123395](https://github.com/ClickHouse/ClickHouse/pull/123395) ([Groene AI](https://github.com/groeneai)).
* Fixed a `NATS` engine table reading from a JetStream stream (`nats_stream`) silently stopping to consume messages after the NATS server restarted or the connection was re-established. [#115343](https://github.com/ClickHouse/ClickHouse/pull/115343) ([Alexey Milovidov](https://github.com/alexey-milovidov)). [#119301](https://github.com/ClickHouse/ClickHouse/pull/119301) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fix a rare server crash (`SIGSEGV` in `mongoc_log`) when a MongoDB dictionary source or `MongoDB` table was created while another thread created the first MongoDB connection in the process. Messages logged by the MongoDB driver now go to the server log. [#124235](https://github.com/ClickHouse/ClickHouse/pull/124235) ([Vladimir Cherkasov](https://github.com/vdimir)).
* `RENAME DATABASE` is now refused when the database holds a loaded `S3Queue` or `AzureQueue` table whose `keeper_path` expanded the `{database}` macro when the table was loaded. Previously the rename succeeded silently, the table bound to a different `Keeper` path at the next server start and reprocessed every file it had already consumed. Not checked: detached tables, tables not yet materialized under `lazy_load_tables = 1`, and a `keeper_path` whose macros a config reload redefined after the table was loaded. [#120103](https://github.com/ClickHouse/ClickHouse/pull/120103) ([Groene AI](https://github.com/groeneai)).
* `SELECT count()` and `system.tables.total_rows` of a `Join` table that keeps every row of a key, `ALL`, or `ANY` / `SEMI` / `ANTI` with `RIGHT`, returned the number of distinct keys instead of the number of rows. [#124099](https://github.com/ClickHouse/ClickHouse/pull/124099) ([Groene AI](https://github.com/groeneai)).
* Fixed reading `Enum8` and `Enum16` columns of `PostgreSQL` and `MySQL` tables, `Nullable(Enum8)` and `Nullable(Enum16)` columns of `PostgreSQL` tables, and `Enum` range columns of a `PostgreSQL` dictionary source. Values are now returned as the declared `Enum` type, parsed by element name or by number, instead of the raw remote text typed as `String` or an `Unexpected value N in enum` error. A remote value that is not an element of the enum is now rejected with an error. [#125198](https://github.com/ClickHouse/ClickHouse/pull/125198) ([Groene AI](https://github.com/groeneai)).
* Fixes `RabbitMQ` tables with `rabbitmq_num_consumers > 1` that insert into materialized views with `parallel_view_processing = 0` (the default) falling behind: the consumers were read one after another, all but the first inserted a single message per flush interval, and their messages waited many intervals (up to about 28 s at 100 msg/s with a 1 s interval). They are now read in parallel. [#125106](https://github.com/ClickHouse/ClickHouse/pull/125106) ([Sven Eliasson](https://github.com/comino)).
* Fixed a server crash (segmentation fault) in a direct `SELECT` from a `NATS` table while the table replaces a connection that the NATS client library closed for good, for example after the broker rejected rotated credentials. Closes [#120199](https://github.com/ClickHouse/ClickHouse/issues/120199). [#125494](https://github.com/ClickHouse/ClickHouse/pull/125494) ([Groene AI](https://github.com/groeneai)).
* Fixed a heap-use-after-free when an `EmbeddedRocksDB` table with a composite `PRIMARY KEY` was filtered by a tuple equality whose tuple has a `LowCardinality` element, e.g. `WHERE (k, id) = (SELECT (name, id) FROM t LIMIT 1)`. Closes [#120527](https://github.com/ClickHouse/ClickHouse/issues/120527). [#125509](https://github.com/ClickHouse/ClickHouse/pull/125509) ([Groene AI](https://github.com/groeneai)).
* Fixed the Arrow Flight interface returning garbage values for a `MergeTree` column stored in sparse serialization, which is the default for a column that holds mostly default values. Affected `DoGet` with a SQL ticket, `GetFlightInfo` and `PollFlightInfo`. [#125553](https://github.com/ClickHouse/ClickHouse/pull/125553) ([Groene AI](https://github.com/groeneai)).
* Fixed a server crash when a `RabbitMQ` table with the `headers` exchange type had a routing key without `=`, or when `rabbitmq_routing_key_list` was empty. Routing keys without `=` for the `headers` exchange type are now rejected with an exception. The problem was found and reported by [@dstesk](https://github.com/dstesk). [#125661](https://github.com/ClickHouse/ClickHouse/pull/125661) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* `StorageKafka2` now counts only live replicas when distributing partition locks, so a replica that lost its `Keeper` session no longer leaves some partitions unconsumed. [#120111](https://github.com/ClickHouse/ClickHouse/pull/120111) ([johnjing](https://github.com/JingYanchao)).
* Fixed memory growth in `Kafka` tables with offsets stored in `Keeper` when partitions move between consumers: prefetched messages for released partitions are now freed rather than retained until restart. Closes [#125077](https://github.com/ClickHouse/ClickHouse/issues/125077). [#125076](https://github.com/ClickHouse/ClickHouse/pull/125076) ([Aparajita Pandey](https://github.com/aparajita31pandey)).
* Fixed spurious `TLS/SSL error: Interrupted system call` failures in `mysql`, the `MySQL` table engine, the `MySQL` database engine, and `MySQL` dictionaries by updating `mariadb-connector-c` to v3.4.10, with a patch that clears the OpenSSL error queue before every TLS operation. [#120526](https://github.com/ClickHouse/ClickHouse/pull/120526) ([Groene AI](https://github.com/groeneai)).
* Fixed a durability bug in the `MySQL` and `PostgreSQL` database engines. The marker file recording whether a table is detached or dropped was created and removed without fsyncing the metadata directory, so a power loss could silently revert an acknowledged `DETACH TABLE ... PERMANENTLY`, `DROP TABLE`, or `ATTACH TABLE` and change the table's visibility on restart. It is now fsynced when `fsync_metadata` is enabled (the default). A failed `ATTACH TABLE` no longer leaves the table half-attached, which made a retry report `TABLE_ALREADY_EXISTS`. [#112170](https://github.com/ClickHouse/ClickHouse/pull/112170) ([Groene AI](https://github.com/groeneai)).
* Using the `PostgreSQL` engine, inserts now quote table and column names so PostgreSQL does not fold them to lowercase. The destination table can therefore use any identifier casing. [#120435](https://github.com/ClickHouse/ClickHouse/pull/120435) ([Thomas Sileghem](https://github.com/mastilver)).
* Fixed `KILL QUERY` and `max_execution_time` having no effect on a query reading from `PostgreSQL` when the remote host stops sending data, and `DROP` of a refreshable materialized view whose refresh reads from `PostgreSQL` hanging for the same reason. [#118995](https://github.com/ClickHouse/ClickHouse/pull/118995) ([Nikolay Degterinsky](https://github.com/evillique)).
* Fixed `PostgreSQL` connections losing `send_timeout` after the handshake. [#123094](https://github.com/ClickHouse/ClickHouse/pull/123094) ([Sema Checherinda](https://github.com/CheSema)).
* HTTP dictionary sources (`SOURCE(HTTP(...))`) now respect the `max_http_get_redirects` setting, so dictionaries can be created from URLs that redirect. Previously such dictionaries always failed with `TOO_MANY_REDIRECTS`. [#101768](https://github.com/ClickHouse/ClickHouse/pull/101768) ([Yash ](https://github.com/Onyx2406)).
* Fix `optimize_inverse_dictionary_lookup` rewriting `dictGet` comparisons incorrectly: complex-key dictionaries with a single key column called with a `tuple`-wrapped, possibly `Nullable`, key expression failed with `ILLEGAL_TYPE_OF_ARGUMENT`; key expressions that rely on `dictGet`'s implicit key type conversion, e.g. a `String` expression for a `UUID` key, failed with `NO_COMMON_TYPE`, and lossy ones silently returned results where `dictGet` throws; a match on a dictionary key containing `NULL` produced `NULL` instead of `false`; a single matching floating-point `NaN` or zero key produced wrong results; and mismatched key shapes were folded to a result instead of the `dictGet` error. Key expressions that would need a conversion are no longer rewritten and keep the `dictGet` lookup, except a signed integer probe of a simple-key dictionary, which is converted to the `UInt64` lookup type the way `dictGet` converts it. [#114865](https://github.com/ClickHouse/ClickHouse/pull/114865) ([Artur Beglaryan](https://github.com/artbeglaryan)).
* Fixed a dictionary with a local `CLICKHOUSE` source that stopped updating with `ACCESS_DENIED` and kept serving stale data after a new role was granted to its source user and the old role was dropped. Every query of such a source now uses the current default roles of the user, like a new session of that user. Closes [#122663](https://github.com/ClickHouse/ClickHouse/issues/122663). [#124051](https://github.com/ClickHouse/ClickHouse/pull/124051) ([Groene AI](https://github.com/groeneai)).
* Fixed ClickHouse Keeper terminating when a client sent a `multi` request with no subrequests. Such a request was written to the Keeper changelog before it failed, so the termination repeated on every restart. [#119847](https://github.com/ClickHouse/ClickHouse/pull/119847) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed ClickHouse Keeper discarding a `world:anyone` ACL entry with all permissions when the request contained other entries. Such a node was stored more restrictively than requested and could end up repairable only with a `super` credential; with `` configured and no ``, a `ReplicatedMergeTree` under the configured path could not be created at all. These nodes now get the requested permissions, which grants every session full access to them, as ZooKeeper does. Closes [#120177](https://github.com/ClickHouse/ClickHouse/issues/120177). [#120265](https://github.com/ClickHouse/ClickHouse/pull/120265) ([Groene AI](https://github.com/groeneai)).
* Fixed `Keeper` persistent recursive watch events to report the path of the changed node, matching ZooKeeper behavior. Previously, they reported the path where the watch was registered. [#121333](https://github.com/ClickHouse/ClickHouse/pull/121333) ([Kirill](https://github.com/kirillgarbar)).
* Fix a segmentation fault in `ClickHouse Keeper` when preallocating space for a changelog file fails because the disk is full. [#122337](https://github.com/ClickHouse/ClickHouse/pull/122337) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* ClickHouse Keeper no longer sends the same watch event to one session several times when more than one of the session's watches matches a change, for example persistent recursive watches on `/a` and `/a/b` for a `create /a/b/c`, or a single persistent watch on a removed node. Like ZooKeeper, Keeper now sends each event to a session once. Closes [#122291](https://github.com/ClickHouse/ClickHouse/issues/122291). [#122706](https://github.com/ClickHouse/ClickHouse/pull/122706) ([Groene AI](https://github.com/groeneai)).
* Fixed a Keeper durability gap: with `force_sync` enabled, the directory entry of a new changelog segment, or of a segment continued after a restart, was never fsynced, so acknowledged writes in that segment could be lost after a power loss on filesystems where a file fsync does not persist the file's name. Keeper now fsyncs the log directory before the first entries of such a segment are reported durable, and stops if that fails. [#122755](https://github.com/ClickHouse/ClickHouse/pull/122755) ([Groene AI](https://github.com/groeneai)).
* Fixed Keeper silently giving a new session to a ZooKeeper client, for example the Java client or `kazoo`, that reconnects and asks to continue its session. Such a client now gets `SessionExpired`, ZooKeeper's answer for a session that cannot be continued, instead of losing its ephemeral nodes later without notice. Keeper still does not restore sessions. Closes [#116690](https://github.com/ClickHouse/ClickHouse/issues/116690). [#122767](https://github.com/ClickHouse/ClickHouse/pull/122767) ([Groene AI](https://github.com/groeneai)).
* Fixed the Keeper HTTP storage API (`/api/v1/storage`) storing a truncated value and reporting success when a `POST` or `PUT` body was larger than `max_request_size`. Such requests are now rejected with `413`, and the node is left unchanged. Closes [#122286](https://github.com/ClickHouse/ClickHouse/issues/122286). [#122928](https://github.com/ClickHouse/ClickHouse/pull/122928) ([Groene AI](https://github.com/groeneai)).
* Fix Keeper recovery with `remove_orphaned_nodes_on_startup` leaving an unrepaired snapshot on disk. Persist the repaired snapshot so followers can install it successfully and the recovered node can restart with orphan recovery disabled. [#123206](https://github.com/ClickHouse/ClickHouse/pull/123206) ([Seva Potapov](https://github.com/seva-potapov)).
* Fixed a Keeper node that restarted after a crash sometimes giving a new client the session ID of a client that had connected to it before the restart, after which the new client received that client's responses. [#124307](https://github.com/ClickHouse/ClickHouse/pull/124307) ([Groene AI](https://github.com/groeneai)).
* ClickHouse now rejects relative paths in `checksums.txt`. [#120356](https://github.com/ClickHouse/ClickHouse/pull/120356) ([alesapin](https://github.com/alesapin)).
* Encryption codecs (`AES_128_GCM_SIV`, `AES_256_GCM_SIV`) now also cover the structural substreams of a column. [#120636](https://github.com/ClickHouse/ClickHouse/pull/120636) ([Raufs Dunamalijevs](https://github.com/rienath)).
* Rejected a compressed block whose codec stores data verbatim, such as `NONE` or `Quantized`, when its declared uncompressed size does not match the body length. Previously that passthrough read path accepted such a block while every other decompression path rejected it. [#114344](https://github.com/ClickHouse/ClickHouse/pull/114344) ([Groene AI](https://github.com/groeneai)).
* Reject invalid HTTP header names supplied to SQL-facing HTTP clients (the `url` table function and engine, HTTP dictionaries, `S3`/object storage, and `DataLake`/REST catalogs). A header name must be a valid RFC 9110 token (letters, digits and ``!#$%&'*+-.^_`|~``); any other byte, `:`, whitespace, control characters, or separators such as `/` and `=`, is rejected. Such names could previously bypass the `` restriction. [#118830](https://github.com/ClickHouse/ClickHouse/pull/118830) ([Sergei Trifonov](https://github.com/serxa)).
* Fixed `ALTER QUOTA` silently not taking effect when a quota is changed to `KEYED BY client_key`: a user whose quota context was already cached kept the previous, more permissive limits, and the failed refresh also stopped every other cached context from picking up unrelated quota changes. [#120240](https://github.com/ClickHouse/ClickHouse/pull/120240) ([Groene AI](https://github.com/groeneai)).
* Kafka producer and consumer trace logs now show secret `librdkafka` properties, such as `sasl.password`, as `[HIDDEN]` instead of their cleartext values. [#119244](https://github.com/ClickHouse/ClickHouse/pull/119244) ([János Benjamin Antal](https://github.com/antaljanosbenjamin)).
* `EXPLAIN AST` no longer prints secret function arguments, such as the key of `encrypt`, in cleartext, including with `optimize = 1` for the body of a view the user may only `SELECT` from. [#120313](https://github.com/ClickHouse/ClickHouse/pull/120313) ([Harikrishnan Prabakaran](https://github.com/harikrishnan94)).
* ClickHouse now masks credentials in `system.query_log` even for invalid URLs of external table engines. [#122057](https://github.com/ClickHouse/ClickHouse/pull/122057) ([alesapin](https://github.com/alesapin)).
* The value of `role_session_name` is now hidden in `query_log`. [#122423](https://github.com/ClickHouse/ClickHouse/pull/122423) ([Alexey Bakharew](https://github.com/alexbakharew)).
* `BACKUP ... TO S3(...)` and `RESTORE ... FROM S3(...)` now enforce `remote_url_allow_hosts` on the initial `S3` URL, instead of checking only redirect targets. Endpoints that the `s3` table function would reject now fail with `UNACCEPTABLE_URL` here as well. [#123114](https://github.com/ClickHouse/ClickHouse/pull/123114) ([Konstantin Vedernikov](https://github.com/scanhex12)).
* A password or presigned signature in a URL is no longer printed in clear by the `ConfluentSchemaRegistry` trace log, by the `URL ... is not allowed in configuration file, see ` error, or by the `Unsupported scheme in URI` error. These now show `scheme://[HIDDEN]@host` and `X-Amz-Signature=[HIDDEN]`, as `system.query_log` already does for `format_avro_schema_registry_url`. [#123226](https://github.com/ClickHouse/ClickHouse/pull/123226) ([Groene AI](https://github.com/groeneai)).
* Fixed `SYSTEM SYNC TRANSACTION LOG` (local, non-`ON CLUSTER` form) not checking the `SYSTEM_SYNC_TRANSACTION_LOG` privilege. The `ON CLUSTER` form already required it, so a user without the grant could run the local form when experimental transactions were enabled. [#112441](https://github.com/ClickHouse/ClickHouse/pull/112441) ([Azhar Izzannada E](https://github.com/azharizz)).
* The values of MongoDB connection options that carry a secret (`tlsCertificateKeyFilePassword`, `sslClientCertificateKeyPassword`, `AWS_SESSION_TOKEN` in `authMechanismProperties`) are now hidden in `SHOW CREATE`, `system.query_log` and `system.dictionaries.source` for the `MongoDB` table engine, the `mongodb` table function and the MongoDB dictionary source, `system.dictionaries.source` no longer shows the MongoDB password, and a named-collection `uri` override after another override is no longer shown as written. [#123240](https://github.com/ClickHouse/ClickHouse/pull/123240) ([Groene AI](https://github.com/groeneai)).
* A `SELECT` row policy on the `mergeTreeProjection` table function (`_table_function.mergeTreeProjection`) is now also applied to a read shipped to another server as a serialized query plan (`serialize_query_plan = 1`, with `process_query_plan_packet` enabled there), as it already is for a local read or with `serialize_query_plan = 0`. [#123609](https://github.com/ClickHouse/ClickHouse/pull/123609) ([Groene AI](https://github.com/groeneai)).
* `SYSTEM DROP DATABASE REPLICA` without a database name is now denied for a user without the `SYSTEM DROP REPLICA` privilege, instead of silently doing nothing and reporting success. This makes it consistent with `SYSTEM DROP REPLICA`. [#117964](https://github.com/ClickHouse/ClickHouse/pull/117964) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* `ALTER TABLE ... MODIFY SETTING disk = disk(...)` could register a disk defined in SQL whose local path is outside `custom_local_disks_base_directory`, and create its directory, bypassing the check that `CREATE TABLE` applies. Now it is rejected the same way, and a statement rejected this way leaves no disk and no directory behind. [#119850](https://github.com/ClickHouse/ClickHouse/pull/119850) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed `ALTER TABLE ... ATTACH PARTITION ... FROM ...` and `CREATE TABLE ... CLONE AS ...` requiring the `ALTER DELETE` privilege on the destination table. These statements only add data, so `INSERT` is now enough. `REPLACE PARTITION`, which does drop the destination data, still requires `ALTER DELETE`. A session temporary table used as the source of `ATTACH` or `REPLACE PARTITION ... FROM` also no longer wrongly requires `SELECT` on a same-named table of the current database. [#117936](https://github.com/ClickHouse/ClickHouse/pull/117936) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed the server terminating when an argument of a `disk(...)` setting value is a key without a value, such as `disk(equals(name))`. A malformed `disk(...)` argument no longer causes the whole query, including its other secrets, to be logged unmasked. [#123847](https://github.com/ClickHouse/ClickHouse/pull/123847) ([Groene AI](https://github.com/groeneai)).
* Mask secrets in the queries that a cluster-mode `QueryRunner` table writes to `system.query_log` as well as in queries executed as startup scripts. [#118978](https://github.com/ClickHouse/ClickHouse/pull/118978) ([Miсhael Stetsyuk](https://github.com/mstetsyuk)).
* A `RESTORE TABLE ... AS ` of a backup whose engine arguments were stripped now validates the Keeper path it derives from `default_replica_path`. Previously the `{database}` and `{table}` substitutions were expanded against the restored name without being checked, so a name containing `/` resolved into another table's Keeper subtree and left an inactive replica there. [#121546](https://github.com/ClickHouse/ClickHouse/pull/121546) ([Groene AI](https://github.com/groeneai)).
* Hide secrets in the `system.mutations` table. [#122717](https://github.com/ClickHouse/ClickHouse/pull/122717) ([alesapin](https://github.com/alesapin)).
* Creating a `FileLog` table now requires the `READ` and `WRITE` privileges, as for a `File` table. [#125701](https://github.com/ClickHouse/ClickHouse/pull/125701) ([Robert Schulze](https://github.com/rschu1ze)).
* Fixed an out-of-bounds read when reading a `Variant` column from a truncated `Native` stream using compact discriminators serialization. [#120252](https://github.com/ClickHouse/ClickHouse/pull/120252) ([Raufs Dunamalijevs](https://github.com/rienath)).
* Reject malformed PostgreSQL startup messages whose parameter data exceeds the declared payload size. [#112780](https://github.com/ClickHouse/ClickHouse/pull/112780) ([Minh Vu](https://github.com/fallintoplace)).
* Reading settings from the Native protocol no longer sizes a string from the length a peer declares before the payload arrives, so a Query packet or a server hello can no longer turn a few bytes on the wire into a large memory allocation. This covers settings and query parameters, on the server and in the client. [#118612](https://github.com/ClickHouse/ClickHouse/pull/118612) ([Groene AI](https://github.com/groeneai)). [#120931](https://github.com/ClickHouse/ClickHouse/pull/120931) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed a crash when a client sends a block over the native TCP protocol that selects the internal `Detached` serialization kind for a column. [#117699](https://github.com/ClickHouse/ClickHouse/pull/117699) ([Pavel Kruglov](https://github.com/Avogar)).
* `COPY` options are no longer silently ignored on the PostgreSQL wire protocol: `WITH (FORMAT csv)` and the legacy `WITH CSV` are now applied, unsupported options are reported instead of skipped, and TSV header auto-detection no longer drops the first data row of a `COPY ... FROM STDIN`. [#119376](https://github.com/ClickHouse/ClickHouse/pull/119376) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Bound the header column count in `RowBinary` formats to avoid excessive memory allocation from a crafted header. [#120282](https://github.com/ClickHouse/ClickHouse/pull/120282) ([George Larionov](https://github.com/george-larionov)).
* Reject malformed `Native` blocks or corrupted parts that could make ClickHouse read past the end of a `JSON` or `Dynamic` column, for example because of duplicate types or paths, a truncated stream, or a part-only serialization version sent over the wire. [#117765](https://github.com/ClickHouse/ClickHouse/pull/117765) ([Pavel Kruglov](https://github.com/Avogar)).
* Fixed `handshake_timeout_milliseconds` not bounding a connection that stops sending during the handshake, which held a thread for `receive_timeout` (300 seconds by default) instead. The setting now also covers the MySQL and PostgreSQL handshake phases and the TLS negotiation; previously a peer that dribbled bytes during a TLS handshake, or stayed silent on the PostgreSQL port, could hold a thread indefinitely. HTTP header reading keeps its own `http_headers_read_timeout` budget, now enforced by the same mechanism. On `tcp_port_secure`, ClickHouse no longer writes an exception to a client whose TLS handshake has already timed out, so such a peer no longer holds a handler thread for twice the configured budget. [#121547](https://github.com/ClickHouse/ClickHouse/pull/121547) ([Sema Checherinda](https://github.com/CheSema)). [#123101](https://github.com/ClickHouse/ClickHouse/pull/123101) ([Sema Checherinda](https://github.com/CheSema)).
* Reject malformed binary input with out-of-range VarInt, integer, or enum values, including settings, client info, query plans, distributed task descriptions, and text indexes, instead of silently truncating them. [#113944](https://github.com/ClickHouse/ClickHouse/pull/113944) ([sunliqiang](https://github.com/Pyolar)). [#123242](https://github.com/ClickHouse/ClickHouse/pull/123242) ([Sergei Trifonov](https://github.com/serxa)).
* The collections of the `Native` protocol, the settings and query parameters of a query, the client information, the granted roles, and the table-status lists, are now bounded, so a small packet can no longer make the server allocate memory for data that has not arrived. [#117015](https://github.com/ClickHouse/ClickHouse/pull/117015) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed `Code: 102. UNEXPECTED_PACKET_FROM_SERVER (... got Progress)` aborting an `INSERT` that requests a table structure from the server, when a subquery is evaluated while the server analyses the query. The `Progress` and `ProfileEvents` packets sent in that window are now drained instead of rejected, both by the client and by the initiator of an `INSERT` into a `Distributed` or `remote` table, where rejecting them also hid the shard's own error. Affects `INSERT ... SELECT`, `input` inserts, and `INSERT ... VALUES` with `async_insert = 0`. [#118946](https://github.com/ClickHouse/ClickHouse/pull/118946) ([Groene AI](https://github.com/groeneai)).
* Fixed the PostgreSQL wire protocol rejecting a simple query that consists only of comments, such as the `-- ping` that the Go driver `pgx` v5 sends from `Ping`, with `Empty query`. Such a query is now answered with `EmptyQueryResponse`, as in PostgreSQL. Closes [#84085](https://github.com/ClickHouse/ClickHouse/issues/84085). [#125161](https://github.com/ClickHouse/ClickHouse/pull/125161) ([Groene AI](https://github.com/groeneai)).
* Fixed `http_max_multipart_form_data_size` silently truncating oversized multipart data instead of failing the query, and made it span a form's external-table parts instead of resetting per part. [#120036](https://github.com/ClickHouse/ClickHouse/pull/120036) ([Sema Checherinda](https://github.com/CheSema)).
* `KILL QUERY`, query timeouts, and client disconnects now stop a query that reads over HTTP, for example over the `url` table function, while it is retrying a request, instead of waiting until all retry attempts are exhausted. [#112930](https://github.com/ClickHouse/ClickHouse/pull/112930) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed gRPC queries with transport compression (`gzip`, `deflate`) crashing the server, as they could in official builds since 26.4. Closes [#115121](https://github.com/ClickHouse/ClickHouse/issues/115121). [#122668](https://github.com/ClickHouse/ClickHouse/pull/122668) ([Groene AI](https://github.com/groeneai)).
* Prevented asynchronous inserts that only need to buffer data from being blocked by another insert waiting for a flush worker while holding their shared queue lock. `SYSTEM FLUSH ASYNC INSERT QUEUE` now also waits for batches removed from the queue that are still waiting for a worker. [#118352](https://github.com/ClickHouse/ClickHouse/pull/118352) ([RJ](https://github.com/VrtxOmega)).
* Fixed asynchronous `INSERT` under a quota `KEYED BY client_key`: the flush ran without the client's quota key, so it failed with `QUOTA_REQUIRES_CLIENT_KEY` (or charged the wrong bucket). The quota key is now carried through the async batch and restored on flush, and background quota recomputes no longer log a spurious `QUOTA_REQUIRES_CLIENT_KEY` error. [#122296](https://github.com/ClickHouse/ClickHouse/pull/122296) ([Mikhail f. Shiryaev](https://github.com/Felixoid)).
* Fixed `max_memory_usage_for_user` being exceeded by memory the user no longer holds. Memory that a query allocates but does not free itself, such as the data of in-memory table engines, cache entries and data waiting in the asynchronous insert queue, is now accounted to whoever owns it, and whatever a query leaves behind is settled when it ends. `max_memory_usage_for_user` is also applied when a query hands over memory it allocated before it had a user. [#113647](https://github.com/ClickHouse/ClickHouse/pull/113647) ([Raúl Marín](https://github.com/Algunenano)).
* Queries that send data over pooled connections, such as `INSERT` into a `Distributed` table, are no longer charged for connection buffers that stay in the pool after they finish, which could count against `max_memory_usage_for_user` while another query of the same user was running. [#125573](https://github.com/ClickHouse/ClickHouse/pull/125573) ([Raúl Marín](https://github.com/Algunenano)).
* Fix a possible hang of a query under workload CPU scheduling with `cpu_slot_preemption` enabled: when all its threads were preempted, the query could keep CPU slots it had already used and wait forever for one of them. [#123640](https://github.com/ClickHouse/ClickHouse/pull/123640) ([Sergei Trifonov](https://github.com/serxa)).
* Fixed vector search returning too few rows for a query with `arrayJoin` below `ORDER BY LIMIT`. A row policy now counts as an additional filter for vector search, so `vector_search_filter_strategy = 'prefilter'` is honored and the index fetch multiplier is applied for a query filtered by a row policy. Fixed `NOT_FOUND_COLUMN_IN_BLOCK` for a non-rescoring vector search query when a `WHERE` filter or a row policy reads the vector column. [#114074](https://github.com/ClickHouse/ClickHouse/pull/114074) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fix a vector search returning fewer rows than its `LIMIT`, and missing true nearest neighbors, after a lightweight `DELETE` (or with a delete mutation applied on the fly): the vector index is no longer used for a part while it still holds deleted rows. [#119371](https://github.com/ClickHouse/ClickHouse/pull/119371) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* `CREATE TABLE` now rejects a `SETTINGS` name that is neither a setting of the table engine nor a query setting for the `File`, `URL`, `S3` (with `COSN`, `OSS`, `GCS`), `AzureBlobStorage`, `HDFS`, `Log`, `TinyLog`, and `StripeLog` engines, with `UNKNOWN_SETTING`, as `MergeTree` already did. The `name = DEFAULT` and `param_name = value` spellings are rejected too, except where the whole clause is dropped before any engine sees it. Such a name used to be accepted, stored in the table metadata, and never read, so a typo like `input_format_csv_delimiter` for `format_csv_delimiter` silently did nothing. A table whose stored definition already names a non-setting still loads. Closes [#120705](https://github.com/ClickHouse/ClickHouse/issues/120705). [#120898](https://github.com/ClickHouse/ClickHouse/pull/120898) ([Groene AI](https://github.com/groeneai)).
* `arrayJoin` in a projection or in a `Distributed` sharding key is now rejected at `CREATE`/`ALTER` time. It changes the number of rows, which made every insert into a table with such a projection fail with an exception, and misrouted or failed inserts into such a `Distributed` table. [#117791](https://github.com/ClickHouse/ClickHouse/pull/117791) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed `ALTER TABLE ... MODIFY ORDER BY` accepting a key expression over a column that the same `ALTER` retypes through a subcolumn, for example `MODIFY COLUMN x Tuple(a UInt32, b UInt32), MODIFY ORDER BY (k, x.a)`, or renames, for example `RENAME COLUMN x TO y, MODIFY ORDER BY (k, y)`. Existing parts are not sorted by such a key, so queries that rely on the sort order could return wrong results. Such an `ALTER` is now refused with `BAD_ARGUMENTS`. Closes [#122685](https://github.com/ClickHouse/ClickHouse/issues/122685). [#122765](https://github.com/ClickHouse/ClickHouse/pull/122765) ([Groene AI](https://github.com/groeneai)).
* Fixed `ALTER TABLE ... MODIFY QUERY` deleting the column comments of a materialized view with a `TO` table. A column that the new query still produces now keeps its comment. [#122775](https://github.com/ClickHouse/ClickHouse/pull/122775) ([Groene AI](https://github.com/groeneai)).
* Fixed `ALTER TABLE COMMENT COLUMN
'...'` and comment-only `ALTER TABLE MODIFY COLUMN
COMMENT '...'` returning success and storing nothing on a materialized view with an inner table, which left no supported way to change a column comment on such a view after `CREATE`. [#119469](https://github.com/ClickHouse/ClickHouse/pull/119469) ([Groene AI](https://github.com/groeneai)). [#123033](https://github.com/ClickHouse/ClickHouse/pull/123033) ([Pedro Ferreira](https://github.com/PedroTadim)).
* Fix `DROP NAMED COLLECTION` succeeding while a `MongoDB` table uses the collection, after which the server could not attach the table on restart. The drop is now refused with `NAMED_COLLECTION_IS_USED`, as for other table engines. [#123636](https://github.com/ClickHouse/ClickHouse/pull/123636) ([Groene AI](https://github.com/groeneai)).
* A sharding key of a `Distributed` table, a `Remote` table or the `remote`/`cluster` table functions that contains `IN` with a subquery or with a non-`Set` table is now rejected when the table is defined. The set of such an `IN` was never built, so every `INSERT` failed with a `Not-ready Set` logical error and `optimize_skip_unused_shards` could prune to the wrong shard and return wrong results. A table defined earlier with such a key still loads, but an `INSERT` that needs the key fails with `BAD_ARGUMENTS` and shard pruning does not use it. Pruning by a key with `IN` over a `Set` table, which can change after rows are placed, now needs `allow_nondeterministic_optimize_skip_unused_shards`, as for `joinGet`. [#124646](https://github.com/ClickHouse/ClickHouse/pull/124646) ([Groene AI](https://github.com/groeneai)).
* Reject a `RENAME DATABASE` that would make the table dependency graph cyclic, for example one that leaves an `Alias` table referring to itself. Such a rename put a cycle into the server-wide table dependency graph, after which every unrelated `CREATE` that adds a dependency edge failed with `INFINITE_LOOP` and the renamed database stopped being listable after a restart. [#117253](https://github.com/ClickHouse/ClickHouse/pull/117253) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed formatting of a function named `any` with a single subquery argument: ``SELECT 1 = `any`((SELECT 1))`` lost its backticks, and because bare `ANY` before a subquery is the SQL quantifier, formatting the query changed its meaning to `IN`. This affected round-trips such as stored view definitions and `SHOW CREATE`. [#120175](https://github.com/ClickHouse/ClickHouse/pull/120175) ([Groene AI](https://github.com/groeneai)).
* Fixed parsing of a column named `from` inside parentheses, such as `WHERE (from IN ('a'))`, which since 26.8 was read as a subquery starting with the `FROM` clause and failed with `Unknown table function IN`, `Unknown table expression identifier`, or a syntax error. [#120950](https://github.com/ClickHouse/ClickHouse/pull/120950) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Preserve quoting for identifiers named `cube`, `rollup`, and `recursive` so formatted queries can be parsed back correctly. [#121896](https://github.com/ClickHouse/ClickHouse/pull/121896) ([Jaysurya Ray](https://github.com/Jaysurya85)).
* Fix `SET = DEFAULT` ignoring an active `compatibility` setting: the setting now gets the value of that version, unless the settings constraints forbid it, and `SET compatibility = DEFAULT` reverts the settings it changed. Closes [#116883](https://github.com/ClickHouse/ClickHouse/issues/116883). [#116933](https://github.com/ClickHouse/ClickHouse/pull/116933) ([Groene AI](https://github.com/groeneai)).
* Fixed direct config substitutions via `from_env` failing when XML-1.0-legal values contain XML special characters like `&`, `<`, `>`, or the `]]>` sequence; existing `` XML-subtree substitutions are unchanged. An explicit `` substitution can read a YAML subtree wherever the generic `` form is used, including inside a leaf element, so it must not be used for a literal secret or setting. Without the explicit `yaml="true"` attribute, a non-`<` value is literal text, but direct non-`<` leaf `from_zk` substitutions are recommended for exact-byte secrets or settings, because surrounding whitespace of an `` becomes part of a leaf value. Values beginning with `<` continue to be interpreted as XML fragments for backward compatibility. Upgrade note: a direct `from_env` value or a non-`<` leaf `from_zk` value that was previously XML-entity-encoded, for example `a&b`, now resolves to its exact literal bytes and must be stored raw as `a&b` instead. [#101773](https://github.com/ClickHouse/ClickHouse/pull/101773) ([Yash ](https://github.com/Onyx2406)).
* Fixed the server refusing to start with `UNKNOWN_ELEMENT_IN_CONFIG` when the definition files of executable user-defined functions or of their drivers are placed in `config.d` (for example with `config.d/*_function.xml`), which also merges their `` or `` elements into the server config. Closes [#123308](https://github.com/ClickHouse/ClickHouse/issues/123308). [#123586](https://github.com/ClickHouse/ClickHouse/pull/123586) ([Groene AI](https://github.com/groeneai)).
* Queries over `system.parts`, `system.parts_columns`, `system.projection_parts`, `system.projection_parts_columns`, and `system.dropped_tables_parts` now respect cancellation and `max_execution_time` while the result is being built. [#113909](https://github.com/ClickHouse/ClickHouse/pull/113909) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed a data race on the exception message for a cancelled query: threads no longer append context concurrently to one shared exception object. [#119077](https://github.com/ClickHouse/ClickHouse/pull/119077) ([Groene AI](https://github.com/groeneai)).
* Fixed unbounded memory growth from time zone names that were not names of the time zone database. A time zone name now has to be one that `system.time_zones` lists, or a fixed UTC offset spelled `Fixed/UTC±HH:MM:SS`. [#120288](https://github.com/ClickHouse/ClickHouse/pull/120288) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed a server abort during transaction rollback: internal exception-reporting helpers could call `std::terminate` while no exception was being handled. [#122891](https://github.com/ClickHouse/ClickHouse/pull/122891) ([Murphy](https://github.com/murphy-4o)).
* Fixed a crash when synchronous logging (`logger.async = 0`) had no log sink that accepted a message. [#123336](https://github.com/ClickHouse/ClickHouse/pull/123336) ([Groene AI](https://github.com/groeneai)).
* Fixed a permanent hang of the server on macOS, where threads that format a time (for example while signing `S3` requests, reporting an exceeded quota or reloading a dictionary) could wait forever on the C library's internal time zone lock while the query profiler was enabled. [#125369](https://github.com/ClickHouse/ClickHouse/pull/125369) ([Groene AI](https://github.com/groeneai)).
* Fixed `NOT_FOUND_COLUMN_IN_BLOCK` on a table that has a physical column named `_part` shadowing the virtual column, for queries such as `SELECT count() FROM t WHERE isNull(_part > 0)` and `SELECT count() FROM t WHERE _partition_id = 'all'`. [#117539](https://github.com/ClickHouse/ClickHouse/pull/117539) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* The statistics cache is now refreshed for read-only `MergeTree` tables. [#119559](https://github.com/ClickHouse/ClickHouse/pull/119559) ([Rory Shanks](https://github.com/rorylshanks)).
* A `MergeTree` table with `table_disk = 1` mounts the parts already present at the disk root. If it declares a sorting key those parts were not written with, reading it raised `LOGICAL_ERROR` and aborted the server in builds with assertions enabled. It now reports `INCORRECT_DATA` and names the offending part. [#119295](https://github.com/ClickHouse/ClickHouse/pull/119295) ([Groene AI](https://github.com/groeneai)).
* Fix a refresh of a table whose disks are all read-only (`SYSTEM RESTART DISK`, or the background `refresh_parts_interval` task) failing with a `LOGICAL_ERROR` and hiding committed parts when a rolled-back part covers them. Follow-up to [#100992](https://github.com/ClickHouse/ClickHouse/issues/100992), which fixed the same case on the startup part-loading path. [#111167](https://github.com/ClickHouse/ClickHouse/pull/111167) ([Groene AI](https://github.com/groeneai)).
* `SYSTEM SYNC MERGES` no longer returns while the part covering the scheduled merges is still uncommitted: it now waits until a new transaction can see that part. [#123396](https://github.com/ClickHouse/ClickHouse/pull/123396) ([Murphy](https://github.com/murphy-4o)).
* Reject empty part names in `CHECK TABLE`. [#123625](https://github.com/ClickHouse/ClickHouse/pull/123625) ([Minh Vu](https://github.com/fallintoplace)).
* Partition commands on a `DateTime64` key accept a literal with `.` as the date separator again, such as `'2024.02.19 00:00:00.500'`. [#122995](https://github.com/ClickHouse/ClickHouse/pull/122995) ([DeviousCardi](https://github.com/DeviousCardi)).
* A `CHECK TABLE` running while a part writes `txn_version.txt` no longer fails with `Unexpected file txn_version.txt.tmp in data part`. [#124158](https://github.com/ClickHouse/ClickHouse/pull/124158) ([Murphy](https://github.com/murphy-4o)).
* Fixed `ALTER TABLE ... MATERIALIZE TTL` failing with `UNKNOWN_IDENTIFIER` and being retried forever on a table with `ttl_only_drop_parts = 1` when a part still holds a column that the table dropped while that part's partition was detached. Mutating such a partition after cloning it into another table with `ATTACH PARTITION FROM` no longer fails with a logical error either. [#115962](https://github.com/ClickHouse/ClickHouse/pull/115962) ([Groene AI](https://github.com/groeneai)).
* Fixed a member of a `Nested` added by `ALTER TABLE ... ADD COLUMN` to a `Memory` table being read as empty arrays for the rows inserted before the `ALTER`, unless another member of the same `Nested` was read at the same time. It now gets the array sizes of the other members, like in `MergeTree`. This fixes wrong results of `SELECT`, `WHERE`, `PREWHERE`, `ARRAY JOIN`, and row policies over such a column, and `SIZES_OF_ARRAYS_DONT_MATCH` errors. [#122991](https://github.com/ClickHouse/ClickHouse/pull/122991) ([Groene AI](https://github.com/groeneai)).
* Fixed `SELECT` from `system.part_moves_between_shards` and `KILL PART_MOVE_TO_SHARD` failing with `Code: 999 ... No node, path .../part_moves_shard` when any replicated table on the server is attached without its Keeper tree. [#122132](https://github.com/ClickHouse/ClickHouse/pull/122132) ([Groene AI](https://github.com/groeneai)).
* Fixed an exception (`BAD_GET` or `NOT_IMPLEMENTED`) when a filter on a table with a `_part_offset` projection had a `Float` or `Nullable(Nothing)` condition over a column the projection does not store. [#124568](https://github.com/ClickHouse/ClickHouse/pull/124568) ([Groene AI](https://github.com/groeneai)).
* Fixed a skip index recording the wrong expression type when `ALTER TABLE` ran in a session whose settings change how that expression resolves. `toString(v)` over a `Dynamic` column is `Nullable(String)` under `cast_keep_nullable` and `String` at the server baseline, so such an `ALTER` stored `Nullable(String)` while the writers resolved `String`, and the next index rebuild failed an internal type assertion. [#119799](https://github.com/ClickHouse/ClickHouse/pull/119799) ([Groene AI](https://github.com/groeneai)).
* Fixed `hasPhrase` rejecting `FixedString` input for some tokenizers, such as `icu` and `splitByRegexp('\W+')`. Closes [#123426](https://github.com/ClickHouse/ClickHouse/issues/123426). [#123585](https://github.com/ClickHouse/ClickHouse/pull/123585) ([Elmi Ahmadov](https://github.com/ahmadov)).
* Fixed statistics about the number of selected rows in trivial `count` queries answered from a text index. [#125380](https://github.com/ClickHouse/ClickHouse/pull/125380) ([Anton Popov](https://github.com/CurtizJ)).
* `ALTER TABLE ... RESET SETTING auto_statistics_types` now rebuilds the automatic column statistics from the default types immediately. Previously the table kept the statistics of the old setting value until the server was restarted, so `system.columns` and the statistics written into new parts disagreed with the table definition. [#123599](https://github.com/ClickHouse/ClickHouse/pull/123599) ([Rion Bora](https://github.com/GoldenEmperor1177)).
* Fix `basic` statistics of parts written by 26.6 or 26.7: after `ALTER TABLE ... UPDATE` or a lightweight `DELETE`, non-`Nullable` columns reported a default-value count of 0, which made selectivity estimates wrong. Query results were not affected. To repair parts that are already affected, run `ALTER TABLE ... MATERIALIZE STATISTICS ALL`. [#123536](https://github.com/ClickHouse/ClickHouse/pull/123536) ([Samuel Krempaský](https://github.com/NIKTONIKTO717)).
* Fixed `indexHint` with a `Nothing`-typed argument, such as `indexHint(assumeNotNull(materialize(NULL)))`, which threw `Cannot create non-empty column with type Nothing` instead of only narrowing the read. [#117635](https://github.com/ClickHouse/ClickHouse/pull/117635) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed `arrayReduce` over a non-deterministic aggregate such as an unseeded `groupArraySample` being treated as deterministic, which pushed a `HAVING` predicate below the aggregation and collapsed per-row draws into a single one. [#118971](https://github.com/ClickHouse/ClickHouse/pull/118971) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed an internal error when two `*` matchers whose column transformers differ in kind at the same position are compared, for example two lambdas sharing an alias with bodies `* EXCEPT (a)` and `* REPLACE (1 AS a)`. Such a query now reports `MULTIPLE_EXPRESSIONS_FOR_ALIAS`. [#120234](https://github.com/ClickHouse/ClickHouse/pull/120234) ([Groene AI](https://github.com/groeneai)).
* Fixed a `LOGICAL_ERROR` (`Can't set alias of ... of QualifiedAsterisk`) when a column transformer that assigns a name, such as `APPLY` with a name prefix or `REPLACE`, is applied to an expression that expands to an asterisk or a `COLUMNS` matcher. Such queries now return a clear `BAD_ARGUMENTS` exception. [#109223](https://github.com/ClickHouse/ClickHouse/pull/109223) ([Groene AI](https://github.com/groeneai)).
* Fixed `NOT_FOUND_COLUMN_IN_BLOCK` for `LIMIT BY` on an injective function of a `GROUP BY` key, such as `GROUP BY toString(c0) LIMIT 1 BY toString(c0)`. [#120070](https://github.com/ClickHouse/ClickHouse/pull/120070) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed `LOGICAL_ERROR: Incorrect table expression` when `EXPLAIN AST optimize = 1` or `EXPLAIN SYNTAX` reads from the experimental table function `eval`. [#121272](https://github.com/ClickHouse/ClickHouse/pull/121272) ([Groene AI](https://github.com/groeneai)).
* A non-finite `FROM`, `TO`, `STEP`, or `STALENESS` value in `ORDER BY ... WITH FILL` (`nan`, `inf`, or `-inf`) is now rejected with `INVALID_WITH_FILL_EXPRESSION`. Previously such a value either made the query generate fill rows endlessly (`TO nan`, `TO inf` ascending, `TO -inf` descending, and the same values for `STALENESS`) or produced a wrong result: a non-finite `FROM` emitted the bound itself as a row and dropped the fill rows that `TO` asked for, while a non-finite `STEP`, or a `TO` bound the fill runs away from, returned the rows unfilled. Pass a finite value instead, or omit it. [#118434](https://github.com/ClickHouse/ClickHouse/pull/118434) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed exception `Trying to compare constants of incompatible types` for a query with an `IN` list over a column of a table that has a `CONSTRAINT ... ASSUME`, when both `convert_query_to_cnf` and `optimize_using_constraints` are enabled. [#118278](https://github.com/ClickHouse/ClickHouse/pull/118278) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* `EXPLAIN AST` no longer throws when a `Backup` locator name looks like a `COLUMNS` matcher. [#122870](https://github.com/ClickHouse/ClickHouse/pull/122870) ([Groene AI](https://github.com/groeneai)).
* `ORDER BY ... WITH FILL ... INTERPOLATE` of the fill column itself is now rejected over a `Distributed` table as well, with the same exception a local table already reported, instead of returning rows whose fill column was overwritten by the interpolated expression. [#118304](https://github.com/ClickHouse/ClickHouse/pull/118304) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fix `NOT_FOUND_COLUMN_IN_BLOCK` when a query over the `filesystem` table function combines `indexHint` with an ordinary condition on the same column. [#118671](https://github.com/ClickHouse/ClickHouse/pull/118671) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed wrong results from `optimize_using_constraints` with a `CONSTRAINT ... ASSUME NOT (...)`: a negated comparison could be added to the constraints graph as if it were positive, making predicates such as `a < b` appear always true and `a >= b` always false. [#121255](https://github.com/ClickHouse/ClickHouse/pull/121255) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* A `HAVING` clause referencing a `SELECT` alias whose quoted name contains a dot, as in ``SELECT sum(t1.c1) AS `t1.c1` FROM t1 AS t1 HAVING `t1.c1` > 0``, is no longer rejected with `NOT_AN_AGGREGATE`. The identifier resolution cache conflated that quoted one-part name with the qualified `t1`.`c1`, which could also return a wrong result instead of an error when both spellings met in one query. Default settings were affected from 26.6, where `enable_identifier_resolve_cache` became enabled by default. [#122017](https://github.com/ClickHouse/ClickHouse/pull/122017) ([Groene AI](https://github.com/groeneai)).
* The analyzer now rejects `arrayJoin` in `INTERPOLATE` and in `HAVING` with `WITH TOTALS`. Before, `INTERPOLATE` used only the first array element, and `HAVING` failed only during execution. [#123538](https://github.com/ClickHouse/ClickHouse/pull/123538) ([Yarik Briukhovetskyi](https://github.com/yariks5s)).
* Fixed `NOT_FOUND_COLUMN_IN_BLOCK` when a comparison of single-element tuples whose elements are tuples, such as `tuple((a, b)) = tuple((c, d))`, is part of an alias used in `GROUP BY` and also in `ORDER BY`, `HAVING`, or `WHERE`. Such comparisons are now rewritten completely, so `WHERE tuple(tuple(x)) = tuple(tuple(y))` over a `JOIN` no longer returns rows where `x` and `y` are both `NULL`, the same as `WHERE tuple(x) = tuple(y)`. [#124546](https://github.com/ClickHouse/ClickHouse/pull/124546) ([Groene AI](https://github.com/groeneai)).
* Fixed the exception `Not-ready Set is passed as the second argument for function 'in'` when the `additional_result_filter` setting contains an `IN` subquery. Such a query now applies the filter instead of failing. [#117719](https://github.com/ClickHouse/ClickHouse/pull/117719) ([Groene AI](https://github.com/groeneai)).
* A nested correlated subquery that cannot be decorrelated now reports `NOT_IMPLEMENTED` instead of the internal error `Cannot find column ... in actions DAG input`. [#118317](https://github.com/ClickHouse/ClickHouse/pull/118317) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed `NOT_IMPLEMENTED` for a correlated subquery in the `SELECT` list of a query that has a `WHERE`, when the correlated column is not also selected, and `NOT_FOUND_COLUMN_IN_BLOCK` for a correlated subquery in `HAVING` of a query with `WITH TOTALS`. [#118402](https://github.com/ClickHouse/ClickHouse/pull/118402) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed `NOT_FOUND_COLUMN_IN_BLOCK` for a correlated subquery that reads a tuple element of an outer column by position (`o.p.1`), and for the same shape on the left of `IN (subquery)` under `rewrite_in_to_join`. [#118287](https://github.com/ClickHouse/ClickHouse/pull/118287) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed `Cannot evaluate correlated scalar subquery` for a query that uses one correlated scalar subquery twice in the same expression, for example in both branches of `if(1 = 1, ..., ...)`. [#118321](https://github.com/ClickHouse/ClickHouse/pull/118321) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed an out-of-bounds read when finalizing a crafted `analysisOfVariance` aggregate state whose internal arrays have mismatched lengths. [#107860](https://github.com/ClickHouse/ClickHouse/pull/107860) ([uwezkhan](https://github.com/uwezkhan)).
* Fixed an out-of-bounds read of the parsed pattern in `sequenceMatch`, `sequenceCount`, and `sequenceMatchEvents`. When the trailing part of a pattern consisted only of actions that a zero-length match satisfies (`.*` and `(?t...)` conditions), the matcher read one element past the end of its action list, so `sequenceMatch` and `sequenceCount` could return `0` for a pattern that does match. [#119871](https://github.com/ClickHouse/ClickHouse/pull/119871) ([Groene AI](https://github.com/groeneai)).
* Fix an out-of-bounds read when deserializing a `uniqTheta` state shorter than 24 bytes, for instance from `CAST( AS AggregateFunction(uniqTheta, ...))`. [#119598](https://github.com/ClickHouse/ClickHouse/pull/119598) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed `regr_r2` returning `1` instead of `nan` when the data contains a NaN or an infinity. `regr_sxx` and `regr_syy` returned `0` in the same case. [#123249](https://github.com/ClickHouse/ClickHouse/pull/123249) ([mosya415](https://github.com/mosya415)).
* Reject malformed serialized `groupBitmap` states with `INCORRECT_DATA` instead of failing later during bitmap operations. [#124049](https://github.com/ClickHouse/ClickHouse/pull/124049) ([Elmi Ahmadov](https://github.com/ahmadov)).
* Fixed wrong results in the `largestTriangleThreeBuckets` aggregate function for `DateTime64` arguments close to the type's upper bound: the maximum `DateTime64(9)` value was returned as `1677-09-21 00:12:43.145224192`. Such values are now saturated instead of wrapping, and a deserialized state whose `Date`, `Date32`, `DateTime` or `DateTime64` coordinates are out of range or fractional is rejected with an error. [#120284](https://github.com/ClickHouse/ClickHouse/pull/120284) ([Groene AI](https://github.com/groeneai)).
* Fix a wrong result, or an exception in debug builds, when `optimize_aggregators_of_group_by_keys` eliminated `any`, `min` or `max` of a `GROUPING SETS` key with `group_by_use_nulls`. [#125575](https://github.com/ClickHouse/ClickHouse/pull/125575) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed several URL-parsing bugs in `domainRFC` and `portRFC` for bracketed IPv6 hosts: an embedded IPv4 tail (for example `[::ffff:192.168.0.1]`) was rejected, non-IPv6 bracket contents and garbage following the closing bracket were silently accepted, and userinfo state could leak into host validation. Also fixed `domainRFC` and `portRFC` resolving the wrong host when a URL's userinfo contains more than one `@`, rejected a host starting with a literal dot in `domain` and `domainRFC`, and fixed `firstSignificantSubdomainRFC` and `cutToFirstSignificantSubdomainRFC` returning a bogus subdomain for a bracketed IPv6 host instead of an empty result. [#118979](https://github.com/ClickHouse/ClickHouse/pull/118979) ([Luís Lizardo](https://github.com/lizardoluis)).
* Fixed `IPv4StringToNum`, `IPv6StringToNum`, `isIPAddressInRange`, `parseDateTime`, `parseDateTime64`, `parseDateTimeInJodaSyntax`, `parseTimeDelta`, `parseReadableSize`, `toModifiedJulianDay`, `JSONMergePatch`, `stringToH3`, and the H3 index functions throwing an exception on entirely valid `LowCardinality` data. [#117359](https://github.com/ClickHouse/ClickHouse/pull/117359) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed the exception `Cannot convert out of range floating point value to integer type` when a logical function (`and`, `or`, `xor`) receives a constant floating point argument outside `{0, 1}`, such as `SELECT 1 OR 2.0`. [#117965](https://github.com/ClickHouse/ClickHouse/pull/117965) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* `timeSeriesRange` and `timeSeriesFromGrid` now throw `ARGUMENT_OUT_OF_BOUND` when the requested number of points would exceed `function_range_max_elements_in_block`, matching the behavior of `range`. Previously an unbounded request would run for tens of seconds and allocate hundreds of gigabytes before hitting the memory limit. [#121056](https://github.com/ClickHouse/ClickHouse/pull/121056) ([Ilya Yatsishin](https://github.com/qoega)).
* `bitShiftLeft`, `bitShiftRight`, `bitRotateLeft`, and `bitRotateRight` no longer answer, once the expression is compiled, for the arguments their interpreted implementation rejects: a big-integer or negative shift amount. [#118716](https://github.com/ClickHouse/ClickHouse/pull/118716) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fix `mapPopulateSeries` keeping the wrong value when duplicate keys are present. [#119832](https://github.com/ClickHouse/ClickHouse/pull/119832) ([Minh Vu](https://github.com/fallintoplace)).
* Fix `format` handling of escaped braces around replacement fields. [#120704](https://github.com/ClickHouse/ClickHouse/pull/120704) ([Minh Vu](https://github.com/fallintoplace)).
* `jaroSimilarity` and `jaroWinklerSimilarity` now return `0` when one input is empty. [#119710](https://github.com/ClickHouse/ClickHouse/pull/119710) ([Minh Vu](https://github.com/fallintoplace)).
* Fixed `plus` and `minus` over an array of dates and an array of tuples holding `NULL`, for example `toString([toDateTime64(1, 3)] + [(2, NULL)])`, and the exception `ColumnTuple cannot have ColumnConst as its element` when adding a constant interval to a non-constant interval of another unit, for example `toIntervalDay(number) + INTERVAL 1 HOUR`. [#122451](https://github.com/ClickHouse/ClickHouse/pull/122451) ([Groene AI](https://github.com/groeneai)).
* Fixed `timeSeriesCopyTags` and `timeSeriesCopyTag` when both group arguments are constant. They returned a single row regardless of the number of input rows, so such a call over several rows failed with `Invalid number of rows in Chunk` (`LOGICAL_ERROR`), and a single-row query printed an extra row in `clickhouse-client`. [#122990](https://github.com/ClickHouse/ClickHouse/pull/122990) ([Groene AI](https://github.com/groeneai)).
* Fixed `if` and `CASE` over tuples failing with `ColumnTuple cannot have ColumnConst as its element` when an element is `NULL` in both branches, for example `if(number = 0, (1, NULL), (number, NULL))`. [#123268](https://github.com/ClickHouse/ClickHouse/pull/123268) ([Groene AI](https://github.com/groeneai)).
* Fixed `geometryIntersectCartesian` and `geometryIntersectSpherical` returning an arbitrary result (usually `1`) for an empty `LineString`, or a `MultiLineString` with an empty element, against a `Ring`, `Polygon`, or `MultiPolygon`. For such a `MultiLineString`, `polygonsDistanceCartesian` and `polygonsDistanceSpherical` could return `0`. [#124101](https://github.com/ClickHouse/ClickHouse/pull/124101) ([Groene AI](https://github.com/groeneai)).
* Fixed an infinite, uncancellable loop in functions `hop`, `hopStart` and `hopEnd` when subtracting the hop interval does not move the window end, for example `hopEnd(toDateTime(0, 'UTC'), toIntervalQuarter(413844), toIntervalQuarter(413844))`, where the date saturates at the calendar limit. Such arguments now throw the `Time overflow` error. [#124570](https://github.com/ClickHouse/ClickHouse/pull/124570) ([Groene AI](https://github.com/groeneai)).
* Fixed the result type of `randConstant`, `rand`, `rand32`, `rand64`, `randCanonical`, `generateUUIDv4`, `generateUUIDv7` and `generateULID` when their optional ignored argument has type `Nothing`: they declared `Nothing` rather than their documented type. `randConstant` with more than one argument also raised `LOGICAL_ERROR` during query analysis instead of reporting the wrong argument count. [#116072](https://github.com/ClickHouse/ClickHouse/pull/116072) ([Groene AI](https://github.com/groeneai)).
* `KILL QUERY` and `max_execution_time` (including `timeout_overflow_mode = 'break'`) now stop AI functions in the middle of a block, instead of only after all requests for the block have finished. [#125698](https://github.com/ClickHouse/ClickHouse/pull/125698) ([George Larionov](https://github.com/george-larionov)).
* Fixed the exception `Provided time zone must be non-empty` when the time zone argument of `formatDateTime`, `formatDateTimeInJodaSyntax`, `fromUnixTimestamp`, or `fromUnixTimestampInJodaSyntax` is a `LowCardinality` column. [#117006](https://github.com/ClickHouse/ClickHouse/pull/117006) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed `toWeek` and `toYearWeek` with mode `8` returning week `135` for `Date32` and `DateTime64` values in the year 1900 and earlier. The wrong values also made the primary key analysis drop matching rows for predicates on `toYearWeek(key, 8)`. [#117694](https://github.com/ClickHouse/ClickHouse/pull/117694) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* An out-of-range integer constant in an `IN` set for a `DateTime64` or `Time64` column no longer wraps to a negative timestamp and matches an unrelated row. [#118656](https://github.com/ClickHouse/ClickHouse/pull/118656) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed `makeDate` and `makeDate32` with two arguments to accept day 366 in leap years. [#119363](https://github.com/ClickHouse/ClickHouse/pull/119363) ([Minh Vu](https://github.com/fallintoplace)).
* Fixed `CAST` of an empty container to a container of `Variant` or `Dynamic`, which was rejected with `Cannot convert type Nothing to Variant(...)` or `Variant type should have at least one nested type`. This also fixes a query returning an empty `Array(Variant(...))` failing once part of it runs on a secondary server, where the folded constant is re-rendered as a `_CAST` of an empty container. [#118038](https://github.com/ClickHouse/ClickHouse/pull/118038) ([Groene AI](https://github.com/groeneai)).
* Fixed `TYPE_MISMATCH` (`CAST AS Array can only be performed between same-dimensional array types`) when casting an `Array(Map(...))` to an array whose element type contains the `Map` inside a `Variant`, or to `Array(Dynamic)`, `Array(JSON)`, or `Array(String)`. [#120948](https://github.com/ClickHouse/ClickHouse/pull/120948) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed `arraySlice` and `arrayElement` on a `QBit` column replicated by `ARRAY JOIN` or a `JOIN`: debug builds raised `LOGICAL_ERROR`, while release builds could return wrong results. [#120224](https://github.com/ClickHouse/ClickHouse/pull/120224) ([Groene AI](https://github.com/groeneai)).
* Fixed a function over a `Dynamic` column reporting `LOGICAL_ERROR` when an unrelated exception, such as `MEMORY_LIMIT_EXCEEDED`, was raised while converting the nested result to the declared result type. Such exceptions now keep their own error code, message, and stack instead of being reported as an internal error. [#121280](https://github.com/ClickHouse/ClickHouse/pull/121280) ([Groene AI](https://github.com/groeneai)).
* The `JSON` type and the `JSON*` functions now also accept `String` values holding bytes that are not valid UTF-8 on builds where simdjson uses its scalar `fallback` backend (`s390x`, `riscv64` and `loongarch64` without RVV / LSX, `amd64compat` on CPUs without SSE4.2 or PCLMULQDQ), which previously failed with `INCORRECT_DATA`. [#123945](https://github.com/ClickHouse/ClickHouse/pull/123945) ([Groene AI](https://github.com/groeneai)).
* Fixed an exception when a function applied to a `Dynamic` column returns a result of the `Nothing` type, for example `arrayElement` on an empty array literal. Such queries now return `NULL` for every row instead of failing with `std::out_of_range` or `Variant type should have at least one nested type`. [#115982](https://github.com/ClickHouse/ClickHouse/pull/115982) ([Groene AI](https://github.com/groeneai)).
* Fixed `CAST AS QBit can only be performed from String, Array or another QBit` (and `Unsupported types for IN`) errors when a query with a `QBit` constant, such as `WHERE q = CAST([1, 2], 'QBit(Float32, 2)')` or `q IN (...)`, runs over `remote`, a `Distributed` table, or parallel replicas. [#125038](https://github.com/ClickHouse/ClickHouse/pull/125038) ([Groene AI](https://github.com/groeneai)).
* Fix `LOGICAL_ERROR: Column identifier ... is already registered` when `analyzer_compatibility_join_using_top_level_identifier = 1` and a `JOIN ... USING` key resolves to an `ALIAS` column of a table function such as `merge` or `remote`. `NATURAL JOIN` now also matches `ALIAS` columns of a table function, as it already did for a table, and no longer takes a non-selectable `EPHEMERAL` column as a join key on either side; with no other shared name it behaves as a `CROSS JOIN` rather than failing with `Code: 16`. [#118734](https://github.com/ClickHouse/ClickHouse/pull/118734) ([Groene AI](https://github.com/groeneai)).
* With `analyzer_compatibility_join_using_top_level_identifier = 1`, a `JOIN USING` identifier of the outermost `JOIN` is now also resolved from an alias defined in the `WITH` clause or in another clause of the query, not only from the `SELECT` list, and duplicated aliases with identical definitions no longer prevent the resolution; an inner `JOIN` of a query with several joins resolves it from its left table, as the old analyzer did. This fixes `UNKNOWN_IDENTIFIER` for such queries and a `USING clause expected identifier` error when an inner `USING` join is placed below an aliased outermost `USING` key. Closes [#121401](https://github.com/ClickHouse/ClickHouse/issues/121401). [#121975](https://github.com/ClickHouse/ClickHouse/pull/121975) ([Vladimir Cherkasov](https://github.com/vdimir)). [#123103](https://github.com/ClickHouse/ClickHouse/pull/123103) ([Vladimir Cherkasov](https://github.com/vdimir)).
* Fixed a null dereference while formatting the `LOGICAL_ERROR` for a `USING` column with no expression; the query now reports the column name instead. Closes [#123292](https://github.com/ClickHouse/ClickHouse/issues/123292). [#123296](https://github.com/ClickHouse/ClickHouse/pull/123296) ([Raúl Marín](https://github.com/Algunenano)).
* Fix the AST predicate push-down into distributed subqueries treating non-deterministic `EXECUTABLE` and `WASM` user-defined functions as deterministic. It pushed a predicate over such a function's result to the shard, which evaluated the function again. [#119865](https://github.com/ClickHouse/ClickHouse/pull/119865) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed a `LOGICAL_ERROR` (`Initiator received more initial requests than there are replicas`, or `Duplicate announcement received for replica number N`) when a `mergeTreeAnalyzeIndexes` predicate contained a correlated subquery and parallel replicas were enabled. [#119860](https://github.com/ClickHouse/ClickHouse/pull/119860) ([Groene AI](https://github.com/groeneai)).
* Parallel replicas are kept enabled for cluster engines when `automatic_parallel_replicas_mode` is set. Also, from now on, with `enable_parallel_replicas = 2` parallel replicas are forced and the automatic mode is not applied. [#122306](https://github.com/ClickHouse/ClickHouse/pull/122306) ([Nikita Taranov](https://github.com/nickitat)).
* Fixed `NO_SUCH_DATA_PART` in a `make_distributed_plan` bucketed read when a worker's own index analysis prunes a part that the coordinator selected, for example with `use_index_for_in_with_subqueries = 0` and an `IN (subquery)` predicate. Such parts are now skipped instead of producing a false "part ... selected by the coordinator is not available on this replica" error. Added `DistributedPlanWorkerPartsReceived`, `DistributedPlanWorkerPartsScanned`, and `DistributedPlanWorkerPartsPruned` profile events. [#115514](https://github.com/ClickHouse/ClickHouse/pull/115514) ([Groene AI](https://github.com/groeneai)).
* A serialized query plan carrying `max_block_size = 0` is now rejected when it is read, instead of constructing steps with a zero block size that could make the receiving server hang. [#120606](https://github.com/ClickHouse/ClickHouse/pull/120606) ([Nihal Z. Miaji](https://github.com/nihalzp)).
* Fixed a case where `make_distributed_plan` fell back to local execution for the outer query but still built inner `IN` subquery sets as distributed plans inside views, scalar subqueries, `GLOBAL IN` subqueries, `Distributed` shard plans, materialized CTEs, and `TimeSeries` reads. [#119986](https://github.com/ClickHouse/ClickHouse/pull/119986) ([Antonio Filipovic](https://github.com/antoniofilipovic)).
* `make_distributed_plan` queries that resolve dictionary functions, `joinGet`, or `MergeTree` column defaults only on the initiator now fall back to local execution, avoiding worker-side `Dictionary (...) not found` failures and similar unresolved-reference errors. [#121198](https://github.com/ClickHouse/ClickHouse/pull/121198) ([Antonio Filipovic](https://github.com/antoniofilipovic)). [#121567](https://github.com/ClickHouse/ClickHouse/pull/121567) ([Antonio Filipovic](https://github.com/antoniofilipovic)).
* A cancelled or failed distributed query with `make_distributed_plan = 1` no longer waits for the handshake timeout of a streaming exchange whose producer does not answer. Closes [#122395](https://github.com/ClickHouse/ClickHouse/issues/122395). [#122422](https://github.com/ClickHouse/ClickHouse/pull/122422) ([Groene AI](https://github.com/groeneai)).
* Fixed distributed query plans losing a `LIMIT` early-stop signal on an in-memory exchange when a port closed concurrently. Such queries could keep reading whole inputs or wait for exchange streams after the `LIMIT` was already satisfied. [#122453](https://github.com/ClickHouse/ClickHouse/pull/122453) ([Groene AI](https://github.com/groeneai)).
* Fixed the `LOGICAL_ERROR` `Reading from materialized CTE '...' before its materialization completed - DelayedPortsProcessor gate is missing in the query plan` on a table read with more than one stream, raised by a lightweight `UPDATE` or `DELETE` whose predicate passes an `IN` subquery that defines a `MATERIALIZED` CTE to a function such as `ignore`, and by a lightweight `UPDATE`/`DELETE` or a `SELECT` when an `IN` or other set subquery defines a `MATERIALIZED` CTE that two other `MATERIALIZED` CTEs of that subquery read. [#119715](https://github.com/ClickHouse/ClickHouse/pull/119715) ([Alexey Milovidov](https://github.com/alexey-milovidov)). [#121010](https://github.com/ClickHouse/ClickHouse/pull/121010) ([Groene AI](https://github.com/groeneai)).
* Fixed `NOT_FOUND_COLUMN_IN_BLOCK` when a predicate on a `Merge` table's `_table` or `_database` virtual column is wrapped in `indexHint`. [#117612](https://github.com/ClickHouse/ClickHouse/pull/117612) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fix ``Column `__array_join_exp_1` not found in table`` for `ARRAY JOIN` with a filter on the array-joined column over a `Merge` table whose child is a `Distributed` table. [#119307](https://github.com/ClickHouse/ClickHouse/pull/119307) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed a `LOGICAL_ERROR` `Unexpected return type` when reading a `Merge` table whose underlying table is another `Merge` table with different column types, with `optimize_prewhere_after_pushdown = 1` and `move_all_conditions_to_prewhere = 0`. [#124037](https://github.com/ClickHouse/ClickHouse/pull/124037) ([Groene AI](https://github.com/groeneai)).
* Fixed `TRUNCATE TABLE` failing with `DEADLOCK_AVOIDED`, leaving the data in place, while the table is being read concurrently, for a `MergeTree` table in a database with `lazy_load_tables = 1` and for an `Alias` table whose target is a `MergeTree` table. [#119105](https://github.com/ClickHouse/ClickHouse/pull/119105) ([Groene AI](https://github.com/groeneai)). [#121703](https://github.com/ClickHouse/ClickHouse/pull/121703) ([Groene AI](https://github.com/groeneai)). [#113634](https://github.com/ClickHouse/ClickHouse/pull/113634) ([Groene AI](https://github.com/groeneai)).
* `TRUNCATE ALL TABLES FROM` and `TRUNCATE TABLES FROM ... LIKE ...` now skip `Alias` tables, which hold no data of their own. Previously such a statement could fail with `LOGICAL_ERROR`, truncate a target in another database, or fail when the alias target was missing. [#121134](https://github.com/ClickHouse/ClickHouse/pull/121134) ([Groene AI](https://github.com/groeneai)).
* Fix `SHOW CREATE TABLE`, `system.tables.create_table_query`, and metadata files of `Alias` tables including a column list, which is invalid for `ENGINE = Alias` and goes stale when the target table changes. [#115141](https://github.com/ClickHouse/ClickHouse/pull/115141) ([Enric Calabuig](https://github.com/eclbg)).
* Fixed a logical error when a non-`APPEND` refreshable materialized view was created in a non-`Atomic`/`Replicated` database via a full-definition `ATTACH`, or via a `RESTORE` of a view that had a UUID into such a database. `CREATE` already rejected this combination; `ATTACH` and `RESTORE` bypassed the check and produced a broken view with no UUID. Backups of views that never had a UUID stay restorable, and refresh now fails cleanly instead of aborting in debug and sanitizer builds. [#111928](https://github.com/ClickHouse/ClickHouse/pull/111928) ([Groene AI](https://github.com/groeneai)).
* Fixed `SELECT count()` never terminating, or returning an invented row count, on an `Avro` file with a corrupted block header. The bundled `ClickHouse/avro` now rejects a block row count larger than its payload can hold wherever it can derive a lower bound for the schema, so `SELECT count()` over `snappy`-compressed `Avro` files still uses the block header row count instead of decoding every row. [#116156](https://github.com/ClickHouse/ClickHouse/pull/116156) ([Groene AI](https://github.com/groeneai)). [#121211](https://github.com/ClickHouse/ClickHouse/pull/121211) ([Groene AI](https://github.com/groeneai)).
* Fix `rows_read` and `rows_before_limit_at_least` in the statistics of the `JSON` and `XML` output formats being reported as 0 or too small when a query with `LIMIT` reads from remote servers (parallel replicas or the `remote` table function), because the output format could be finalized before the remaining progress was drained from the connections. Also fix a query broken off by `timeout_overflow_mode = 'break'` answering with a truncated response - or with no response body at all - instead of a complete document with the statistics, and, over the native protocol, dropping the rows that had already been produced when the time limit was checked. [#118000](https://github.com/ClickHouse/ClickHouse/pull/118000) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fix `CANNOT_SEEK_THROUGH_FILE` when reading a subset of columns from an `ArrowStream` through a pipe, for example with `clickhouse local` reading stdin. [#125689](https://github.com/ClickHouse/ClickHouse/pull/125689) ([Mishalski](https://github.com/wywywywycloud)).
* Fixed `FileLog` on macOS re-reading a file from offset `0` when it is renamed during a directory rescan. [#122448](https://github.com/ClickHouse/ClickHouse/pull/122448) ([Groene AI](https://github.com/groeneai)).
* Fixed `FileLog` silently skipping the first rows of a file moved into the watched directory from elsewhere (for example a staging file renamed into place) when that file got the inode of a file just deleted from the directory. Such a file is now read from the beginning. [#123593](https://github.com/ClickHouse/ClickHouse/pull/123593) ([Groene AI](https://github.com/groeneai)).
* A `FileLog` file that cannot be opened (removed, a symlink whose target was removed, not readable by the server) no longer stops the table: the other files keep being consumed, and it is skipped, logged once and retried until it can be opened while the table is loaded, unless the directory reports that it was removed, renamed or replaced. With the default `handle_error_mode`, a record that cannot be parsed is now logged and skipped while the table streams into materialized views, instead of failing the whole insert together with the rows read from the other files; a direct `SELECT` still throws. [#123595](https://github.com/ClickHouse/ClickHouse/pull/123595) ([Groene AI](https://github.com/groeneai)).
* Fixed the warning about a setting duplicated in the definition of an `S3Queue` or `AzureQueue` table, which said that the first value is used while the table uses the last one. [#124916](https://github.com/ClickHouse/ClickHouse/pull/124916) ([Vadim Lopatin](https://github.com/buggins)).
* Fix the `KafkaConsumersWithAssignment` metric drifting negative: it was decremented twice for every consumer-group rebalance. [#113919](https://github.com/ClickHouse/ClickHouse/pull/113919) ([kalavt](https://github.com/kalavt)).
* Fixed the histogram metric `keeper_read_wait_for_write_time_milliseconds` and the OpenTelemetry span `keeper.read.wait_for_write` always reading zero and never being emitted when `use_new_dispatcher` is enabled, which is the default. [#115252](https://github.com/ClickHouse/ClickHouse/pull/115252) ([Groene AI](https://github.com/groeneai)).
* `TestKeeper` no longer treats nodes that only share a name prefix as descendants: `removeRecursive` of `/q` keeps `/q2`, and `listRecursive` and `listWithOptions` of `/q` return its children when a sibling such as `/q-x` exists. [#122769](https://github.com/ClickHouse/ClickHouse/pull/122769) ([Groene AI](https://github.com/groeneai)).
* Fixed Keeper `ProfileEvents` `KeeperPacketsSent`, `KeeperPacketsReceived`, `KeeperRequestTotal`, `KeeperRequestTotalWithSubrequests`, and `KeeperLatency` being counted twice. After upgrading, these counters grow at half the previous rate. [#122811](https://github.com/ClickHouse/ClickHouse/pull/122811) ([myeongjun](https://github.com/myeongjjun)).
* Fix unbounded recursion when decoding a deeply nested value inside a binary-encoded type, for example an `AggregateFunction` parameter in a `Dynamic` value read from `RowBinary` or `Native`. [#122667](https://github.com/ClickHouse/ClickHouse/pull/122667) ([Pavel Kruglov](https://github.com/Avogar)).
* Fixed `SHOW COLUMNS` failing with `Cannot parse string 'Decimal' as Int8` (`CANNOT_PARSE_TEXT`) for `Nullable(Decimal(P, S))` columns when the connection is made through the MySQL wire protocol. [#75694](https://github.com/ClickHouse/ClickHouse/pull/75694) ([ultrabig](https://github.com/ultrabig)).
* Fix a logical error `Cannot write to canceled buffer` in the PostgreSQL wire protocol handler when a client disconnects while the server is still sending the result of a query. [#118369](https://github.com/ClickHouse/ClickHouse/pull/118369) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed a signed overflow in the workload throttler that made `system.scheduler.throttling_us` report a negative value for a workload whose `max_bytes_per_second`, `max_queries_per_second`, or `max_cpus` is small enough to postpone a request for longer than a year. Such a postponement is now saturated at one year. [#113697](https://github.com/ClickHouse/ClickHouse/pull/113697) ([Groene AI](https://github.com/groeneai)).
* Fixed the `throughput` column of `system.scheduler` reporting a small fraction of the real value (about 0.05x initially and 0.3x after 4 seconds) for about 20 seconds after a scheduling node is created, for example right after server start or `CREATE WORKLOAD`. The client's CPU usage indicator, which uses the same `EventRateMeter`, was affected the same way on its first samples. Closes [#121962](https://github.com/ClickHouse/ClickHouse/issues/121962). [#122006](https://github.com/ClickHouse/ClickHouse/pull/122006) ([Groene AI](https://github.com/groeneai)).
* Fix a logical error `Cannot add step Limit to QueryPlan because it has incompatible header with root step Sorting` when a vector search query with `vector_search_with_rescoring = 0` was executed with the experimental `make_distributed_plan` setting. [#114457](https://github.com/ClickHouse/ClickHouse/pull/114457) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fix `assignCentroid(vec, 'dict')` with an unqualified dictionary name over a `Distributed` table, `cluster`/`remote`, or parallel replicas. Remote shards and replicas resolved the name in their own `default` database, so the query failed with `Dictionary (dict) not found` or silently used a dictionary with the same name from `default`. The name is now resolved in the current database of the initiator, as for `dictGet`. [#123711](https://github.com/ClickHouse/ClickHouse/pull/123711) ([Groene AI](https://github.com/groeneai)).
* Fixed `UNDROP TABLE` failing with `LOGICAL_ERROR` (`Failed to get metadata path from database`) instead of `UNKNOWN_TABLE` when the target database engine stores no table metadata on disk, for example a `Memory` database that reused the name of a dropped `Atomic` one, or the default database of `clickhouse-local`. [#120945](https://github.com/ClickHouse/ClickHouse/pull/120945) ([Groene AI](https://github.com/groeneai)).
* Fixed `ALTER TABLE ... MODIFY SETTING name = DEFAULT` skipping the checks an engine makes on a setting reset. [#119475](https://github.com/ClickHouse/ClickHouse/pull/119475) ([Raúl Marín](https://github.com/Algunenano)).
* Fixed `TRUNCATE ALL TABLES FROM ` failing with `NOT_IMPLEMENTED` for the whole database when it held a table whose engine stores no rows of its own, such as `Merge`, `Null`, `GenerateRandom`, `Executable`, `ExecutablePool`, `FuzzQuery`, `FuzzJSON`, or `URL`. Such tables are now skipped, as views and dictionaries already were. [#121248](https://github.com/ClickHouse/ClickHouse/pull/121248) ([Groene AI](https://github.com/groeneai)).
* A table created without a column list over a source that carries a per-column `TTL` no longer inherits that `TTL` when its own engine does not support one, such as `Merge`, `Buffer`, `Distributed`, or `Remote`. [#121335](https://github.com/ClickHouse/ClickHouse/pull/121335) ([Groene AI](https://github.com/groeneai)).
* Fixed the logical error `Cannot find column in ColumnsDescription` when a single `ALTER` statement on a materialized view applies `COMMENT COLUMN` or `MODIFY COLUMN ... COMMENT` after a `MODIFY QUERY` whose new query no longer produces that column. Such a statement now reports the missing column instead of aborting in debug and sanitizer builds. [#121469](https://github.com/ClickHouse/ClickHouse/pull/121469) ([Groene AI](https://github.com/groeneai)).
* Fix `LOGICAL_ERROR` `Cannot capture column N because it has incompatible type` when a materialized view with a lambda over an `Array(Tuple(...))` column receives a block while the source table's column type is being changed by `ALTER TABLE ... MODIFY COLUMN`. [#122345](https://github.com/ClickHouse/ClickHouse/pull/122345) ([Jimmy Aguilar Mena](https://github.com/Ergus)). [#123514](https://github.com/ClickHouse/ClickHouse/pull/123514) ([Jimmy Aguilar Mena](https://github.com/Ergus)). [#124740](https://github.com/ClickHouse/ClickHouse/pull/124740) ([Groene AI](https://github.com/groeneai)).
* In a `Memory` database, the name of a detached table, view or dictionary is now reserved, as in `Atomic` databases. A statement that would create a new object under it (`CREATE`, `CREATE OR REPLACE [MATERIALIZED] VIEW`, or `ATTACH` with a full definition) fails with `TABLE_ALREADY_EXISTS`, `IF NOT EXISTS` makes it a no-op, and a short `ATTACH` restores the detached object. Previously these statements were accepted, but `SHOW CREATE TABLE` and the table dependencies kept describing the detached object, and a later `ALTER` of such a view failed with a `LOGICAL_ERROR` exception. [#122670](https://github.com/ClickHouse/ClickHouse/pull/122670) ([Groene AI](https://github.com/groeneai)).
* Fixed a window definition that places a frame before the parent window name, as in `WINDOW x AS (ROWS UNBOUNDED PRECEDING w)`. That order is now a syntax error, while a parent window named after a frame keyword, as in `WINDOW x AS (rows)`, now parses. [#120156](https://github.com/ClickHouse/ClickHouse/pull/120156) ([Groene AI](https://github.com/groeneai)).
* Formatting `EXPLAIN AST () FORMAT ...` or `... SETTINGS ...` now keeps the parentheses for `INSERT`, `DELETE`, `CREATE`, a nested non-`SELECT` `EXPLAIN`, other non-`SELECT` queries, and a `SELECT` or `EXPLAIN` with output options of its own, and `EXPLAIN SYNTAX SYSTEM ... FORMAT ...` is no longer formatted with parentheses that do not parse, so the formatted query parses back with the same output options. [#123189](https://github.com/ClickHouse/ClickHouse/pull/123189) ([Groene AI](https://github.com/groeneai)).
* Fixed formatting of PostgreSQL `COPY` queries so table names, columns, direction, format, and header options are preserved. [#123601](https://github.com/ClickHouse/ClickHouse/pull/123601) ([Minh Vu](https://github.com/fallintoplace)).
* Keep empty `LIKE` and `ILIKE` patterns in `SHOW` statements, including `SHOW FUNCTIONS`. [#123624](https://github.com/ClickHouse/ClickHouse/pull/123624) ([Minh Vu](https://github.com/fallintoplace)). [#123626](https://github.com/ClickHouse/ClickHouse/pull/123626) ([Minh Vu](https://github.com/fallintoplace)).
* A one-argument `tuple` in the `ORDER BY` of a projection, such as `ORDER BY tuple(c0)`, is now kept when the definition is formatted, so the formatted query parses back to the same definition. [#123162](https://github.com/ClickHouse/ClickHouse/pull/123162) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed formatting of the tuple element access operator when its index carries an alias. `SELECT ((1,2) AS t).(1 AS a)` was formatted as `SELECT ((1, 2) AS t).(1) AS a`, which re-parses with the alias attached to the whole `tupleElement` instead of to the index. This changed the column names of a query passed through `formatQuery` or sent to a remote shard, and raised `Inconsistent AST formatting` on builds with assertions enabled. [#120217](https://github.com/ClickHouse/ClickHouse/pull/120217) ([Groene AI](https://github.com/groeneai)).
* Fixed `formatQuery` and `formatQueryFromJSON` dropping `FULL` from `SHOW FULL DATABASES` and the other supported `SHOW FULL` forms. `SHOW FULL DICTIONARIES` no longer selects a non-existent `engine` column, and builds with assertions enabled no longer fail with `Inconsistent AST formatting`. Closes [#123967](https://github.com/ClickHouse/ClickHouse/issues/123967). [#124036](https://github.com/ClickHouse/ClickHouse/pull/124036) ([Groene AI](https://github.com/groeneai)).
* Fixed a crash and a `LOGICAL_ERROR` when a `lambda` function reached query analysis without the `lambda(tuple(...), body)` shape the SQL parser always produces. An AST deserialized from JSON (`dialect = clickhouse_json`) can no longer mark an arbitrary function as a lambda, and `CREATE FUNCTION f AS g(tuple(x), x)` is now rejected with `BAD_ARGUMENTS` instead of failing when `f` is called. Closes [#120380](https://github.com/ClickHouse/ClickHouse/issues/120380). [#120483](https://github.com/ClickHouse/ClickHouse/pull/120483) ([Groene AI](https://github.com/groeneai)).
* Fixed server termination on `CREATE TABLE`/`ALTER TABLE` when a constraint expression restored through the `clickhouse_json` dialect held a function without an `arguments` list. Such a payload now fails with `BAD_ARGUMENTS` while the AST is deserialized, so shapes that used to be accepted and fail later at `INSERT` (for example `notEquals` with no argument list) are rejected at parse time inside that dialect. [#120507](https://github.com/ClickHouse/ClickHouse/pull/120507) ([Groene AI](https://github.com/groeneai)).
* Fixed `formatQueryFromJSON` accepting enumerator names that name no value (an enumeration bound, or an unset default), such as `{"type":"SystemQuery","query_type":"UNKNOWN"}`, which raised `LOGICAL_ERROR: Unknown SYSTEM command` instead of reporting bad input. Such names are now rejected with `BAD_ARGUMENTS`. Closes [#120741](https://github.com/ClickHouse/ClickHouse/issues/120741). [#120886](https://github.com/ClickHouse/ClickHouse/pull/120886) ([Groene AI](https://github.com/groeneai)).
* Fixed two segfaults in `formatQueryFromJSON` when a node omits a child that formatting dereferences unconditionally. Closes [#120739](https://github.com/ClickHouse/ClickHouse/issues/120739). [#120876](https://github.com/ClickHouse/ClickHouse/pull/120876) ([Groene AI](https://github.com/groeneai)).
* Fixed a server crash when a `clickhouse_json` payload restores an expression holding a function with no `arguments` list, a shape the SQL parser cannot produce. Such a payload is now rejected with `BAD_ARGUMENTS`, as is an empty `TTL` list, which was persisted as metadata that no longer loaded. [#120882](https://github.com/ClickHouse/ClickHouse/pull/120882) ([Groene AI](https://github.com/groeneai)).
* Fixed `formatQueryFromJSON` raising `LOGICAL_ERROR: Unknown element in AST: Foreign Key` for a payload of type `ForeignKeyDeclaration`. That node type has no formatter and no query can produce one, so it is now rejected with `BAD_ARGUMENTS`. Closes [#120738](https://github.com/ClickHouse/ClickHouse/issues/120738). [#120915](https://github.com/ClickHouse/ClickHouse/pull/120915) ([Groene AI](https://github.com/groeneai)).
* Fixed stack exhaustion when deserializing an AST from JSON through `formatQueryFromJSON` or the `clickhouse_json` dialect. Such payloads now fail with `TOO_DEEP_RECURSION`. [#121693](https://github.com/ClickHouse/ClickHouse/pull/121693) ([Groene AI](https://github.com/groeneai)).
* Fixed a silently corrupted query when a node restored from the AST JSON format (`formatQueryFromJSON`, `dialect = 'clickhouse_json'`) carried a shape the parser cannot produce, such as a bare select query argument or an expression list where an argument was expected. Such a node is now rejected with `BAD_ARGUMENTS` instead of formatting into SQL that parses back as a different query. [#120725](https://github.com/ClickHouse/ClickHouse/pull/120725) ([Groene AI](https://github.com/groeneai)).
* Fixed stack exhaustion in `parseQueryToJSON` when serializing a query nested deeper than the serializer could follow, reachable by raising `max_parser_depth` above its default. Such a query now fails with `TOO_DEEP_RECURSION` instead of terminating the server. [#121856](https://github.com/ClickHouse/ClickHouse/pull/121856) ([Groene AI](https://github.com/groeneai)).
* A `CREATE DICTIONARY` sent in the AST JSON format (`dialect = 'clickhouse_json'`) is now rejected with `BAD_ARGUMENTS` when the brackets of a key-value argument do not match its value, a bracketed list holds something other than key-value pairs, the `SOURCE` has no brackets, the primary key is empty or not a list of identifiers, a `DEFAULT` is not a literal, or the attributes or the definition are missing or empty, and so is any other query that carries them. Such queries could crash the server or prevent it from starting. [#122981](https://github.com/ClickHouse/ClickHouse/pull/122981) ([Groene AI](https://github.com/groeneai)).
* Fix a server crash (SIGSEGV) when a `CREATE TABLE ... PROJECTION` / `ALTER TABLE ... ADD PROJECTION` statement is restored from a `clickhouse_json` AST whose projection `query` subtree contains a function node without an `arguments` list. The malformed payload is now rejected with `BAD_ARGUMENTS` during AST JSON deserialization. [#121113](https://github.com/ClickHouse/ClickHouse/pull/121113) ([Ilias](https://github.com/iliasabk)).
* A `clickhouse_json` payload that restores a function without an `arguments` list into an expression slot read by the pre-analyzer stack is now rejected with `BAD_ARGUMENTS` while it is being deserialized. Previously such a payload was accepted and could reach a visitor that dereferences the missing list, terminating the server. [#121119](https://github.com/ClickHouse/ClickHouse/pull/121119) ([Groene AI](https://github.com/groeneai)).
* Fixed `parseSize` and `parseTime` logic to correctly distinguish between size thresholds and time-based rotation schedules such as `12:00`. Fixes [#103108](https://github.com/ClickHouse/ClickHouse/issues/103108) and [#100910](https://github.com/ClickHouse/ClickHouse/issues/100910). [#103127](https://github.com/ClickHouse/ClickHouse/pull/103127) ([Jianmei Zhang](https://github.com/zhangjmruc)).
* A configuration file can be written in XML or in YAML, but only `config.xml` was looked up as the default configuration file. Now `clickhouse-server`, `clickhouse-keeper`, `clickhouse-local`, `clickhouse-keeper-client` and `clickhouse-disks` also find `config.yaml` and `config.yml` (`keeper_config.yaml` and `keeper_config.yml` for Keeper). Previously, `clickhouse-server` silently started with the configuration embedded into the binary when only a `config.yaml` was present. [#118422](https://github.com/ClickHouse/ClickHouse/pull/118422) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* `clickhouse install` (and therefore `apt`/`dpkg` package upgrades) no longer prompts interactively to set up a password for the `default` user when that user has been explicitly removed from configuration via `` in `users.d`. Previously the installer only checked whether the `default` user already had a password configured, missing the case where the user itself does not exist in the merged configuration at all, so it kept asking for a password on every upgrade even though there was no user to set it for. [#110438](https://github.com/ClickHouse/ClickHouse/pull/110438) ([Eduardo Gómez](https://github.com/edugomz)).
* Fixed the per-query `MemoryAllocatedWithoutCheck` and `MemoryAllocatedWithoutCheckBytes` values in `system.query_log`. A thread's untracked memory balance is flushed when the thread is attached to a query, and that flush was reported as the query's, so memory allocated before the query existed was charged to it. [#116505](https://github.com/ClickHouse/ClickHouse/pull/116505) ([Groene AI](https://github.com/groeneai)).
* Fixed `AsynchronousInsertQueueSize` and `AsynchronousInsertQueueBytes` in `system.metrics` growing permanently after `SYSTEM FLUSH ASYNC INSERT QUEUE`. [#120215](https://github.com/ClickHouse/ClickHouse/pull/120215) ([Sema Checherinda](https://github.com/CheSema)).
* Fixed a trailing NUL byte in the `notation` column of `system.unicode`, which made `length` return a wrong value and comparisons such as `notation = 'U+0041'` never match. [#122119](https://github.com/ClickHouse/ClickHouse/pull/122119) ([David Meng](https://github.com/davidmenggx)).
* Fixed `CGroup*` asynchronous metrics being silently missing on cgroup v2 systems that run ClickHouse in a nested cgroup, such as a typical `systemd` service. Closes [#103968](https://github.com/ClickHouse/ClickHouse/issues/103968). [#122918](https://github.com/ClickHouse/ClickHouse/pull/122918) ([Raúl Marín](https://github.com/Algunenano)).
* Fixed `NO_COMMON_TYPE` for `use_variant_as_common_type = 0` in the jemalloc fragmentation dashboard. [#121621](https://github.com/ClickHouse/ClickHouse/pull/121621) ([Azat Khuzhin](https://github.com/azat)).
* Fixed `TYPE_MISMATCH` being counted in `system.errors` on every execution of a `SELECT` comparing a `DateTime64` column against a `DateTime`, `Date` or `Date32` constant inside `AND`. A date or time constant with a part the column type cannot hold is no longer pushed down to MongoDB as a truncated bound. [#121078](https://github.com/ClickHouse/ClickHouse/pull/121078) ([Navneet Kumar](https://github.com/navneet83)).
* Fixed reading `system.parts`, `system.parts_columns` and `system.projection_parts` for a table whose `PARTITION BY` contains a `modulo` with an unsigned left and a signed right operand: the query aborted with `Bad get: has Int128, requested UInt128 (BAD_GET)` when the partition value was wider than 8 bytes, and otherwise showed a reinterpreted value that `ALTER TABLE ... DROP PARTITION` rejects. The same value is rendered while a merge or mutation is scheduled, while a `system.part_log` row is written, and while a partition is pruned, so on such a table merges failed to start, `part_log` rows were lost, and a filtered read could abort during planning. [#119333](https://github.com/ClickHouse/ClickHouse/pull/119333) ([Groene AI](https://github.com/groeneai)).
* Fix `system.server_settings` reporting the async logger queue size under the misspelled key `logger.async_queye_max_size` instead of `logger.async_queue_max_size`. [#123578](https://github.com/ClickHouse/ClickHouse/pull/123578) ([Raúl Marín](https://github.com/Algunenano)).
* Fix `SELECT` from `system.stack_trace` failing with `Cannot read from file /proc//status ... No such process` when a thread exits while the table is being scanned. [#123805](https://github.com/ClickHouse/ClickHouse/pull/123805) ([Groene AI](https://github.com/groeneai)).
* Fix `system.jemalloc_sampled_allocations` and the collapsed output of `system.jemalloc_profile_text` on sampled allocations whose backtrace jemalloc could not unwind: the allocation is now reported with `trace = []` or under `[unknown]` instead of failing with `CANNOT_PARSE_TEXT` or being omitted. [#123818](https://github.com/ClickHouse/ClickHouse/pull/123818) ([Groene AI](https://github.com/groeneai)).
* Fix per-protocol asynchronous metrics such as `TCPThreads` and `HTTPThreads` not being reported for listeners configured through the `` section. Such a listener is now reported under the same metric as the equivalent built-in port. Metrics are also now reported for the `tcp_with_proxy` and `tcp_ssh` listeners, which previously had none. [#112977](https://github.com/ClickHouse/ClickHouse/pull/112977) ([Chester](https://github.com/superdiaodiao)).
* Fix a deadlock when an obsolete union system log table is replaced with synchronous drops. [#124610](https://github.com/ClickHouse/ClickHouse/pull/124610) ([Azat Khuzhin](https://github.com/azat)).
* Fixed the `max_local_read_bandwidth_for_server`, `max_local_write_bandwidth_for_server`, `max_remote_read_network_bandwidth_for_server` and `max_remote_write_network_bandwidth_for_server` rows of `system.server_settings` reporting the reading session's own bandwidth limit instead of the server-wide one. `getServerSetting` on those names is fixed the same way. [#119556](https://github.com/ClickHouse/ClickHouse/pull/119556) ([Groene AI](https://github.com/groeneai)).
* Fix tables of the `clickhouse-local` default database becoming invisible (`UNKNOWN_TABLE`) when the same `--path` is later used with another `default_database`. [#123124](https://github.com/ClickHouse/ClickHouse/pull/123124) ([Nikolay Degterinsky](https://github.com/evillique)).
* Fixed missing crash reports of `clickhouse-local` when neither `stdin` nor `stderr` is a terminal: a fatal signal printed nothing, and `--client_logs_file` was not written. [#115102](https://github.com/ClickHouse/ClickHouse/pull/115102) ([Groene AI](https://github.com/groeneai)).
* Fixed `clickhouse-local` hanging forever on `DROP TABLE|VIEW|DATABASE ... SYNC` when `--path` is set and no metadata is loaded from it, for example a new directory on released versions or `--only-system-tables`. [#123862](https://github.com/ClickHouse/ClickHouse/pull/123862) ([Groene AI](https://github.com/groeneai)).
* The wasm64 `clickhouse local` now starts with 2 GiB of linear memory, so it no longer fails at startup with `memory access out of bounds` when Node.js races a `memory.grow` across worker threads. Closes [#124067](https://github.com/ClickHouse/ClickHouse/issues/124067). [#123944](https://github.com/ClickHouse/ClickHouse/pull/123944) ([Groene AI](https://github.com/groeneai)).
* Fixed `SET profile` having no effect on subsequent queries in `clickhouse-local`. Profile settings such as `readonly` and `join_use_nulls` now apply to subsequent queries again. Closes [#123916](https://github.com/ClickHouse/ClickHouse/issues/123916). [#125171](https://github.com/ClickHouse/ClickHouse/pull/125171) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed `promql_evaluation_time` silently rounding the requested instant, which could make an instant query return a different sample. The setting also now accepts an integer Unix timestamp over the native protocol, which it previously refused. [#120942](https://github.com/ClickHouse/ClickHouse/pull/120942) ([Valery Petrov](https://github.com/valerypetrov)).
* PromQL queries with regex label matchers (`=~`, `!~`) again work under `--dialect promql`. [#115073](https://github.com/ClickHouse/ClickHouse/pull/115073) ([Valery Petrov](https://github.com/valerypetrov)).
* Allow PromQL `# ` and `#!` line comments to end at EOF without a trailing newline. [#113201](https://github.com/ClickHouse/ClickHouse/pull/113201) ([Minh Vu](https://github.com/fallintoplace)).
* Fix PromQL duplicate-series detection to check one step at a time, so series that share tags but have values at different steps are now merged instead of failing with `Multiple series have the same tags`. Binary operators check for duplicates after matching series, so unmatched series no longer cause this exception. [#124086](https://github.com/ClickHouse/ClickHouse/pull/124086) ([Vitaly Baranov](https://github.com/vitlibar)). [#124879](https://github.com/ClickHouse/ClickHouse/pull/124879) ([Vitaly Baranov](https://github.com/vitlibar)).
* PromQL: fixed expressions over an instant vector that is known to be empty, such as `(0 < clamp(up, 1, -1)) or vector(7)`, which failed in range queries with `Number of values doesn't match number of steps` or returned samples at `1970-01-01`. [#123879](https://github.com/ClickHouse/ClickHouse/pull/123879) ([Valery Petrov](https://github.com/valerypetrov)).
* Fixed `SELECT count()` returning the whole-table row count for a streaming read (`FROM ... STREAM`), ignoring the `CURSOR` bound. The implicit min-max/count projection answered the query from part metadata instead of the streaming reader. [#117188](https://github.com/ClickHouse/ClickHouse/pull/117188) ([Groene AI](https://github.com/groeneai)).
* Fixed a server crash (`std::terminate` with `write failed`) in the embedded SSH client when the client's terminal was closed before the line reader was destroyed. [#120764](https://github.com/ClickHouse/ClickHouse/pull/120764) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed `Code: 1001 STD_EXCEPTION` (`filesystem error: ... File name too long`) when a query names a table or dictionary longer than the filesystem's `NAME_MAX` in `clickhouse local`, or in a server holding a `Filesystem` or `URL` database. Such a name is now reported as missing rather than as a filesystem error. Closes [#121304](https://github.com/ClickHouse/ClickHouse/issues/121304). [#121471](https://github.com/ClickHouse/ClickHouse/pull/121471) ([Groene AI](https://github.com/groeneai)).
* A malformed argument list of an optimization of the `mergeTreeAnalyzeIndexes` table function is now reported as `BAD_ARGUMENTS` instead of a logical error or a raw `std::exception`. [#118644](https://github.com/ClickHouse/ClickHouse/pull/118644) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed `max_execution_time` not being enforced in `clickhouse-local` for a query blocked inside a non-interruptible read. `clickhouse-local` did not start the watchdog that turns a time limit expiry into a query cancellation, so a query reading from an unresponsive `s3` endpoint ran to the end of the S3 retry budget (`s3_retry_attempts` defaults to 500, which takes minutes) instead of failing with `TIMEOUT_EXCEEDED` at its limit. [#120933](https://github.com/ClickHouse/ClickHouse/pull/120933) ([Groene AI](https://github.com/groeneai)).
* Fixed distributed queries hanging at 100% CPU on macOS when `max_threads = 1`. [#122905](https://github.com/ClickHouse/ClickHouse/pull/122905) ([Raúl Marín](https://github.com/Algunenano)).
* Fixed a server abort on macOS when an HTTP client resets the connection during header reading. [#123074](https://github.com/ClickHouse/ClickHouse/pull/123074) ([Groene AI](https://github.com/groeneai)).
* Fixed a `LOGICAL_ERROR` (`Unexpected return type from materialize`, a server abort in debug and sanitizer builds) when reading a `Buffer` table whose destination declares a column with a different but convertible type and a forwarded filter references that column: with a row policy and the implicit `WHERE` to `PREWHERE` move, and under `query_plan_optimize_lazy_final`. The same cause made such a read fail with `NOT_FOUND_COLUMN_IN_BLOCK` when a text index on that column was read directly and the predicate appeared in both `PREWHERE` and `WHERE`, fail with `TYPE_MISMATCH` over a `URL(Parquet)` destination, abort with `Bad cast from ColumnMap to ColumnArray` when a row policy and an explicit `PREWHERE` both referenced it, or fail with `AMBIGUOUS_COLUMN_NAME` when several `PREWHERE` conditions referenced the converted column. [#113900](https://github.com/ClickHouse/ClickHouse/pull/113900) ([Groene AI](https://github.com/groeneai)). [#124632](https://github.com/ClickHouse/ClickHouse/pull/124632) ([Groene AI](https://github.com/groeneai)).
* Fixed `SYSTEM DROP DNS CACHE` leaving entries in the DNS cache when it ran at the same time as the periodic DNS cache update. [#123699](https://github.com/ClickHouse/ClickHouse/pull/123699) ([Groene AI](https://github.com/groeneai)).
* Fix `UNSUPPORTED_METHOD` error for queries using `IN`/`NOT IN`/`GLOBAL IN` with a subquery inside `AND`/`OR` when `enable_function_early_short_circuit` is enabled. [#116037](https://github.com/ClickHouse/ClickHouse/pull/116037) ([fhw12345](https://github.com/fhw12345)).
* Fixed a crash caused by a stack overflow when a deeply nested JSON document was parsed into a `JSON` column or passed to the `JSONExtract` family of functions. Such documents are now rejected with the `TOO_DEEP_RECURSION` error. [#120887](https://github.com/ClickHouse/ClickHouse/pull/120887) ([Pavel Kruglov](https://github.com/Avogar)).
* Fixed the `LOGICAL_ERROR` `Not-ready Set is passed as the second argument for function 'in'` for a query with `ORDER BY ... WITH FILL ... INTERPOLATE` whose `INTERPOLATE` expression contains `IN` with a subquery or a table that is not used anywhere else in the query. [#124518](https://github.com/ClickHouse/ClickHouse/pull/124518) ([Groene AI](https://github.com/groeneai)).
* Fixed wrong results of a `WHERE` equality between `Tuple` values with `Nullable` elements, or between `Variant` values, over a comma, `CROSS` or `INNER` join: the pair whose equality is `NULL`, such as `tuple(NULL) = tuple(NULL)`, was returned. With `allow_dynamic_type_in_join_keys = 0`, a comma or `CROSS` join with a `WHERE` equality on a `Dynamic` value no longer returns no rows or fails with `ILLEGAL_COLUMN`. [#124854](https://github.com/ClickHouse/ClickHouse/pull/124854) ([Groene AI](https://github.com/groeneai)).
* Fixed secret arguments being exposed in `system.query_log` and the server log when a table function or function was called with the wrong letter case, such as `S3` instead of `s3`, `MySQL` instead of `mysql`, or `ENCRYPT` instead of `encrypt`. Such calls are still rejected. [#124862](https://github.com/ClickHouse/ClickHouse/pull/124862) ([Groene AI](https://github.com/groeneai)).
* Fixed tables of a `MySQL` database ignoring the database's `connection_auto_close` setting: with `connection_auto_close = 0`, every read still closed its connection and the next read reconnected. A table attached again with `ATTACH TABLE` also lost the database's settings. `INSERT` into any `MySQL` table ignored the setting and always kept its connection; with the default `connection_auto_close = 1` it now closes it after the query, as reads do. Closes [#124749](https://github.com/ClickHouse/ClickHouse/issues/124749). [#124884](https://github.com/ClickHouse/ClickHouse/pull/124884) ([Groene AI](https://github.com/groeneai)).
* Hide the password of a URL in `SHOW CREATE TABLE`, `system.tables` and `system.query_log` only within the URL's authority: a `@` in the query string no longer rewrites the shown host, and a password containing `@` is hidden whole. [#124885](https://github.com/ClickHouse/ClickHouse/pull/124885) ([Raúl Marín](https://github.com/Algunenano)).
* Fixed `merge` and `Merge` tables over a `Distributed` or `remote` table rejecting valid queries on a column that some of the tables lack: aggregates over `Decimal` and `Map` columns failed with errors such as `THERE_IS_NO_COLUMN`, and an integer column of this kind in `GROUP BY`, `ORDER BY` or `LIMIT BY` failed with `Positional argument number 0 is out of bounds`. [#124976](https://github.com/ClickHouse/ClickHouse/pull/124976) ([Groene AI](https://github.com/groeneai)).
* Fixed trace samples in `system.trace_log` losing their `query_id` while a thread attaches to or detaches from a query, so memory profiling samples remain attributable to the query. [#125176](https://github.com/ClickHouse/ClickHouse/pull/125176) ([Groene AI](https://github.com/groeneai)).
* Fixed wrong window function results in the totals row of a `WITH TOTALS` query when an `arrayJoin` expands the totals into several rows: those rows were not sorted by the window's `PARTITION BY` / `ORDER BY` keys. [#125324](https://github.com/ClickHouse/ClickHouse/pull/125324) ([Groene AI](https://github.com/groeneai)).
* Fixed primary key and skip index analysis that could skip or over-count rows for conditions on date and time functions such as `toHour`, `toDayOfMonth`, `timezoneOffset` or `toTimeWithFixedDate` over a `Nullable(DateTime)` or `LowCardinality(Nullable(DateTime))` key whose time zone differs from the session time zone. [#125327](https://github.com/ClickHouse/ClickHouse/pull/125327) ([Groene AI](https://github.com/groeneai)).
* Fixed wrong results of `ORDER BY`, `DISTINCT`, `LIMIT BY` and aggregation in order over a `Merge` table or the `merge` table function when it reads an `Iceberg` table with a sort order: the rows came back unsorted or duplicated. [#125383](https://github.com/ClickHouse/ClickHouse/pull/125383) ([Groene AI](https://github.com/groeneai)).
* Fixed `count()` with a `WHERE` condition on the sorting key returning too many rows on a `MergeTree` table with a normal projection: rows counted from the primary key by the exact count optimization were counted again when the projection was read. Closes [#125183](https://github.com/ClickHouse/ClickHouse/issues/125183). [#125412](https://github.com/ClickHouse/ClickHouse/pull/125412) ([Groene AI](https://github.com/groeneai)).
* Fixed a possible segmentation fault when reading an `Avro` `map` into a `Map` column (for example `Map(DateTime, String)`) with the `AvroConfluent` format, including `Kafka` tables. Closes [#125457](https://github.com/ClickHouse/ClickHouse/issues/125457). [#125505](https://github.com/ClickHouse/ClickHouse/pull/125505) ([Groene AI](https://github.com/groeneai)).
* Fix a server crash on `CREATE DICTIONARY` without a `SOURCE` clause when `restore_replace_external_dictionary_source_to_null` is enabled. Such a query now fails with `INCORRECT_DICTIONARY_DEFINITION`, as it does with the setting disabled. With the same setting, a local `CLICKHOUSE` source that uses a constant function such as `DB currentDatabase()` is no longer rejected. [#125659](https://github.com/ClickHouse/ClickHouse/pull/125659) ([Groene AI](https://github.com/groeneai)).
* Fixed the `Arrow` and `ArrowStream` input formats rejecting valid dictionary-encoded columns whose dictionary contains repeated values. Closes [#125139](https://github.com/ClickHouse/ClickHouse/issues/125139). [#125677](https://github.com/ClickHouse/ClickHouse/pull/125677) ([Jay Pokale](https://github.com/JayPokale)).
* Fixed the Arrow Flight interface writing the text of each query, including secrets such as `IDENTIFIED BY` passwords and storage keys, to the server log and `system.text_log`. The gRPC interface did the same for the first 64 characters of each query. Now queries from these interfaces are logged only with their secrets hidden. [#125716](https://github.com/ClickHouse/ClickHouse/pull/125716) ([Groene AI](https://github.com/groeneai)).
* Fix a server crash on macOS where an idle thread pool worker aborted with `condition_variable wait failed: Invalid argument`. The `EINVAL` that Darwin's `pthread_cond_wait` returns when the kernel fails the wait is now treated as a spurious wakeup. Closes [#84761](https://github.com/ClickHouse/ClickHouse/issues/84761). [#125721](https://github.com/ClickHouse/ClickHouse/pull/125721) ([Groene AI](https://github.com/groeneai)).
#### Build/Testing/Packaging Improvement
* Harden official builds by compiling with `-fstack-protector-strong` and `-fstack-clash-protection`, and by linking with `-Wl,-z,separate-code`. [#119039](https://github.com/ClickHouse/ClickHouse/pull/119039) ([Raúl Marín](https://github.com/Algunenano)). [#123073](https://github.com/ClickHouse/ClickHouse/pull/123073) ([Raúl Marín](https://github.com/Algunenano)).
* The musl build of ClickHouse is now a static position-independent executable, so it gets address space layout randomization like the glibc build. [#125669](https://github.com/ClickHouse/ClickHouse/pull/125669) ([Raúl Marín](https://github.com/Algunenano)).
* Added an optional packaging mode `SYMBOL_SECTIONS=gnu_debugdata` that replaces `.symtab` and `.strtab` in release binaries with compressed `.gnu_debugdata` (MiniDebugInfo), reducing symbol data from about 148 MiB to about 10 MiB in the official build. Stack traces and symbol access from gdb, lldb, elfutils, and perf remain available. [#115322](https://github.com/ClickHouse/ClickHouse/pull/115322) ([Andrew Grigorev](https://github.com/ei-grad)).
* Update `cctz` to 2026d. Time zone names with the `file:` prefix are now rejected. [#121325](https://github.com/ClickHouse/ClickHouse/pull/121325) ([Actuele AI](https://github.com/actueleai)). Update `cctz` to 2026e: `America/Winnipeg`, `America/Rainy_River`, and `Canada/Central` now stay at UTC−5 from 2026-11-01, reflecting Manitoba's removal of the DST fall-back. [#124249](https://github.com/ClickHouse/ClickHouse/pull/124249) ([Actuele AI](https://github.com/actueleai)).
* Update `OpenSSL` to 3.5.9. [#124278](https://github.com/ClickHouse/ClickHouse/pull/124278) ([Actuele AI](https://github.com/actueleai)).
* Update `aws-sdk-cpp` to 1.11.907, the AWS CRT libraries to 0.43.8, and `aws-c-common` to 1.0.2. [#125080](https://github.com/ClickHouse/ClickHouse/pull/125080) ([Groene AI](https://github.com/groeneai)).
* The `delta-kernel-rs` library no longer carries its own copy of OpenSSL, so the binary always links the OpenSSL built from `contrib/openssl` with the current build flags instead of an older copy kept by the Rust build cache. [#123889](https://github.com/ClickHouse/ClickHouse/pull/123889) ([Groene AI](https://github.com/groeneai)).
* Rust crates are now built in parallel with each other and with the C++ code, which reduces the build time. [#124645](https://github.com/ClickHouse/ClickHouse/pull/124645) ([Antonio Andelic](https://github.com/antonio2368)).
* Builds of the experimental GPU engine are faster: `nvcc` compilations are now cached with `ccache`, and unused PTX plus CUDA line info are no longer generated. [#120421](https://github.com/ClickHouse/ClickHouse/pull/120421) ([Konstantin Vedernikov](https://github.com/scanhex12)).
* Fixed building with `-DNO_ARMV81_OR_HIGHER=1` on AArch64: the compatibility profile no longer disables `NEON` for Rust, so `ring`-based components (`chdig`, `delta-kernel-rs`) compile and stay enabled. This unblocks building for ARMv8.2-A CPUs that lack `rcpc`, such as HiSilicon Kunpeng 920. [#107440](https://github.com/ClickHouse/ClickHouse/pull/107440) ([Tiaonmmn](https://github.com/Tiaonmmn)).
* Compile code linked into the position-independent `clickhouse` executable with `-fPIE` instead of `-fPIC`, avoiding unnecessary symbol indirection. Apply the flag to the C++ runtime libraries from `contrib` too, so builds with compilers that do not default to PIE link successfully, including Fedora's `clang` on `aarch64` and `x86_64`. [#125094](https://github.com/ClickHouse/ClickHouse/pull/125094) ([oleg-milanov](https://github.com/oleg-milanov)). [#125488](https://github.com/ClickHouse/ClickHouse/pull/125488) ([Groene AI](https://github.com/groeneai)).
* Allow building with XRay instrumentation under musl. [#118914](https://github.com/ClickHouse/ClickHouse/pull/118914) ([Konstantin Bogdanov](https://github.com/thevar1able)).
* Fixed a missing CMake link dependency that could make `src/Functions/array/distanceTransposed.cpp` fail with `simsimd/simsimd.h file not found` on a from-scratch build. [#120504](https://github.com/ClickHouse/ClickHouse/pull/120504) ([Craig Ringer](https://github.com/ringerc)).
* Reduce linker warnings in Rust/wasm builds: remove `--icf=safe` warnings about `SHT_LLVM_ADDRSIG` in the stripped Rust libraries, and apply the `__jit_debug_register_code` workaround only to the `clickhouse` binary and only when `wasmtime` is linked. [#122904](https://github.com/ClickHouse/ClickHouse/pull/122904) ([Raúl Marín](https://github.com/Algunenano)). [#123287](https://github.com/ClickHouse/ClickHouse/pull/123287) ([Azat Khuzhin](https://github.com/azat)).
* Update `google-protobuf` to v36.1. `google-cloud-cpp` protobuf sources are now regenerated when `protoc` changes, so incremental builds do not fail after such an update. [#118926](https://github.com/ClickHouse/ClickHouse/pull/118926) ([Actuele AI](https://github.com/actueleai)). [#123603](https://github.com/ClickHouse/ClickHouse/pull/123603) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Update `rocksdb` to v11.8.1. [#118929](https://github.com/ClickHouse/ClickHouse/pull/118929) ([Actuele AI](https://github.com/actueleai)).
* Update `abseil-cpp` to 20260817.0. [#118897](https://github.com/ClickHouse/ClickHouse/pull/118897) ([Actuele AI](https://github.com/actueleai)).
* Update `PostgreSQL` to 18.6. [#124281](https://github.com/ClickHouse/ClickHouse/pull/124281) ([Actuele AI](https://github.com/actueleai)).
* Update `thrift` to v0.25.0. [#124280](https://github.com/ClickHouse/ClickHouse/pull/124280) ([Actuele AI](https://github.com/actueleai)).
* Update `cppkafka` to v0.4.1. [#119468](https://github.com/ClickHouse/ClickHouse/pull/119468) ([Actuele AI](https://github.com/actueleai)).
* Update `h3` to v4.5.0. [#119328](https://github.com/ClickHouse/ClickHouse/pull/119328) ([Actuele AI](https://github.com/actueleai)).
* Update `flatbuffers` to v25.12.19. [#119100](https://github.com/ClickHouse/ClickHouse/pull/119100) ([Actuele AI](https://github.com/actueleai)).
* Update `croaring` to v5.2.2. [#119464](https://github.com/ClickHouse/ClickHouse/pull/119464) ([Actuele AI](https://github.com/actueleai)).
* Update `simdutf` to v9.1.1. [#119324](https://github.com/ClickHouse/ClickHouse/pull/119324) ([Actuele AI](https://github.com/actueleai)).
* Update `double-conversion` to v3.4.0. [#119095](https://github.com/ClickHouse/ClickHouse/pull/119095) ([Actuele AI](https://github.com/actueleai)).
* Update `libcpuid` to v0.8.2. [#121382](https://github.com/ClickHouse/ClickHouse/pull/121382) ([Actuele AI](https://github.com/actueleai)).
* Update `liburing` to 2.15. [#118895](https://github.com/ClickHouse/ClickHouse/pull/118895) ([Actuele AI](https://github.com/actueleai)).
* Update `libuv` to v1.52.1. [#119099](https://github.com/ClickHouse/ClickHouse/pull/119099) ([Actuele AI](https://github.com/actueleai)).
* Update `libcotp` to v4.2.2. [#122000](https://github.com/ClickHouse/ClickHouse/pull/122000) ([Actuele AI](https://github.com/actueleai)).
* Update `vectorscan` to 5.4.13. [#125774](https://github.com/ClickHouse/ClickHouse/pull/125774) ([Actuele AI](https://github.com/actueleai)).
* Update `snappy` to 1.2.2. [#119325](https://github.com/ClickHouse/ClickHouse/pull/119325) ([Actuele AI](https://github.com/actueleai)).
* Update `brotli` to v1.2.0. [#119096](https://github.com/ClickHouse/ClickHouse/pull/119096) ([Actuele AI](https://github.com/actueleai)).
* Update `libdeflate` to v1.26. [#119349](https://github.com/ClickHouse/ClickHouse/pull/119349) ([Actuele AI](https://github.com/actueleai)).
* Update `xxHash` to v0.8.4. [#124231](https://github.com/ClickHouse/ClickHouse/pull/124231) ([Actuele AI](https://github.com/actueleai)).
* Update `google-benchmark` to v1.9.5. [#118893](https://github.com/ClickHouse/ClickHouse/pull/118893) ([Actuele AI](https://github.com/actueleai)).
* `MemoryWorker` now corrects `MemoryTracker` using allocated memory from ASan, TSan, and MSan instead of resident memory in sanitizer builds when cgroups are available. [#119956](https://github.com/ClickHouse/ClickHouse/pull/119956) ([Konstantin Morozov](https://github.com/k-morozov)).
* Add support for cross-compiling ClickHouse for illumos. Closes [#23777](https://github.com/ClickHouse/ClickHouse/issues/23777). [#125073](https://github.com/ClickHouse/ClickHouse/pull/125073) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
### ClickHouse release 26.9, 2026-09-21. [Presentation](https://presentations.clickhouse.com/2026-release-26.9/), [Video](https://www.youtube.com/watch?v=wLrTlU5LLWI)
#### Backward Incompatible Change
* 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. [#118629](https://github.com/ClickHouse/ClickHouse/pull/118629) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* The default compression method is changed from `LZ4` to `ZSTD(3)`. Client/server and server/server network communication switches to `ZSTD(3)` uniformly. For `MergeTree` column data the built-in default is now size-aware: `LZ4` for parts below 100 MB and `ZSTD(3)` at or above it, judged by the part size known at write time (the size of the source parts for a merge or a mutation). The `StripeLog` data stream, the persistent files of the `Set` and `Join` engines, and `MergeTree` auxiliary files such as `checksums.txt` switch to `ZSTD(3)` uniformly. HTTP `compress=1` now uses the `network_compression_method` setting too; the default is still `ZSTD(3)`, and `compatibility` set to `26.8` or earlier restores `LZ4` over HTTP as well. This improves compression ratios and reduces storage and network usage out of the box, at a modest increase in CPU usage. To restore the previous behavior: for network compression, use the `compatibility` setting or set `network_compression_method = 'LZ4'`; for `MergeTree` column data, set `CODEC(LZ4)` on the column or table, or set the server `` default to `LZ4`; for the `Log` and `TinyLog` engines, set a column `CODEC(LZ4)`. The remaining streams always use the built-in default and have no runtime rollback; reading stays correct because every compressed frame is self-describing. [#108786](https://github.com/ClickHouse/ClickHouse/pull/108786) ([Alexey Milovidov](https://github.com/alexey-milovidov)). [#119825](https://github.com/ClickHouse/ClickHouse/pull/119825) ([Alexey Milovidov](https://github.com/alexey-milovidov)). This change is backward compatible, it is listed here for your convenience.
* Removed the CatBoost integration. The `catboostEvaluate` function, the `system.models` table and the `SYSTEM RELOAD MODEL(S)` queries are no longer available. Queries, views and grants referring to them have to be migrated before the upgrade: in particular, revoke `SYSTEM RELOAD MODEL` from all users and roles beforehand, because an access entity whose grants still mention the removed privilege cannot be parsed on startup. Also let any in-flight `SYSTEM RELOAD MODEL(S) ON CLUSTER` entries drain from the distributed DDL queue before the upgrade: upgraded hosts can no longer parse such entries and will finish them with an error status instead of executing them. The same applies to persisted table metadata: a table whose column `DEFAULT`/`MATERIALIZED`/`ALIAS` expressions, secondary indices, constraints, projections, partition/order/sample keys, or TTL expressions still reference `catboostEvaluate` cannot be loaded after the upgrade (`UNKNOWN_FUNCTION`), so drop or rewrite such definitions beforehand. The revoke also has to cover every other carrier of serialized grants: a `GRANT SYSTEM RELOAD MODEL` line in the `grants` section of `users.xml` must be removed as well, because it can no longer be parsed and the server then refuses to load the users configuration at startup; on clusters with replicated (Keeper-backed) access storage, revoke the privilege before upgrading any replica, because with the default `access_control_improvements.throw_on_invalid_replicated_access_entities = 0` an upgraded replica that reads a user or role still carrying `SYSTEM RELOAD MODEL` from ZooKeeper cannot parse it and silently drops that entity from its in-memory copy (set `throw_on_invalid_replicated_access_entities = 1` to fail loudly instead); and access backups (`BACKUP ... ACCESS`) taken while the grant was still present cannot be restored with `RESTORE ... ACCESS` on the new version, so re-create such backups after the revoke. [#109710](https://github.com/ClickHouse/ClickHouse/pull/109710) ([Robert Schulze](https://github.com/rschu1ze)). [#116586](https://github.com/ClickHouse/ClickHouse/pull/116586) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Removed the deprecated `read_resource` and `write_resource` disk options from `storage_configuration`. Attach a scheduler resource to a disk with `CREATE RESOURCE name (READ DISK disk, WRITE DISK disk)` instead. [#115286](https://github.com/ClickHouse/ClickHouse/pull/115286) ([Sergei Trifonov](https://github.com/serxa)).
* Removed the `WasmEdge` engine for WebAssembly UDFs. `wasmtime`, which has always been the default, is now the only supported value of the `webassembly_udf_engine` server setting. A server configured with `webassembly_udf_engine = 'wasmedge'` will not start; remove that setting or set it to `wasmtime`. On binaries where `wasmtime` is unavailable, including MemorySanitizer, `arm_v80compat`, and `riscv64`, WebAssembly UDFs are not available at all: the server still starts, but `system.webassembly_modules` is absent and any attempt to create or use a WebAssembly UDF fails with `SUPPORT_IS_DISABLED`. [#115316](https://github.com/ClickHouse/ClickHouse/pull/115316) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* The experimental `WINDOW VIEW` feature is removed, together with the `WATCH` statement and the `windowID` function. It has been non-functional since version 24.12 (inserts into the source table were silently not delivered to window views) and was never supported by the analyzer, which is enabled by default since 24.3. The settings `allow_experimental_window_view`, `window_view_clean_interval`, `window_view_heartbeat_interval`, and `wait_for_window_view_fire_signal_timeout` are kept as obsolete no-ops. The time-window functions `tumble`, `tumbleStart`, `tumbleEnd`, `hop`, `hopStart`, and `hopEnd` are kept. If you still have window views defined, drop them before upgrading: a server that finds a window view in its metadata fails to start (`Cannot parse definition from metadata file ... (SYNTAX_ERROR)`), the same way the removal of the `Lazy` database engine behaves. Similar functionality will be reimplemented on top of streaming queries (issue [#114738](https://github.com/ClickHouse/ClickHouse/issues/114738)). [#114747](https://github.com/ClickHouse/ClickHouse/pull/114747) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Removed the sharded `GROUP BY` aggregation (`enable_sharding_aggregator`, disabled by default) in favor of the adaptive aggregation (`enable_adaptive_aggregator`, enabled by default), which targets the same high-cardinality workloads without the weaknesses on skewed or low-cardinality keys and with support for external aggregation. The `enable_sharding_aggregator` setting is kept as obsolete: setting it is still accepted and has no effect. [#116532](https://github.com/ClickHouse/ClickHouse/pull/116532) ([Nihal Z. Miaji](https://github.com/nihalzp)).
* Fixed wrong results from `runningConcurrency` under `LEFT JOIN` and `ANY JOIN`, and under lazy evaluation in `if`, `multiIf`, `and`, and `or`, by treating it as non-deterministic. Queries using it may be slower. A sorting key, partition key, or text index `preprocessor`/`postprocessor` containing `runningConcurrency` is now rejected, and a table created earlier with one will not load after upgrading: remove or replace it before the upgrade. [#114403](https://github.com/ClickHouse/ClickHouse/pull/114403) ([Groene AI](https://github.com/groeneai)).
* `BACKUP ... TO Disk(...)`, `RESTORE ... FROM Disk(...)`, and `CREATE DATABASE ... ENGINE = Backup(..., Disk(...))` now require `SOURCES` grants for the target `Disk(...)` location: `WRITE ON DISK` to write and `READ ON DISK` to read. Previously a user with `BACKUP` but without `SOURCES` could still use any disk listed in `backups.allowed_disk`; such users now need the corresponding `DISK` grant, while users already granted `SOURCES` are unaffected. [#117406](https://github.com/ClickHouse/ClickHouse/pull/117406) ([Groene AI](https://github.com/groeneai)).
* Compression codecs are now gated by dedicated per-codec settings whose declared tier defines the codec maturity. The `ALP` codec is promoted to beta through `enable_alp_codec`, and `allow_experimental_codecs` is now obsolete: it no longer enables any codec, so use the per-codec `enable__codec` settings instead. [#116337](https://github.com/ClickHouse/ClickHouse/pull/116337) ([Raufs Dunamalijevs](https://github.com/rienath)). [#117545](https://github.com/ClickHouse/ClickHouse/pull/117545) ([Raufs Dunamalijevs](https://github.com/rienath)).
* Reading a `File` source with `rename_files_after_processing` set now requires the `WRITE ON FILE` grant on top of `READ ON FILE` (on the initiator for `fileCluster`): the setting renames the files a `SELECT` has read, which is a write to the source, and it used to happen for anyone who could read them. A query relying on it now needs `GRANT WRITE ON FILE`. A per-query renaming rule is also no longer cached by a `Filesystem` database, where it could make an unrelated later query rename files, or be dropped silently. [#117895](https://github.com/ClickHouse/ClickHouse/pull/117895) ([Groene AI](https://github.com/groeneai)).
* The `interface` and `http_method` columns of `system.query_log`, `system.query_thread_log` and `system.processes` are now `Enum8` instead of `UInt8`, over the value set `system.session_log.interface` already uses, plus `Unknown` for an unrecognized interface. Comparing to a number keeps working (`WHERE interface = 1`) and comparing to a name now works too (`WHERE interface = 'TCP'`), but a plain `SELECT` renders the name, and arithmetic on the column (`interface + 0`) is no longer accepted. The default-enabled `system.user_query_log` and the opt-in `all_` union tables copy these types. As with any system log schema change, the existing log tables are renamed with the first free suffix (`query_log_0`, `query_log_1`, ...) on upgrade; their rows read as names after `ALTER TABLE system.query_log_0 MODIFY COLUMN interface Enum8(...)`, and the same for `http_method`, preceded by `MODIFY SETTING table_readonly = 0` if that table was frozen. [#118136](https://github.com/ClickHouse/ClickHouse/pull/118136) ([Groene AI](https://github.com/groeneai)).
* `CREATE TABLE ... AS mergeTreeIndex(...)` is no longer accepted, nor the same form over `mergeTreeProjection`, `mergeTreeAnalyzeIndexes`, `mergeTreeAnalyzeIndexesUUID`, `mergeTreeTextIndex` and `mergeTreeCodecBlockCounts`. The storage these functions return holds its source table's storage object, so once such a persisted table had been read, `DROP TABLE SYNC` never returned, the source stayed in `system.dropped_tables` forever and its data was never reclaimed from disk. Reading these functions directly, as in `SELECT ... FROM mergeTreeIndex(...)`, is unaffected. An existing table of this shape keeps loading at server startup, but `ATTACH TABLE`, `RESTORE` and `Replicated` database replica recovery now refuse it: list them with `SELECT database, name FROM system.tables WHERE engine = 'Proxy'`, drop the ones over these six functions, and read the functions directly instead. [#118969](https://github.com/ClickHouse/ClickHouse/pull/118969) ([Groene AI](https://github.com/groeneai)).
* `CREATE TABLE ... AS timeSeriesSamples(...)` is no longer accepted, nor the same form over `timeSeriesData`, `timeSeriesTags`, or `timeSeriesMetrics`. Reading those functions directly is unaffected. Existing tables of this shape still load at server startup, but `ATTACH TABLE`, `RESTORE`, and `Replicated` replica recovery now refuse them, because once such a persisted proxy table had been read, `DROP TABLE ` dropped its live target and destroyed its rows, and later reads could fail with `QueryPlan was not initialized`. Find candidates with `SELECT database, name, create_table_query FROM system.tables WHERE engine = 'Proxy'` and keep only the ones whose outer call is one of these four functions; a `view(...)` wrapper is still allowed. Drop such a table on a freshly started server, before anything reads it, so the drop removes only the proxy and leaves the `TimeSeries` data intact. Do not use `DETACH TABLE` instead, because a detached definition can no longer be `ATTACH`ed. If metadata loading of such a table already fails after a restart, move the metadata file out of `store/` and restart: until then, unfiltered reads of `system.tables` can fail with `ASYNC_LOAD_WAIT_FAILED`. [#119786](https://github.com/ClickHouse/ClickHouse/pull/119786) ([Groene AI](https://github.com/groeneai)).
* Removed the `s3_disable_checksum` setting. It existed to skip a second read of the source data for the checksum of an S3 upload; the checksum is now computed during the single read, so there is nothing left to disable. [#119496](https://github.com/ClickHouse/ClickHouse/pull/119496) ([Azat Khuzhin](https://github.com/azat)).
* `Nullable(Tuple(...))` is now generally available and enabled by default. `Nullable(Tuple(...))` columns can be created without any setting, schema inference of nullable structs in the `Parquet`, `Arrow`, `ORC`, `Avro` and `JSON` formats returns `Nullable(Tuple(...))`, and a `Tuple` subcolumn extracted from a `Variant`, `Dynamic`, `JSON` or `Nullable(Tuple)` column is `Nullable(Tuple(...))` and `NULL` where the value is missing, instead of a tuple of default values. The previous behavior is available with `enable_nullable_tuple_type = 0` and `allow_nullable_tuple_in_extracted_subcolumns = 0`; the subcolumn setting is read at server startup, so it has to be set in the default profile. Upgrading existing tables whose partition keys, sorting keys, TTL expressions, or skip indexes depend on a tuple subcolumn extracted from a `Dynamic`, `Variant` or `Nullable(Tuple)` column or from a `JSON` path not declared as `Tuple(...)` is unsafe with the new default: tables may fail to attach, queries may fail, or data parts may be detached during startup. Before the first startup after upgrading, set `allow_nullable_tuple_in_extracted_subcolumns = 0` in the default profile, or preserve the previous behavior through `compatibility` in that profile. Changing the setting after parts have been detached does not restore them automatically; those parts must also be reattached. [#119222](https://github.com/ClickHouse/ClickHouse/pull/119222) ([Nihal Z. Miaji](https://github.com/nihalzp)).
* New setting `validate_group_by_all_key_types` (default `true`) gates the key-type validation that `GROUP BY ALL` applies to the grouping keys it expands the `SELECT` expressions into. Since 26.7 it rejects a `Variant` or `Dynamic` grouping key, for example an untyped JSON subpath, that earlier versions accepted with the analyzer enabled (the default), with no way to keep such a query running across an upgrade. Setting `compatibility` to a version before 26.7, or `validate_group_by_all_key_types = 0`, restores the earlier behavior. An explicit `GROUP BY` is unaffected and still rejects such a key, as it did before 26.7. Closes [#119852](https://github.com/ClickHouse/ClickHouse/issues/119852). [#119868](https://github.com/ClickHouse/ClickHouse/pull/119868) ([Groene AI](https://github.com/groeneai)).
#### New Feature
* `DISTINCT` can now spill data to disk, like external aggregation and external sort: the new settings `max_bytes_before_external_distinct` and `max_bytes_ratio_before_external_distinct` set the threshold; by default, spilling starts once query memory usage exceeds half the available memory under the applicable server or user memory limits, or as soon as the next hash table allocation would exceed it. [#116569](https://github.com/ClickHouse/ClickHouse/pull/116569) ([Nihal Z. Miaji](https://github.com/nihalzp)).
* Refreshable materialized views can now refresh incrementally with `REFRESH ... APPEND INCREMENTAL`, appending only the rows committed to the source table since the previous refresh instead of re-reading the whole source. [#114152](https://github.com/ClickHouse/ClickHouse/pull/114152) ([Smita Kulkarni](https://github.com/SmitaRKulkarni)). An incremental refresh into an `Iceberg` target is now exactly-once: the refresh cursor is committed atomically inside the `Iceberg` snapshot summary. [#114823](https://github.com/ClickHouse/ClickHouse/pull/114823) ([Smita Kulkarni](https://github.com/SmitaRKulkarni)).
* New `LIMIT` forms that select rows by boundary conditions instead of by position, following the stream order (use `ORDER BY` to define it): `LIMIT n AFTER cond` returns up to `n` rows starting at the first row where `cond` is true (`SELECT number FROM numbers(10) ORDER BY number LIMIT 3 AFTER number >= 5` returns `5, 6, 7`); `LIMIT UNTIL cond` returns the rows before the first row where `cond` is true (`LIMIT UNTIL number >= 3` returns `0, 1, 2`); `LIMIT AFTER cond1 UNTIL cond2` returns the rows between the two (`LIMIT AFTER number >= 2 UNTIL number >= 6` returns `2, 3, 4, 5`); `LIMIT n AFTER cond ALL` opens a range of `n` rows at every matching row and returns their union without duplicates (`LIMIT 2 AFTER number IN (2, 6) ALL` returns `2, 3, 6, 7`). [#99508](https://github.com/ClickHouse/ClickHouse/pull/99508) ([Zakhar Kravchuk](https://github.com/zakr600)).
* Added the `CREATE TOKEN` statement, which generates a random secret, adds it to the current user as an additional authentication method and returns it together with its expiration deadline: `CREATE TOKEN VALID FOR INTERVAL 30 DAY GRANTS (SELECT ON db.table)`. It is a convenient way to create tokens for applications: a token is tied to the user, can be limited in time and in privileges, and stops working when the user is deleted. Without an explicit `VALID UNTIL` or `VALID FOR` clause a token lives for `create_token_default_ttl_seconds`, 30 minutes by default. The statement requires the new `CREATE TOKEN` privilege, which also authorizes the equivalent `ALTER USER ADD IDENTIFIED ...` statement. [#116957](https://github.com/ClickHouse/ClickHouse/pull/116957) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Authentication methods in `CREATE USER` and `ALTER USER ... ADD IDENTIFIED` support a `GRANTS (SELECT ON db.table, ...)` clause which limits the access rights of sessions authenticated with that method to the intersection with the listed grants. This allows using additional credentials as tokens for applications: `ALTER USER vasya ADD IDENTIFIED WITH password BY '...' VALID UNTIL '2026-12-31' GRANTS (SELECT ON db.table)`. Closes [#109117](https://github.com/ClickHouse/ClickHouse/issues/109117). [#110144](https://github.com/ClickHouse/ClickHouse/pull/110144) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Added the SQL standard linear regression aggregate functions `regr_slope`, `regr_intercept`, `regr_r2`, `regr_count`, `regr_avgx`, `regr_avgy`, `regr_sxx`, `regr_syy` and `regr_sxy`. [#119347](https://github.com/ClickHouse/ClickHouse/pull/119347) ([mosya415](https://github.com/mosya415)).
* Added `MergeTree` settings `max_table_size_rows`, `max_table_size_bytes_compressed`, and `max_table_size_bytes_uncompressed`, which limit the total size of a table. The limits are checked at the start of `INSERT` and when new parts are committed, including the results of background merges and mutations, but not on replicated fetches. Closes [#115063](https://github.com/ClickHouse/ClickHouse/issues/115063). [#115069](https://github.com/ClickHouse/ClickHouse/pull/115069) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Added the `max_tables` database setting to limit the number of tables in `Atomic` and `Ordinary` databases. Every table-like object counts toward the limit, including tables, views, and dictionaries. [#115202](https://github.com/ClickHouse/ClickHouse/pull/115202) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Added bracket syntax for `JSON` subcolumns, such as `json['key1']['key2']`; the parser translates it to nested `arrayElement` calls. [#107039](https://github.com/ClickHouse/ClickHouse/pull/107039) ([Pavel Kruglov](https://github.com/Avogar)).
* Added the `system.statements` system table, which exposes the documentation of SQL statements such as their name, syntax, description, and examples. [#115341](https://github.com/ClickHouse/ClickHouse/pull/115341) ([Robert Schulze](https://github.com/rschu1ze)).
* Added virtual columns for the `Iceberg` v3 manifest fields `first_row_id` and `last_seq_num`. [#115603](https://github.com/ClickHouse/ClickHouse/pull/115603) ([Konstantin Vedernikov](https://github.com/scanhex12)). The same fields are now also written when inserting into an `Iceberg` v3 table. [#116171](https://github.com/ClickHouse/ClickHouse/pull/116171) ([Konstantin Vedernikov](https://github.com/scanhex12)).
* Added the opt-in `MergeTree` setting `skip_empty_columns_on_insert`, which avoids storing columns that contain only their type-default value. It requires `serialization_info_version = 'with_missing_columns'`; during rolling upgrades with servers that cannot read the new part metadata, keep the older serialization version. [#98472](https://github.com/ClickHouse/ClickHouse/pull/98472) ([Amos Bird](https://github.com/amosbird)).
* Added support for `+` and `-` between `DateTime` and `Time` data types. [#82980](https://github.com/ClickHouse/ClickHouse/pull/82980) ([Yarik Briukhovetskyi](https://github.com/yariks5s)).
* Added the `parseISO8601Duration` function, which parses ISO 8601 duration strings such as `PT1H30M` into seconds. [#116993](https://github.com/ClickHouse/ClickHouse/pull/116993) ([Navneet Kumar](https://github.com/navneet83)).
* Added the `type_json_skip_null_typed_paths` setting for `JSON`. When it is enabled, typed paths in `JSON` columns that have `NULL` values are treated as absent, matching the behavior of dynamic paths. Closes [#99191](https://github.com/ClickHouse/ClickHouse/issues/99191). [#106959](https://github.com/ClickHouse/ClickHouse/pull/106959) ([Pavel Kruglov](https://github.com/Avogar)).
* Added the `arrayFlattenedLength` function, which returns the total number of elements in a multidimensional array as if it was flattened with `arrayFlatten`. Unlike `cardinality` and `length`, which count only the elements of the outermost array, it counts elements at every nesting level, matching PostgreSQL's `cardinality`. [#113696](https://github.com/ClickHouse/ClickHouse/pull/113696) ([David Meng](https://github.com/davidmenggx)).
* `clickhouse-client` now accepts `--ssh-key-file` without a value: the key is looked up the same way as `ssh` does it, from `~/.ssh/config`, the default identity files such as `~/.ssh/id_ed25519`, and the keys held by `ssh-agent`. Authentication with a key held by `ssh-agent` is now supported without passing its path or passphrase explicitly. [#115072](https://github.com/ClickHouse/ClickHouse/pull/115072) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* The `splitByRegexp` tokenizer, used in text indexes and the `tokens` function, now accepts an optional `extract` argument. With `splitByRegexp(re, 1)`, `re` no longer acts as a separator: each match contributes at most one token, the first capture group of the match or the whole match if `re` has no capture group. [#116127](https://github.com/ClickHouse/ClickHouse/pull/116127) ([Jimmy Aguilar Mena](https://github.com/Ergus)).
* Added the `system.session_query_ids` system table, which contains the query ids of the queries executed in the current session, in execution order. It makes it easy to find "the queries I just ran" in `system.query_log` without assigning `query_id` client-side or tagging queries with `log_comment`, which is especially useful for testing and benchmarking. The history size is bounded per session by the new `session_query_ids_history_size` setting (default `1000`, `0` disables recording), and `TRUNCATE TABLE system.session_query_ids` clears the current session's history. [#110536](https://github.com/ClickHouse/ClickHouse/pull/110536) ([Vladimir Cherkasov](https://github.com/vdimir)).
* Added a zero-argument form of `year` that returns the current year, mirroring `now` and `today`: `year()` is equivalent to `toYear(today())`. `year` is now a function in its own right rather than a case-insensitive alias of `toYear`, and is reported non-deterministic, so `year()` is excluded from features that require a deterministic function: the query result cache, mutations of `Replicated*` tables, on-the-fly mutation application (`apply_mutations_on_fly`), mutation partition pruning, and the trivial-view pushdown to `Distributed` tables; use `toYear()` where determinism is required. Results, result types, index analysis and projection selection for `year()` are unchanged. [#109097](https://github.com/ClickHouse/ClickHouse/pull/109097) ([Groene AI](https://github.com/groeneai)).
* Added a memory fragmentation profiler for jemalloc. The new `system.jemalloc_sampled_allocations` table lists the sampled allocations that are currently alive, with their backtrace, age and size class; together with `system.jemalloc_arena_bins` it shows which code holds the allocations that keep fragmented slabs alive, and the same data is shown in a new "Fragmentation" tab of the jemalloc page of the server's web UI. [#115456](https://github.com/ClickHouse/ClickHouse/pull/115456) ([Azat Khuzhin](https://github.com/azat)).
* Support `BACKUP` and `RESTORE` for `WORKLOAD` and `RESOURCE` entities. SQL-defined `CREATE WORKLOAD` and `CREATE RESOURCE` definitions are now included when backing up `system.workloads` and `system.resources` and are recreated on restore, including `ON CLUSTER`. [#108431](https://github.com/ClickHouse/ClickHouse/pull/108431) ([Sergei Trifonov](https://github.com/serxa)).
* Added the `workload_admission_timeout_ms` query setting that bounds how long a query waits to acquire its workload query slot and memory reservation before failing. `0` (the default) keeps the previous unbounded wait. [#118852](https://github.com/ClickHouse/ClickHouse/pull/118852) ([Sergei Trifonov](https://github.com/serxa)).
* Added `mode = 'exclusive'` to the `S3Queue` engine: file processing is tracked only in the memory of the server, with no coordination through Keeper, for high-throughput ingestion on a single server, such as from a local `minio` instance. [#110552](https://github.com/ClickHouse/ClickHouse/pull/110552) ([Ivan Tkatchev](https://github.com/ivan-tkatchev)).
* Added the `nats_ca_file`, `nats_client_cert_file` and `nats_client_key_file` settings to the `NATS` engine, for verifying a broker certificate signed by a private CA and for client-certificate authentication. The feature was first proposed in [#69396](https://github.com/ClickHouse/ClickHouse/pull/69396) by [sidhmads](https://github.com/sidhmads). [#116117](https://github.com/ClickHouse/ClickHouse/pull/116117) ([Nikolay Degterinsky](https://github.com/evillique)).
* Added a four-letter-word command to `clickhouse-keeper` for the backpressure that the leader applies to slow Raft members. [#117728](https://github.com/ClickHouse/ClickHouse/pull/117728) ([Kseniia Sumarokova](https://github.com/kssenii)).
* Added the `keyValuePairs` text index tokenizer, which indexes a `Map(String, String)` column directly and answers `map['key'] = 'value'` from the index without reading the map column. [#115579](https://github.com/ClickHouse/ClickHouse/pull/115579) ([Jimmy Aguilar Mena](https://github.com/Ergus)).
#### Experimental Feature
* Added Prometheus HTTP API support for the `/api/v1/metadata`, `/api/v1/labels`, and `/api/v1/label//values` endpoints on `TimeSeries` tables. The `/api/v1/labels` endpoint returns the sorted unique label names of the matched time series, and `/api/v1/label//values` returns the sorted unique values of one label; both support the optional `match[]`, `start`, `end`, and `limit` parameters. [#116518](https://github.com/ClickHouse/ClickHouse/pull/116518) ([Nikita Mikhaylov](https://github.com/nikitamikhaylov)). [#116731](https://github.com/ClickHouse/ClickHouse/pull/116731) ([Nikita Mikhaylov](https://github.com/nikitamikhaylov)). [#117160](https://github.com/ClickHouse/ClickHouse/pull/117160) ([Nikita Mikhaylov](https://github.com/nikitamikhaylov)).
* Added the `/api/v1/format_query` endpoint of the Prometheus HTTP API. It parses a PromQL expression and returns its canonical form. [#117159](https://github.com/ClickHouse/ClickHouse/pull/117159) ([Nikita Mikhaylov](https://github.com/nikitamikhaylov)).
* Added an embedded SQL Console UI at `/ui` on the HTTP server. This is the same console that is available in ClickHouse Cloud - not to be confused with the Web UI. [#100406](https://github.com/ClickHouse/ClickHouse/pull/100406) ([Luis Neves](https://github.com/lneves12)).
* Reimplemented the experimental `KQL` (Kusto) dialect with a dedicated lexer and parser instead of translating it to SQL text and reparsing it. This fixes expression-injection in string operators such as `contains` and `has`, several results that disagreed with Kusto such as `7 / 2`, `substring` with a negative start, and `bin`, and functions that were registered but did nothing. Unsupported syntax is now rejected instead of being mistranslated. [#112932](https://github.com/ClickHouse/ClickHouse/pull/112932) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Added an experimental `trino` value of the `dialect` setting (gated by `enable_trino_dialect`): queries written in Trino SQL are translated to ClickHouse SQL, including Trino-specific syntax (`ARRAY[...]` literals, `TRY_CAST`, `UNNEST`, `ROW` constructors and types, `VALUES` tables, `OFFSET` before `LIMIT`, `FETCH`) and a mapping of several hundred Trino function names and argument conventions to their ClickHouse equivalents. Bitwise shifts over untyped integer literals now match Trino semantics. [#115383](https://github.com/ClickHouse/ClickHouse/pull/115383) ([Alexey Milovidov](https://github.com/alexey-milovidov)). [#119430](https://github.com/ClickHouse/ClickHouse/pull/119430) ([Ethan Lin](https://github.com/linsen458-spec)).
* Added the `hierarchicalKMeans` and `assignCentroid` functions, building blocks for IVF-style vector search. [#112309](https://github.com/ClickHouse/ClickHouse/pull/112309) ([Shankar Iyer](https://github.com/shankar-iyer)).
* Added `SELECT` support for `TimeSeries` tables. [#115622](https://github.com/ClickHouse/ClickHouse/pull/115622) ([Vitaly Baranov](https://github.com/vitlibar)).
* `TimeSeries` tables now derive their inner engine family from `default_table_engine`, require all inner tables to use the same replication family, and always pin `recent_samples_ttl_seconds` into `SETTINGS` for `RECENT SAMPLES` targets. [#115922](https://github.com/ClickHouse/ClickHouse/pull/115922) ([Vitaly Baranov](https://github.com/vitlibar)).
* Added PromQL support for `absent` and `count_values`, including range queries and `by`/`without` aggregation modifiers. [#112795](https://github.com/ClickHouse/ClickHouse/pull/112795) ([Valery Petrov](https://github.com/valerypetrov)).
* PromQL now supports the range functions `sum_over_time`, `avg_over_time`, `count_over_time`, `present_over_time`, `absent_over_time`, `quantile_over_time`, and `predict_linear`. [#112353](https://github.com/ClickHouse/ClickHouse/pull/112353) ([Valery Petrov](https://github.com/valerypetrov)). [#112842](https://github.com/ClickHouse/ClickHouse/pull/112842) ([Valery Petrov](https://github.com/valerypetrov)).
* The `TimeSeries` table engine now supports dictionary-encoded series identifiers: the `id` column can be declared with a `LowCardinality` type, and new tables use `Tuple(UInt64, LowCardinality(UUID))` by default while existing tables keep their declared `id` type. The previous layout remains available through `TAGS INNER COLUMNS (id Tuple(UInt64, UUID))`, and the new layout gives a 1.16x geometric-mean PromQL speedup in the benchmark. [#117033](https://github.com/ClickHouse/ClickHouse/pull/117033) ([Nikita Mikhaylov](https://github.com/nikitamikhaylov)).
* `timeSeriesGroupArray` is now supported in `SimpleAggregateFunction`, and the `timeSeries*ToGrid` functions now also accept the samples as a single `Array(Tuple(timestamp, value))` argument. [#117340](https://github.com/ClickHouse/ClickHouse/pull/117340) ([Vitaly Baranov](https://github.com/vitlibar)). [#117341](https://github.com/ClickHouse/ClickHouse/pull/117341) ([Vitaly Baranov](https://github.com/vitlibar)).
* `TimeSeries` tables now expose the outer samples column as `samples` instead of `time_series`. `INSERT INTO ts_new SELECT * FROM ts_old` still works because the column order is unchanged. [#119225](https://github.com/ClickHouse/ClickHouse/pull/119225) ([Vitaly Baranov](https://github.com/vitlibar)). The `METRICS` target is renamed to `METRIC FAMILIES`, which is what that inner table actually holds; `METRICS` keeps working as an alias. [#119227](https://github.com/ClickHouse/ClickHouse/pull/119227) ([Vitaly Baranov](https://github.com/vitlibar)).
* Distributed query plans (`make_distributed_plan`) now stop idle upstream stages promptly after a satisfied `LIMIT`, instead of continuing to read and compute data that nobody consumes. They also no longer stall when the initiator pipeline has only one execution thread, because waiting for distributed plan stages no longer occupies that thread. Plans with many nodes now honor the query's `max_threads` in worker fragments, so they no longer exhaust the server thread pool or outlive `max_execution_time`; `use_concurrency_control` is disabled automatically for these queries because it can starve worker tasks while they wait on exchange sockets. Plans with many finished stages also no longer pay up to 100 ms of idle waiting per stage while draining completed stages, which speeds up multi-join queries several times in some cases. The data sent between nodes is now also serialized on all threads of a task instead of one thread per destination, removing a bottleneck when a query runs on a small number of workers. [#115690](https://github.com/ClickHouse/ClickHouse/pull/115690) ([Alexander Gololobov](https://github.com/davenger)). [#116017](https://github.com/ClickHouse/ClickHouse/pull/116017) ([Alexey Milovidov](https://github.com/alexey-milovidov)). [#116300](https://github.com/ClickHouse/ClickHouse/pull/116300) ([Groene AI](https://github.com/groeneai)). [#116878](https://github.com/ClickHouse/ClickHouse/pull/116878) ([Alexander Gololobov](https://github.com/davenger)). [#117328](https://github.com/ClickHouse/ClickHouse/pull/117328) ([Alexander Gololobov](https://github.com/davenger)). [#119067](https://github.com/ClickHouse/ClickHouse/pull/119067) ([Alexander Gololobov](https://github.com/davenger)).
* `parallel_replicas_plan_based` can now collect runtime statistics and automatically enable parallel replicas for supported queries. [#115788](https://github.com/ClickHouse/ClickHouse/pull/115788) ([Igor Nikonov](https://github.com/devcrafter)).
* A `Merge` table can now be read with parallel replicas: reads from the underlying `MergeTree` tables are coordinated across replicas, and aggregations and joins above them are distributed too. Enabled by the `parallel_replicas_allow_merge_tables` setting together with `parallel_replicas_plan_based`. [#115001](https://github.com/ClickHouse/ClickHouse/pull/115001) ([Igor Nikonov](https://github.com/devcrafter)).
* Added experimental support for the `silk` fiber runtime, enabled with the `enable_silk_runtime` server setting. When it is enabled, subsystems that support it can run jobs on fibers instead of occupying an operating-system thread while waiting for I/O. [#112667](https://github.com/ClickHouse/ClickHouse/pull/112667) ([Miсhael Stetsyuk](https://github.com/mstetsyuk)).
* Adaptive codec selection (`enable_adaptive_codec_selection`) for `MergeTree` now also applies to columns without a specialized candidate codec: when no type-specific codec candidate exists, each block is written with whichever of the table's default codec and `NONE` compresses it smaller, so incompressible data is no longer stored larger than raw. For `Float32` and `Float64` columns it now also considers the `ALP` codec. [#115639](https://github.com/ClickHouse/ClickHouse/pull/115639) ([Raufs Dunamalijevs](https://github.com/rienath)). [#117553](https://github.com/ClickHouse/ClickHouse/pull/117553) ([Raufs Dunamalijevs](https://github.com/rienath)).
* Added aggregation pushdown below `JOIN` (eager aggregation) to the experimental Cascades optimizer as a cost-based alternative: a partial aggregation is performed on one join input before the join and merged above it, or, when the join provably neither duplicates nor null-extends the aggregated side and the join keys are a subset of the `GROUP BY` keys, the aggregation is pushed below the join entirely. Controlled by the new setting `cascades_aggregation_pushdown` (enabled by default; takes effect only with `enable_cascades_optimizer = 1` and `make_distributed_plan = 1`). [#115354](https://github.com/ClickHouse/ClickHouse/pull/115354) ([Dmitry Novik](https://github.com/novikd)).
* Queries with `INTERSECT` and `EXCEPT` now work under the experimental `make_distributed_plan` setting. [#116563](https://github.com/ClickHouse/ClickHouse/pull/116563) ([Alexander Gololobov](https://github.com/davenger)). When `make_distributed_plan` is enabled and no distributed plan can be built, the query falls back to local execution. [#116487](https://github.com/ClickHouse/ClickHouse/pull/116487) ([Antonio Filipovic](https://github.com/antoniofilipovic)). A failing `make_distributed_plan = 1` query reports the error of the task that failed, not the closed exchange connection that failure caused; worker task failures reach the client with the worker's error code. [#118390](https://github.com/ClickHouse/ClickHouse/pull/118390) ([Groene AI](https://github.com/groeneai)).
* Fixed `Column '__text_index_...' not found in table` and `Query builder not found for text search query` when a query using a text index read with `parallel_replicas_plan_based` enabled. [#116363](https://github.com/ClickHouse/ClickHouse/pull/116363) ([Igor Nikonov](https://github.com/devcrafter)).
* `parallel_replicas_plan_based` now supports `RIGHT JOIN` and `ORDER BY ... WITH FILL`; when the analyzer is disabled, the query runs locally instead of falling back to query-based parallel replicas, because plan-based parallel replicas are not supported there. [#113515](https://github.com/ClickHouse/ClickHouse/pull/113515) ([Groene AI](https://github.com/groeneai)). [#116135](https://github.com/ClickHouse/ClickHouse/pull/116135) ([Igor Nikonov](https://github.com/devcrafter)). [#118781](https://github.com/ClickHouse/ClickHouse/pull/118781) ([Igor Nikonov](https://github.com/devcrafter)).
* Adaptive codec selection (`enable_adaptive_codec_selection`) now applies to every substream of a column, such as `Array` and `String` sizes and null maps, instead of the main data stream only. [#117348](https://github.com/ClickHouse/ClickHouse/pull/117348) ([Raufs Dunamalijevs](https://github.com/rienath)).
* WebAssembly UDFs now split an input block that would not fit into the guest's linear memory into smaller batches, sized by the input's measured serialized size. The new setting `webassembly_udf_input_split_memory_ratio` controls how much of the linear memory one call's input may occupy. [#116552](https://github.com/ClickHouse/ClickHouse/pull/116552) ([Vasily Chekalkin](https://github.com/bacek)). A UDF using the `BUFFERED_V1` ABI that returns a result buffer with a non-zero size but a data pointer at linear-memory offset `0` is now rejected instead of unrelated memory being read. [#116548](https://github.com/ClickHouse/ClickHouse/pull/116548) ([Vasily Chekalkin](https://github.com/bacek)).
* The experimental `ReaderExecutor` now shrinks its read window and block size under memory pressure, configured via `reader_executor_memory_pressure_{elevated,high,critical}_level_pct`; its default read window is now 8 MiB. [#115635](https://github.com/ClickHouse/ClickHouse/pull/115635) ([Sema Checherinda](https://github.com/CheSema)).
* PromQL: implemented the `max_over_time` and `min_over_time` functions. [#112354](https://github.com/ClickHouse/ClickHouse/pull/112354) ([Valery Petrov](https://github.com/valerypetrov)). PromQL now also parses legacy octal numeric literals with Prometheus-compatible semantics. [#113586](https://github.com/ClickHouse/ClickHouse/pull/113586) ([Minh Vu](https://github.com/fallintoplace)). `sgn` now preserves `NaN` and negative zero. [#113747](https://github.com/ClickHouse/ClickHouse/pull/113747) ([Minh Vu](https://github.com/fallintoplace)). `stddev` and `stdvar` no longer return `NaN` for large finite values whose variance is representable. [#114250](https://github.com/ClickHouse/ClickHouse/pull/114250) ([Minh Vu](https://github.com/fallintoplace)).
* PromQL no longer counts consecutive `NaN` samples as changes. [#113744](https://github.com/ClickHouse/ClickHouse/pull/113744) ([Minh Vu](https://github.com/fallintoplace)).
* `CREATE TABLE ... ENGINE = DeltaLake(...)` can now create a new `DeltaLake` table, writing the initial commit through `delta-kernel-rs`, attach to an existing `_delta_log`, or register an existing table into a Unity catalog. It is gated behind the new `allow_delta_lake_create_table` setting; creating a partitioned table (`PARTITION BY`) is not supported yet. Writes to a `DeltaLake` table now cast values to the Delta write-schema type with an accurate cast that throws when a value does not fit the target type, for example `300` written into a Delta `byte`, instead of silently truncating; the new `delta_lake_accurate_write_cast` setting, enabled by default, controls this, and `compatibility` below `26.9` restores the previous truncating behavior. [#106011](https://github.com/ClickHouse/ClickHouse/pull/106011) ([Smita Kulkarni](https://github.com/SmitaRKulkarni)).
#### Performance Improvement
* Reduced memory usage and query-plan optimization time for keyed aggregations over large constant-folded literals by hashing the aggregation hash-table-statistics cache key while it is serialized instead of accumulating a full copy in memory first. For an 80 MB literal, peak memory drops by about 250 MB and optimization time by about 2.5x. [#115847](https://github.com/ClickHouse/ClickHouse/pull/115847) ([Groene AI](https://github.com/groeneai)).
* Added the `query_plan_aggregation_bucket_top_k` setting (enabled by default) to control the optimization that keeps only each two-level aggregation bucket's best `n` groups when a final aggregation feeds `ORDER BY ... LIMIT n`. The optimization is now visible in `EXPLAIN` output. [#116124](https://github.com/ClickHouse/ClickHouse/pull/116124) ([Nihal Z. Miaji](https://github.com/nihalzp)).
* A `WHERE` equality is now merged into the `JOIN` condition even when its operands have different types but a common supertype, such as `Int32` and `Nullable(Int32)`. This lets more `CROSS JOIN`s be rewritten to `INNER JOIN`s. [#112630](https://github.com/ClickHouse/ClickHouse/pull/112630) ([Hechem Selmi](https://github.com/m-selmi)).
* Improved performance of merges of text indexes. [#114525](https://github.com/ClickHouse/ClickHouse/pull/114525) ([Anton Popov](https://github.com/CurtizJ)).
* Reduce CPU usage of the post-filter used by `IN` and `NOT IN` predicates. [#111690](https://github.com/ClickHouse/ClickHouse/pull/111690) ([Elmi Ahmadov](https://github.com/ahmadov)).
* The `arrayJoin` function syntax is now planned as the `ARRAY JOIN` operator internally, so it can use the same `ARRAY JOIN` optimizations. A filter on a column produced by `ARRAY JOIN` is pushed into the array before it is expanded, so elements that do not match are never turned into rows and other columns are not replicated for them, which speeds up selective `ARRAY JOIN ... WHERE` queries over wide rows. A follow-up reduces the fused path's per-block overhead by avoiding per-window filter copies and computing survivor offsets only when eager replication needs them. Controlled by the `query_plan_fuse_filter_into_array_join` setting. [#115474](https://github.com/ClickHouse/ClickHouse/pull/115474) ([Yarik Briukhovetskyi](https://github.com/yariks5s)). [#116910](https://github.com/ClickHouse/ClickHouse/pull/116910) ([Yarik Briukhovetskyi](https://github.com/yariks5s)). [#117660](https://github.com/ClickHouse/ClickHouse/pull/117660) ([Yarik Briukhovetskyi](https://github.com/yariks5s)).
* Fixed a performance regression where a query combining a text index filter with `ORDER BY ... LIMIT` stopped answering the filter from the index and read the whole text column instead. [#115586](https://github.com/ClickHouse/ClickHouse/pull/115586) ([Jimmy Aguilar Mena](https://github.com/Ergus)).
* Speed up query pipeline construction for queries with large expressions or many streams by computing each plan step's output header once instead of once per stream. For a ClickBench Q29-like query on a 96-core machine, this removes about a third of the hot query time. [#115677](https://github.com/ClickHouse/ClickHouse/pull/115677) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Speed up building the hash table of an `ANY`, `SEMI`, or `ANTI JOIN` when the right side repeats the same join keys many times. [#115820](https://github.com/ClickHouse/ClickHouse/pull/115820) ([Nikita Taranov](https://github.com/nickitat)).
* Speed up random data generation. `rand`, `rand64`, `randConstant`, `randomString`, `randomFixedString`, `generateUUIDv4`, `generateUUIDv7`, and `dateTimeToUUIDv7` now generate bytes with ARS (reduced-round AES in counter mode) wherever the CPU has AES instructions: on AArch64 chosen at build time, on x86-64 chosen at run time when VAES is present. Targets and CPUs without those instructions keep the previous generator unchanged. A follow-up reduced the fixed setup cost on x86-64, which is noticeable when blocks are small. [#116133](https://github.com/ClickHouse/ClickHouse/pull/116133) ([Groene AI](https://github.com/groeneai)). [#116158](https://github.com/ClickHouse/ClickHouse/pull/116158) ([Raúl Marín](https://github.com/Algunenano)).
* Fix a CPU regression for queries that issue many independent small reads against the same `MergeTree` part when the table has `LowCardinality` columns. Such queries on tables with a small `index_granularity` were up to several times slower since 26.6. [#116134](https://github.com/ClickHouse/ClickHouse/pull/116134) ([Groene AI](https://github.com/groeneai)).
* Speed up `GROUP BY` without aggregates by inlining some functions and by starting prefetching at the same cardinality as `GROUP BY` with aggregates, which helps when the hash table stops fitting in the L2 cache. [#115840](https://github.com/ClickHouse/ClickHouse/pull/115840) ([Nikita Taranov](https://github.com/nickitat)). [#116267](https://github.com/ClickHouse/ClickHouse/pull/116267) ([Nikita Taranov](https://github.com/nickitat)).
* Use the `bloom_filter` skip index for `IN` predicates on a directly indexed column when `transform_null_in = 1` and the `IN` set contains no `NULL` values. Previously the index was skipped for such queries, forcing a full scan. [#111329](https://github.com/ClickHouse/ClickHouse/pull/111329) ([Groene AI](https://github.com/groeneai)).
* The adaptive `GROUP BY` aggregation (`enable_adaptive_aggregator`) now falls back to the ordinary algorithm when rare keys or aggregate arguments are too wide to copy profitably, so aggregations over heavy string columns run at the ordinary algorithm's speed and memory usage. Adds `adaptive_aggregator_freeze_threshold_bytes` to bound each thread's frozen table in bytes. [#115755](https://github.com/ClickHouse/ClickHouse/pull/115755) ([Nihal Z. Miaji](https://github.com/nihalzp)).
* Lightweight `UPDATE` queries now write patch parts that carry the table's sort-key columns, so applying a patch no longer has to hold the whole patch part in memory. [#116007](https://github.com/ClickHouse/ClickHouse/pull/116007) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Added an alternative row-major payload layout for hash joins to speed up join output reconstruction. Controlled by `enable_hash_join_row_store` (default `true`) and `min_rows_ratio_for_hash_join_row_store` (default `5`). A probe that emits no right-side columns, such as `SELECT count()`, no longer publishes a fake zero match count into the row-store cache, so a later full-output run can still use the row-store optimization. Closes [#117260](https://github.com/ClickHouse/ClickHouse/issues/117260). [#104884](https://github.com/ClickHouse/ClickHouse/pull/104884) ([Hechem Selmi](https://github.com/m-selmi)). [#117410](https://github.com/ClickHouse/ClickHouse/pull/117410) ([Groene AI](https://github.com/groeneai)).
* The `IEJoin` algorithm now chooses which two `JOIN ON` inequality conditions to use as its key conditions by their estimated selectivity from the column min/max statistics, instead of taking the first two in syntax order. The remaining conditions are evaluated per candidate pair, so picking the most selective pair can speed up such joins by orders of magnitude. [#115790](https://github.com/ClickHouse/ClickHouse/pull/115790) ([Vladimir Cherkasov](https://github.com/vdimir)).
* A `bloom_filter` skip index on an `Array` column is now used for `arrayJoin(column) IN (set)`, `arrayJoin(column) GLOBAL IN (set)`, and `arrayJoin(column) = const`, the same way it was already used for `hasAny(column, set)` and `has(column, const)`. Previously these `arrayJoin` forms fell back to a full scan. [#109536](https://github.com/ClickHouse/ClickHouse/pull/109536) ([Groene AI](https://github.com/groeneai)).
* Reduce cancellation latency for distributed queries that use parallel replicas by not waiting for a replica's initial announcement after the query is already cancelled. [#114862](https://github.com/ClickHouse/ClickHouse/pull/114862) ([Nikita Taranov](https://github.com/nickitat)).
* Speed up reading `system.tables` by not copying the query context for every row. [#115867](https://github.com/ClickHouse/ClickHouse/pull/115867) ([Nikolay Degterinsky](https://github.com/evillique)).
* Speed up `Array(LowCardinality(T))` aggregations by preserving dictionary identity. [#115961](https://github.com/ClickHouse/ClickHouse/pull/115961) ([Ivan Babrou](https://github.com/bobrik)).
* Improved the performance of the `roundDuration` and `roundAge` functions on AArch64 by rewriting their comparison cascades into a branchless form that the compiler can auto-vectorize. Results are unchanged. [#116164](https://github.com/ClickHouse/ClickHouse/pull/116164) ([Groene AI](https://github.com/groeneai)).
* Avoid extremely slow `BACKUP` of a `Memory` or `KeeperMap` table when `max_compress_block_size` is set to a small value by sizing the temporary file stream with `temporary_files_buffer_size`. [#116233](https://github.com/ClickHouse/ClickHouse/pull/116233) ([Groene AI](https://github.com/groeneai)).
* Speed up server shutdown for databases with many tables by shutting tables down in parallel. Controlled by the new `database_catalog_shutdown_table_concurrency` setting; `0` means the number of CPU cores. [#104969](https://github.com/ClickHouse/ClickHouse/pull/104969) ([Jayme Bird](https://github.com/jaymebrd)).
* `arrayElement` and `arraySlice` now read lazily replicated arrays (produced by `ARRAY JOIN` and `JOIN` when `enable_lazy_columns_replication` is enabled) directly, without materializing them. This reduces memory usage and speeds up queries that index or slice a large array. [#112304](https://github.com/ClickHouse/ClickHouse/pull/112304) ([Diego Gomes Tomé](https://github.com/diegomestre2)).
* `A UNION DISTINCT B` now deduplicates each branch in parallel before merging them, the same way its `SELECT DISTINCT * FROM (A UNION ALL B)` rewrite already did. Previously the query funneled every row through a single thread, so it did not scale with `max_threads`. [#115173](https://github.com/ClickHouse/ClickHouse/pull/115173) ([Groene AI](https://github.com/groeneai)).
* Speed up regular-expression searches for simple anchored literals, including prefix, suffix, exact-literal, and escaped-literal matches. [#116554](https://github.com/ClickHouse/ClickHouse/pull/116554) ([Elmi Ahmadov](https://github.com/ahmadov)). [#117331](https://github.com/ClickHouse/ClickHouse/pull/117331) ([Elmi Ahmadov](https://github.com/ahmadov)).
* Reduce CPU and memory overhead of `TTL` deletions during merges: blocks are now filtered in one vectorized pass instead of being rebuilt column by column, and a block with nothing to delete is passed through untouched instead of being copied. [#116623](https://github.com/ClickHouse/ClickHouse/pull/116623) ([Shaohua Wang](https://github.com/tiandiwonder)).
* Optimize one-argument date conversions on `Date` and `DateTime` columns. [#114267](https://github.com/ClickHouse/ClickHouse/pull/114267) ([Ivan Babrou](https://github.com/bobrik)).
* `clickhouse-local` now attaches the `system` and `information_schema` tables on first access instead of at startup. [#115489](https://github.com/ClickHouse/ClickHouse/pull/115489) ([Konstantin Bogdanov](https://github.com/thevar1able)).
* Speed up `GRANT`, `REVOKE`, and `SHOW GRANTS` for users with many grants by avoiding a deep copy of the access-rights tree when it is only read. [#115696](https://github.com/ClickHouse/ClickHouse/pull/115696) ([miao tang](https://github.com/a819721810)).
* Reduce memory usage when inserting into a wide `MergeTree` part that writes many more streams than it has columns, for example a table with a few bucketed `Map` columns. The `min_columns_to_activate_adaptive_write_buffer` setting is now compared against the number of streams the part writes, since one write buffer is allocated per stream. [#115759](https://github.com/ClickHouse/ClickHouse/pull/115759) ([Groene AI](https://github.com/groeneai)).
* Fixed a performance regression since 26.6: a query filtering a `Nullable` column with `IN (subquery)` read the whole table instead of skipping the read when the subquery returned no rows. Closes [#116450](https://github.com/ClickHouse/ClickHouse/issues/116450). [#116538](https://github.com/ClickHouse/ClickHouse/pull/116538) ([Yarik Briukhovetskyi](https://github.com/yariks5s)).
* Fixed quadratic complexity of `groupConcat` over a `FixedString` argument. The whole argument column was converted to `String` once per row, so a query over 400,000 rows took 45 seconds instead of 0.1 seconds and could overrun its `max_execution_time`, which is only checked between blocks. [#116795](https://github.com/ClickHouse/ClickHouse/pull/116795) ([Groene AI](https://github.com/groeneai)).
* Push a `WHERE` condition on a `USING` column through a `RIGHT JOIN` so the left `MergeTree` input can use it as a primary-key index condition, even when the join keys have different types. Applies with `enable_analyzer = 1`. [#103478](https://github.com/ClickHouse/ClickHouse/pull/103478) ([Manuel](https://github.com/raimannma)).
* Reduce memory usage of Parquet dictionary-based row-group pruning (`input_format_parquet_dictionary_filter_push_down`) several times by hashing integer dictionaries directly and keeping the value set as a sorted vector instead of a hash table. [#115744](https://github.com/ClickHouse/ClickHouse/pull/115744) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Reading dictionary-encoded `Parquet` data is now faster: dictionary indexes are decoded and resolved to values in one fused pass, turning runs of a repeated value into bulk fills instead of per-row gathers, for about 20% faster scans of dictionary-encoded numeric columns. [#115819](https://github.com/ClickHouse/ClickHouse/pull/115819) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Speed up some `PREWHERE` queries with text indexes by placing text-index lookups and other zero-size-column predicates before expensive predicates on the indexed column. [#116546](https://github.com/ClickHouse/ClickHouse/pull/116546) ([Jimmy Aguilar Mena](https://github.com/Ergus)).
* Speed up the `numbers` table function, sorting, and other bulk index fills on AArch64 by improving code generation of their sequential-fill loops. Results and x86-64/macOS code generation are unchanged. [#116616](https://github.com/ClickHouse/ClickHouse/pull/116616) ([Groene AI](https://github.com/groeneai)).
* Speed up `groupUniqArray` for 8-bit types (`UInt8`, `Int8`, `Enum8`, `Bool`) by using a 256-bit bitmap instead of a hash set. [#116880](https://github.com/ClickHouse/ClickHouse/pull/116880) ([Manuel](https://github.com/raimannma)).
* Writing rows in JSON output formats that emit object keys, including `JSONEachRow` and its aliases, `PrettyJSONEachRow`, `JSON`, `JSONStrings`, `JSONStringsEachRow`, `JSONObjectEachRow`, and `GeoJSON`, is now faster because each field name is no longer copied into a temporary string and re-measured for every row. Compact formats that emit no keys are unchanged. [#117082](https://github.com/ClickHouse/ClickHouse/pull/117082) ([Groene AI](https://github.com/groeneai)).
* Fixed a performance regression introduced in 26.4 when writing `JSON` and `Dynamic` columns in text formats, including `Dynamic(JSON)` text output. [#115852](https://github.com/ClickHouse/ClickHouse/pull/115852) ([Pavel Kruglov](https://github.com/Avogar)). [#117655](https://github.com/ClickHouse/ClickHouse/pull/117655) ([Nikita Fomichev](https://github.com/fm4v)).
* Speed up repeated insertion of the same `LowCardinality` value into an in-memory column, for example during joins. [#115020](https://github.com/ClickHouse/ClickHouse/pull/115020) ([Minh Vu](https://github.com/fallintoplace)).
* Correlated subqueries with equality on columns that differ only in nullability, or on native-number columns with a least common type, are now decorrelated via equivalent-expression substitution instead of falling back to a `CROSS JOIN` with a post-join filter. This avoids severe memory growth on such queries. Closes [#113407](https://github.com/ClickHouse/ClickHouse/issues/113407). [#115493](https://github.com/ClickHouse/ClickHouse/pull/115493) ([Dmitry Novik](https://github.com/novikd)).
* Speed up division and modulo of `Int128`, `UInt128`, and `Decimal128` values that fit in 64 bits. `Decimal128` rounding with `round`, `floor`, `ceil`, `trunc`, and `roundBankers` is 1.5x faster on x86-64, and gains more on architectures that have no 128-bit divide instruction. Results are unchanged. [#116199](https://github.com/ClickHouse/ClickHouse/pull/116199) ([Groene AI](https://github.com/groeneai)).
* Functions with several SIMD implementations, including `MD5`, `SHA1`, hashing functions, `greatCircleDistance`, and `geoDistance`, now choose one from the CPU's capabilities instead of benchmarking them at runtime. `MD5` becomes 2-3.7x faster. The `function_implementation` setting is obsolete and has no effect. [#116501](https://github.com/ClickHouse/ClickHouse/pull/116501) ([Raúl Marín](https://github.com/Algunenano)).
* Speed up `dotProductTransposed` on `QBit` columns with floating-point element types on hosts where SimSIMD has no vectorized dot kernel, which for `Float64` means AArch64 and x86 without AVX-512. The reduction now uses independent partial sums instead of a single accumulator, so its summation order changes. Closes [#116784](https://github.com/ClickHouse/ClickHouse/issues/116784). [#116816](https://github.com/ClickHouse/ClickHouse/pull/116816) ([Groene AI](https://github.com/groeneai)).
* Reduce jemalloc fragmentation by lowering `lg_extent_max_active_fit` to its default value `6`. [#116836](https://github.com/ClickHouse/ClickHouse/pull/116836) ([Azat Khuzhin](https://github.com/azat)).
* Speed up `formatDateTime` with non-constant time zone arguments by caching resolved time zones locally. [#116851](https://github.com/ClickHouse/ClickHouse/pull/116851) ([Robert Schulze](https://github.com/rschu1ze)).
* PromQL selector scans over `TimeSeries` tables are now parallelized, which speeds up reads of the narrow, decode-heavy samples table columns. [#116932](https://github.com/ClickHouse/ClickHouse/pull/116932) ([Nikita Mikhaylov](https://github.com/nikitamikhaylov)).
* Speed up conversion of `TimeSeries` tag arrays by reserving the final output size up front and by building extracted tag values and `NULL` maps in one pass. [#115620](https://github.com/ClickHouse/ClickHouse/pull/115620) ([Minh Vu](https://github.com/fallintoplace)). [#115687](https://github.com/ClickHouse/ClickHouse/pull/115687) ([Minh Vu](https://github.com/fallintoplace)).
* Speed up `timeSeriesGroupArray` when the input samples are already sorted by timestamp. [#117703](https://github.com/ClickHouse/ClickHouse/pull/117703) ([Vitaly Baranov](https://github.com/vitlibar)).
* The `Native` protocol now batches end-of-query control messages into a single socket write by default, and `sync` now flushes them immediately. This removes one round trip of latency per query for clients on high-latency connections that idle between queries. [#111034](https://github.com/ClickHouse/ClickHouse/pull/111034) ([Kaviraj Kanagaraj](https://github.com/kavirajk)).
* Phrase search in text indexes now stores positions in packed blocks and reads only the blocks that cover candidate rows, reducing position-data reads and memory usage. [#111550](https://github.com/ClickHouse/ClickHouse/pull/111550) ([Elmi Ahmadov](https://github.com/ahmadov)).
* Appending many default values to `Array` and `String` columns now pre-sizes the offsets array, reducing reallocations and peak memory usage. [#113577](https://github.com/ClickHouse/ClickHouse/pull/113577) ([Groene AI](https://github.com/groeneai)).
* The preliminary per-stream `DISTINCT` now abandons deduplication when the input is almost entirely unique, freeing its hash tables because the final `DISTINCT` still deduplicates the output. This roughly halves memory usage and speeds up `SELECT DISTINCT` on unique data. Controlled by `allow_preliminary_distinct_abandoning` and observable via `DistinctTransformsAbandonedDeduplication`. [#116508](https://github.com/ClickHouse/ClickHouse/pull/116508) ([Nihal Z. Miaji](https://github.com/nihalzp)).
* PromQL instant-vector responses now reuse the formatted evaluation timestamp within each result block. [#115567](https://github.com/ClickHouse/ClickHouse/pull/115567) ([Minh Vu](https://github.com/fallintoplace)).
* Speed up `TimeSeries` reads by writing sampling keys directly into the result column. [#115683](https://github.com/ClickHouse/ClickHouse/pull/115683) ([Minh Vu](https://github.com/fallintoplace)).
* Reduce lock contention and per-lookup allocations during serialization by sharding the object pool. [#116869](https://github.com/ClickHouse/ClickHouse/pull/116869) ([Manuel](https://github.com/raimannma)).
* `LIKE ... ESCAPE 'c'` and `ILIKE ... ESCAPE 'c'` can now use skip indexes instead of falling back to a full scan. `TYPE text` indexes prune granules for both; `LIKE ... ESCAPE 'c'` can also use the `ngrambf_v1`, `tokenbf_v1`, and `sparse_grams` indexes, and `NOT LIKE ... ESCAPE 'c'` can use `bloom_filter` skip indexes and the primary key when applicable, matching plain `NOT LIKE`. `TYPE text` indexes still do not support `NOT LIKE`. [#105848](https://github.com/ClickHouse/ClickHouse/pull/105848) ([Groene AI](https://github.com/groeneai)).
* Distributed `ORDER BY` query plans can now use `read in order` when the query order matches the table's sorting key, and projections can reuse that base-table in-order read too. [#115244](https://github.com/ClickHouse/ClickHouse/pull/115244) ([Shankar Iyer](https://github.com/shankar-iyer)). [#116854](https://github.com/ClickHouse/ClickHouse/pull/116854) ([Mikhail Artemenko](https://github.com/Michicosun)).
* Slightly speed up `INSERT` into `JSON` columns by making typed-path default insertion cheaper. [#107359](https://github.com/ClickHouse/ClickHouse/pull/107359) ([Pavel Kruglov](https://github.com/Avogar)).
* Added the `query_plan_lift_predicate_across_join` optimization, which copies equi-join filter conjuncts across `MergeTree` join inputs for better primary-key pruning. It speeds up some queries by 70-80x. [#108377](https://github.com/ClickHouse/ClickHouse/pull/108377) ([Yarik Briukhovetskyi](https://github.com/yariks5s)).
* Automatic parallel replicas now share prepared sets with the probe plan instead of executing them twice. [#114231](https://github.com/ClickHouse/ClickHouse/pull/114231) ([Nikita Taranov](https://github.com/nickitat)).
* Supported `LIKE` and `ILIKE` patterns can now use text indexes. [#114728](https://github.com/ClickHouse/ClickHouse/pull/114728) ([Elmi Ahmadov](https://github.com/ahmadov)).
* Improve generic `arrayReverse` performance by reserving space for all nested elements. [#115011](https://github.com/ClickHouse/ClickHouse/pull/115011) ([Minh Vu](https://github.com/fallintoplace)).
* `LEFT ANTI JOIN` and `LEFT SEMI JOIN`, when no column of the right table is selected, now build a hash table that stores the keys alone and release the right-hand blocks as they are built. This makes them up to 1.5x faster and can halve memory usage. Controlled by the new setting `enable_join_key_only_hash_tables`, which is enabled by default. [#115301](https://github.com/ClickHouse/ClickHouse/pull/115301) ([Nikita Taranov](https://github.com/nickitat)).
* Speed up `timeSeriesFromGrid` for dense rows by bulk-copying values. [#115518](https://github.com/ClickHouse/ClickHouse/pull/115518) ([Minh Vu](https://github.com/fallintoplace)).
* Answer `min`, `max`, and `count` aggregations without `GROUP BY` and filters directly from per-part column statistics, collected automatically for suitable columns by the `auto_statistics_types` `MergeTree` setting, reading no data for the parts that have statistics materialized. This speeds up ClickBench Q6 (`SELECT MIN(EventDate), MAX(EventDate) FROM hits`) from tens of milliseconds to a few milliseconds. Controlled by the new setting `use_statistics_for_min_max_aggregation`, which is enabled by default. [#115738](https://github.com/ClickHouse/ClickHouse/pull/115738) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* On AArch64, short runtime-sized copies in hot string, join, and part-reading paths now stay inline instead of being rewritten to a `memcpy` call. [#117353](https://github.com/ClickHouse/ClickHouse/pull/117353) ([Groene AI](https://github.com/groeneai)).
* Improve performance of `bitmapAndCardinality`, `bitmapOrCardinality`, `bitmapXorCardinality`, `bitmapAndnotCardinality`, and `bitmapHasAny` by computing the result directly instead of first materializing the intersection bitmap. [#117478](https://github.com/ClickHouse/ClickHouse/pull/117478) ([Anand Kr Shaw](https://github.com/anandheritage)).
* Reduce memory usage of reading a `TimeSeries` table directly with SQL (`SELECT ... FROM ts_table`). The samples are now aggregated in sorting-key order instead of being buffered in a hash table, so peak memory no longer grows with the size of the scanned window, and `LIMIT` is pushed into the read. [#117726](https://github.com/ClickHouse/ClickHouse/pull/117726) ([Nikita Mikhaylov](https://github.com/nikitamikhaylov)).
* Queries with join-side disjunction predicates can now push the per-side filters down to `PREWHERE` on `MergeTree` reads, reducing unnecessary column reads. [#117760](https://github.com/ClickHouse/ClickHouse/pull/117760) ([Nikita Taranov](https://github.com/nickitat)).
* Reduce `clickhouse-keeper` request latency for concurrent `RemoveRecursive` requests when many uncommitted nodes exist. [#117778](https://github.com/ClickHouse/ClickHouse/pull/117778) ([Alexander Gololobov](https://github.com/davenger)).
* Improve performance of `hasToken`, `hasAnyTokens`, and `hasAllTokens` queries with text indexes in lazy posting-list apply mode. [#117905](https://github.com/ClickHouse/ClickHouse/pull/117905) ([Anton Popov](https://github.com/CurtizJ)).
* Speed up k-way merges: merging sorted streams with multi-column or collated sorting keys uses a sorted array of cursors instead of a heap (7-8% faster), merges of non-intersecting parts detect the whole cursor as one batch in O(1) comparisons, and runs of duplicate keys inside a part are skipped, which makes `SELECT ... FINAL` from `ReplacingMergeTree` use up to 40% less CPU and the insert-time deduplication of `optimize_on_insert` about three times faster when there are many duplicates. [#115869](https://github.com/ClickHouse/ClickHouse/pull/115869) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Reading columns with many substreams, such as `JSON`, from object storage is much faster and makes far fewer requests: the marks of all streams of a `MergeTree` part are now loaded asynchronously and in parallel by default (setting `load_marks_asynchronously`). [#118477](https://github.com/ClickHouse/ClickHouse/pull/118477) ([Alexey Milovidov](https://github.com/alexey-milovidov)). Marks of streams with an empty data file, such as the `SharedVariant` substreams of `JSON` paths with values of a single type, are not loaded at all, which removes about a third of the requests. [#118478](https://github.com/ClickHouse/ClickHouse/pull/118478) ([Alexey Milovidov](https://github.com/alexey-milovidov)). The metadata streams of `JSON` and `Dynamic` columns are no longer read twice when prefetching. [#118479](https://github.com/ClickHouse/ClickHouse/pull/118479) ([Alexey Milovidov](https://github.com/alexey-milovidov)). A read of a file inside a packed part is bounded to the file's slice, so it does not transfer the rest of the archive and reuses HTTP connections. [#118483](https://github.com/ClickHouse/ClickHouse/pull/118483) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Improved performance of reading individual paths and subcolumns from `JSON` columns that use the `advanced` shared data serialization. Each path and substream now starts in its own compressed block, so a selective read no longer decompresses data belonging to other paths. [#118154](https://github.com/ClickHouse/ClickHouse/pull/118154) ([Pavel Kruglov](https://github.com/Avogar)).
* The join reordering optimizer uses the CD-C and CD-A conflict detectors from the SIGMOD'13 paper "On the Correct and Complete Enumeration of the Core Search Space", so joins of any kind can be reordered, including `ANTI` and `SEMI` joins, not only `INNER` joins. For seven relations, CD-C explores about 12 times more valid plans than before. [#117677](https://github.com/ClickHouse/ClickHouse/pull/117677) ([Fisnik Kastrati](https://github.com/fkastrati)).
* Decode `Iceberg` data manifest files concurrently while the list of data files for a query is produced. The setting `iceberg_manifest_decode_concurrency` (default `4`) bounds how many manifests, delete and data alike, are decoded at a time; it replaces `iceberg_delete_manifest_decode_concurrency`, which is kept as an alias. [#116723](https://github.com/ClickHouse/ClickHouse/pull/116723) ([Aaron Harlap](https://github.com/aaron276h)).
* Use the `lower_bound` and `upper_bound` statistics of the `Iceberg` manifest list to prune data files. Closes [#104567](https://github.com/ClickHouse/ClickHouse/issues/104567). [#115817](https://github.com/ClickHouse/ClickHouse/pull/115817) ([Konstantin Vedernikov](https://github.com/scanhex12)).
* Reduce peak memory of the `JSONExtract*` functions on the rapidjson code path (`allow_simdjson = 0`): the parser's DOM allocator is rewound between rows, so the DOM is bounded by one document instead of growing with `max_block_size`. A 100-level nested document uses 84% less memory and is 30% faster, a 200-key object 61% less and 21% faster. [#117618](https://github.com/ClickHouse/ClickHouse/pull/117618) ([Groene AI](https://github.com/groeneai)).
* Faster writing of `String` values in the JSON output formats (`JSONEachRow` and its variants, `JSON`, `JSONObjectEachRow`, `PrettyJSONEachRow` and `GeoJSON`) and in `JSONExtractRaw`: a run of bytes that needs no escaping is copied in one block instead of one byte at a time. Values in which most bytes need escaping become slower. The output is unchanged. [#117755](https://github.com/ClickHouse/ClickHouse/pull/117755) ([Groene AI](https://github.com/groeneai)).
* `addDays`, `addWeeks`, `subtractDays` and `subtractWeeks` over a `DateTime` column are up to 12% faster in time zones with UTC-offset changes: a per-row range check that the argument type makes impossible to fail is no longer executed. [#118219](https://github.com/ClickHouse/ClickHouse/pull/118219) ([Groene AI](https://github.com/groeneai)).
* `toHour` and `toMinute` no longer walk the calendar lookup table in time zones where the result is pure arithmetic: `toHour` in every zone whose UTC offset does not change after 1970 (including `UTC` and `Asia/Kolkata`), and `toMinute` in zones that keep a constant minute-of-hour, such as `Asia/Kolkata`, `Pacific/Chatham` and `America/St_Johns`. Results are unchanged. [#117562](https://github.com/ClickHouse/ClickHouse/pull/117562) ([Groene AI](https://github.com/groeneai)).
* Reduce the per-query cost of applying the `compatibility` setting and of logging changed settings into `system.query_log`. A query on a service that sets an old `compatibility` value can run more than twice as fast. [#118114](https://github.com/ClickHouse/ClickHouse/pull/118114) ([Raúl Marín](https://github.com/Algunenano)).
* The bound on the cost of estimating the selectivity of `col IN (...)` from column statistics, controlled by `statistics_max_set_size_for_exact_selectivity_estimation`, is now also applied when `compatibility` is set to 26.6 or an earlier version. [#118095](https://github.com/ClickHouse/ClickHouse/pull/118095) ([Nikita Fomichev](https://github.com/fm4v)).
* Automatic parallel replicas now skip their planning overhead entirely when no read step of the query is estimated to read at least `automatic_parallel_replicas_min_bytes_per_replica` times the number of replicas. [#116521](https://github.com/ClickHouse/ClickHouse/pull/116521) ([Nikita Taranov](https://github.com/nickitat)).
* Join runtime filters now reach the local probe-side plan under parallel replicas when `parallel_replicas_filter_pushdown` is enabled, so grouped probe-side queries filter rows before local aggregation instead of after it. [#118650](https://github.com/ClickHouse/ClickHouse/pull/118650) ([Nikita Taranov](https://github.com/nickitat)). The join runtime filter no longer builds a Bloom filter that the build-side key count predicts to be too dense to be useful. [#118336](https://github.com/ClickHouse/ClickHouse/pull/118336) ([Manuel](https://github.com/raimannma)).
* The bucket-local top-K optimization (`query_plan_aggregation_bucket_top_k`) no longer materializes every group's key for a statistic that only automatic parallel replicas consume, so `GROUP BY ... ORDER BY count() DESC LIMIT n` over high-cardinality keys spends less CPU in the final aggregation. [#118374](https://github.com/ClickHouse/ClickHouse/pull/118374) ([Groene AI](https://github.com/groeneai)).
* Skip analyzing the implicit `minmax_count` projection during query planning when the query aggregates with a function that projection cannot provide. Previously every aggregating query over a `MergeTree` table interpreted the projection's definition while optimizing the plan, even for `sum`, `avg`, `uniq` and every other aggregate it can never serve. [#118723](https://github.com/ClickHouse/ClickHouse/pull/118723) ([Groene AI](https://github.com/groeneai)).
* A condition on an `ARRAY JOIN` element, such as `ARRAY JOIN tags AS t WHERE t IN (...)`, is now used for skip index analysis the same way `arrayJoin(tags) IN (...)` already is. [#118582](https://github.com/ClickHouse/ClickHouse/pull/118582) ([Yarik Briukhovetskyi](https://github.com/yariks5s)). A `WHERE` condition that compares an `ARRAY JOIN` element with other columns of the row is applied before the expansion, so filtered-out elements are never expanded. [#118904](https://github.com/ClickHouse/ClickHouse/pull/118904) ([Yarik Briukhovetskyi](https://github.com/yariks5s)).
* `ARRAY JOIN` of a `Nested` column inside a subquery, CTE, `UNION` branch or view now reads only the referenced subcolumns, like a top-level `ARRAY JOIN` does. Fixed an exception `Tuple doesn't have element with name` when a second `ARRAY JOIN` referenced a subcolumn of a `Nested` column joined by the first one. [#119055](https://github.com/ClickHouse/ClickHouse/pull/119055) ([Vladimir Cherkasov](https://github.com/vdimir)).
* A `bloom_filter` skip index is no longer selected for a condition built only from `!=` or `NOT IN`. A bloom filter can only prove that a value is absent from a granule, so such a condition never skipped a granule while the whole index was still read. `force_data_skipping_indices` now reports `INDEX_NOT_USED` for it. [#116544](https://github.com/ClickHouse/ClickHouse/pull/116544) ([Groene AI](https://github.com/groeneai)).
* Text indexes on `mapKeys` and `JSONAllPaths` can now prune `IN` predicates even when the right-hand-side set exceeded `use_index_for_in_with_subqueries_max_values` and was built without stored elements. [#118128](https://github.com/ClickHouse/ClickHouse/pull/118128) ([Nikita Taranov](https://github.com/nickitat)). A text index built with the `array` tokenizer can now serve arbitrary `LIKE` and `ILIKE` patterns by scanning its dictionary. [#115649](https://github.com/ClickHouse/ClickHouse/pull/115649) ([Elmi Ahmadov](https://github.com/ahmadov)).
* Speed up primary key index analysis for conditions with a large `IN` set by reusing per-thread buffers instead of allocating on every call. [#110937](https://github.com/ClickHouse/ClickHouse/pull/110937) ([Manuel](https://github.com/raimannma)). Avoid a redundant `LowCardinality` type unwrap per mark when evaluating `IN` conditions on the primary key. [#117054](https://github.com/ClickHouse/ClickHouse/pull/117054) ([Manuel](https://github.com/raimannma)).
* Improved performance of aggregate functions that combine a null map with an `-If` condition (`sum`, `avg`, `min`/`max`/`argMin`/`argMax` with `-If`, functions with two or more `Nullable` arguments such as `corr` and `quantileExactWeighted`, and the `timeSeries*` functions with `-If`) when a block is consumed in increasing sub-ranges, as `optimize_aggregation_in_order` and window frames do. [#118025](https://github.com/ClickHouse/ClickHouse/pull/118025) ([Groene AI](https://github.com/groeneai)).
* Hashing a value that has no contiguous in-memory representation (`JSON`, `Variant`, `AggregateFunction`) no longer allocates and copies a buffer per row. `xxHash64` over a `Variant` column is about 40% faster, `sipHash64` over a `JSON` column about 5%. Counting distinct aggregate states with `uniqExact` is about 33% faster for 200-byte states; `uniq`, `DISTINCT` and `arrayDistinct` hash states through the same path. [#119322](https://github.com/ClickHouse/ClickHouse/pull/119322) ([Groene AI](https://github.com/groeneai)).
* Speed up compression and decompression with the `T64` codec on AArch64 and on x86-64 hosts without AVX-512. The byte and bit transposes now use portable vector shuffles instead of a per-byte scalar loop. Compressed output is unchanged. [#116206](https://github.com/ClickHouse/ClickHouse/pull/116206) ([Groene AI](https://github.com/groeneai)). Faster `DoubleDelta` decompression. [#118787](https://github.com/ClickHouse/ClickHouse/pull/118787) ([Nikita Mikhaylov](https://github.com/nikitamikhaylov)).
* Improve `LIMIT BY` performance by stopping input reads after a constant grouping key reaches its limit. [#118770](https://github.com/ClickHouse/ClickHouse/pull/118770) ([Minh Vu](https://github.com/fallintoplace)).
* Squash small chunks before writing the intermediate table during recursive CTE evaluation. Deep recursions no longer accumulate one tiny `Memory` block per produced chunk, which degraded per-step reads of the working table. [#107068](https://github.com/ClickHouse/ClickHouse/pull/107068) ([Zach Naimon](https://github.com/ArctypeZach)).
* Speed up `jaroSimilarity` and `jaroWinklerSimilarity` using AVX2. [#104457](https://github.com/ClickHouse/ClickHouse/pull/104457) ([Manuel](https://github.com/raimannma)). Speed up `isValidASCII` by using SIMD kernels from simdutf. [#119062](https://github.com/ClickHouse/ClickHouse/pull/119062) ([Konstantin Bogdanov](https://github.com/thevar1able)). Faster `base58Encode` and `base58Decode`. [#117619](https://github.com/ClickHouse/ClickHouse/pull/117619) ([Groene AI](https://github.com/groeneai)). Improve the performance of string functions in byte mode by avoiding unnecessary ASCII scans. [#115003](https://github.com/ClickHouse/ClickHouse/pull/115003) ([Minh Vu](https://github.com/fallintoplace)).
* Speed up `mortonEncode` and `mortonDecode` by resolving each input column and the constant range mask once per call instead of once per row. Results are unchanged. [#117727](https://github.com/ClickHouse/ClickHouse/pull/117727) ([Groene AI](https://github.com/groeneai)).
* Speed up the fast Walsh-Hadamard transform used by `randomHadamardTransform` and by vector quantization with AVX2 (about 28% higher throughput). [#119064](https://github.com/ClickHouse/ClickHouse/pull/119064) ([Jingxin (Philip) Li](https://github.com/philip-jingxin)).
* Faster `cbrt`, `fmod`, `fma` and `hypot`: in release builds the slower implementations from Rust's `compiler_builtins` were shadowing the optimized `llvm-libc` ones, and `hypot` now uses the libc implementation. [#118910](https://github.com/ClickHouse/ClickHouse/pull/118910) ([Konstantin Bogdanov](https://github.com/thevar1able)).
* Reduced the time and peak memory of `s2GetNeighbors` over many rows by reserving its result array once per block instead of once per row. Peak memory at four million rows in a single block drops by about 44%, and the gain grows with `max_block_size`. [#115919](https://github.com/ClickHouse/ClickHouse/pull/115919) ([Groene AI](https://github.com/groeneai)).
* Avoid materializing constant arguments in generic `least` and `greatest` evaluation. [#119108](https://github.com/ClickHouse/ClickHouse/pull/119108) ([Minh Vu](https://github.com/fallintoplace)).
* Faster materialization of lazily replicated sparse columns when consecutive output rows refer to the same source row. [#118237](https://github.com/ClickHouse/ClickHouse/pull/118237) ([Minh Vu](https://github.com/fallintoplace)).
* Skip rebuilding column TTL blocks when no row in the block is expired. [#119109](https://github.com/ClickHouse/ClickHouse/pull/119109) ([Minh Vu](https://github.com/fallintoplace)).
* Faster `LEFT ANTI` joins with the `ie_join` algorithm when there is no residual condition: empty bitmap scans are skipped. [#118584](https://github.com/ClickHouse/ClickHouse/pull/118584) ([Minh Vu](https://github.com/fallintoplace)).
* PromQL: a math binary operator applied to two aggregations of the same expression with the same grouping, such as `sum(x) - max(x)` or `sum by (job) (rate(x[5m])) / count by (job) (rate(x[5m]))`, now evaluates the argument once and computes both aggregations in a single `GROUP BY`, instead of scanning the argument twice and joining the two results by group. [#118307](https://github.com/ClickHouse/ClickHouse/pull/118307) ([Nikita Mikhaylov](https://github.com/nikitamikhaylov)). Use the constant empty group for aggregations with an empty `by()` modifier. [#118132](https://github.com/ClickHouse/ClickHouse/pull/118132) ([Minh Vu](https://github.com/fallintoplace)). Improved the performance of the `deriv` function. [#118987](https://github.com/ClickHouse/ClickHouse/pull/118987) ([Vitaly Baranov](https://github.com/vitlibar)).
* A PromQL selector matching a whole metric on a `TimeSeries` table no longer re-evaluates its primary-key range on `id` for every row it reads; measured 23.7% faster on a 105M-row whole-metric query. [#119092](https://github.com/ClickHouse/ClickHouse/pull/119092) ([Groene AI](https://github.com/groeneai)).
* Faster `timeSeries*ToGrid` aggregate functions: per-sample timestamp validation is skipped when the sorted bucket endpoints already prove the range. [#118189](https://github.com/ClickHouse/ClickHouse/pull/118189) ([Minh Vu](https://github.com/fallintoplace)).
* Reduced contention on the global logger mutex in the `MergeTree` read path, which was noticeable on servers with many cores and queries touching many parts. [#117498](https://github.com/ClickHouse/ClickHouse/pull/117498) ([Manuel](https://github.com/raimannma)). Partition values are no longer formatted for a trace-level log message when trace logging is disabled. [#119605](https://github.com/ClickHouse/ClickHouse/pull/119605) ([Rory Shanks](https://github.com/rorylshanks)).
* Push the `disk_name` filter of `system.remote_data_paths` into the disk traversal, so a query that names the disks it needs no longer walks every object storage disk on the server. [#118400](https://github.com/ClickHouse/ClickHouse/pull/118400) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Speed up `clickhouse-client` startup with many options. [#118386](https://github.com/ClickHouse/ClickHouse/pull/118386) ([Ivan Babrou](https://github.com/bobrik)).
* Fewer allocations when reporting `ProfileEvents` snapshots. [#118305](https://github.com/ClickHouse/ClickHouse/pull/118305) ([Ilya Yatsishin](https://github.com/qoega)).
* Speed up reading subcolumns from wide parts and from compact parts with substream marks by avoiding unnecessary full-column serializations. [#111020](https://github.com/ClickHouse/ClickHouse/pull/111020) ([Rory Shanks](https://github.com/rorylshanks)).
* Speed up aggregation batches with non-null states. [#117009](https://github.com/ClickHouse/ClickHouse/pull/117009) ([Ivan Babrou](https://github.com/bobrik)).
* Speed up flushing `system.opentelemetry_span_log` by writing spans directly into its columns instead of boxing each value into a `Field`. A burst of spans no longer makes `SYSTEM FLUSH LOGS opentelemetry_span_log` hit its timeout. [#117481](https://github.com/ClickHouse/ClickHouse/pull/117481) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Avoid join-order regressions when the selectivity estimator cannot evaluate every predicate in a `WHERE` condition: unaffected predicates are still used to estimate cardinality instead of falling back to full-table estimates. [#118137](https://github.com/ClickHouse/ClickHouse/pull/118137) ([Nikita Taranov](https://github.com/nickitat)).
* Improved performance of some array functions: generic `arrayFirst` and `arrayLast` reserve result rows, `arrayExcept` no longer copies the input when the exclusion array is empty, single-argument `arrayConcat` no longer rebuilds the result, and `arraySlice(arr, 1)` no longer rebuilds the result array. [#118188](https://github.com/ClickHouse/ClickHouse/pull/118188) ([Minh Vu](https://github.com/fallintoplace)). [#119665](https://github.com/ClickHouse/ClickHouse/pull/119665) ([Minh Vu](https://github.com/fallintoplace)). [#119697](https://github.com/ClickHouse/ClickHouse/pull/119697) ([Minh Vu](https://github.com/fallintoplace)). [#119817](https://github.com/ClickHouse/ClickHouse/pull/119817) ([Minh Vu](https://github.com/fallintoplace)).
* Reuse HTTP connections to object storage when a read range ends at the end of the object. Streams reading the same `MergeTree` part no longer open a new connection for each range. [#118480](https://github.com/ClickHouse/ClickHouse/pull/118480) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* `SELECT count()` can use the trivial count optimization on tables with lightweight-update patches that only change values, avoiding unnecessary table and patch reads. [#118882](https://github.com/ClickHouse/ClickHouse/pull/118882) ([Anton Popov](https://github.com/CurtizJ)).
* Improve `Map` subcolumn pruning: `mapContainsValue` can read only the values subcolumn, `mapKeys`/`mapValues` filters can read only the matching keys or values subcolumn even when the full `Map` is also selected, and `has`/`notHas` over a `Map` can read only the keys subcolumn when it is safe to do so. [#119172](https://github.com/ClickHouse/ClickHouse/pull/119172) ([Minh Vu](https://github.com/fallintoplace)). [#119261](https://github.com/ClickHouse/ClickHouse/pull/119261) ([Minh Vu](https://github.com/fallintoplace)). [#119190](https://github.com/ClickHouse/ClickHouse/pull/119190) ([Minh Vu](https://github.com/fallintoplace)).
* The `advanced` shared-data serialization for `JSON` now sizes compressed blocks by `min_compress_block_size` instead of flushing per path and substream, avoiding large part-size regressions on tables with many shared-data paths. [#119285](https://github.com/ClickHouse/ClickHouse/pull/119285) ([Pavel Kruglov](https://github.com/Avogar)).
* Reduce decompression overhead for chained compression codecs by constructing codec-description ASTs only when requested. [#119490](https://github.com/ClickHouse/ClickHouse/pull/119490) ([Raufs Dunamalijevs](https://github.com/rienath)).
* Accelerate `countBytesInFilter` and `countBytesInFilterWithNull` on AArch64 using direct NEON vector register accumulation, improving filter counting throughput by up to 15x. [#119555](https://github.com/ClickHouse/ClickHouse/pull/119555) ([Joshua Dorst](https://github.com/JoshyDo)).
* Partition pruning now runs before loading column statistics and before calculating skip-index ordering costs for `PREWHERE` optimization. Query-plan `PREWHERE` column sizes and statistics are now also estimated from the parts left after pruning, retaining the existing byte-cost estimate when those parts have no per-column measurements. [#119558](https://github.com/ClickHouse/ClickHouse/pull/119558) ([Rory Shanks](https://github.com/rorylshanks)). [#119606](https://github.com/ClickHouse/ClickHouse/pull/119606) ([Rory Shanks](https://github.com/rorylshanks)). [#119607](https://github.com/ClickHouse/ClickHouse/pull/119607) ([Rory Shanks](https://github.com/rorylshanks)).
* Speed up single-argument `uniq`, `uniqCombined`, and `uniqCombined64` on common scalar types when aggregating many interleaved groups. [#119594](https://github.com/ClickHouse/ClickHouse/pull/119594) ([Manuel](https://github.com/raimannma)).
* UTF-8 validation is now vectorized across ClickHouse, not only inside the `isValidUTF8` SQL function on x86. Text index conditions, Prometheus query parsing, format escaping and output, `detectLanguage`, and `isValidUTF8` itself now validate long strings much faster, including on AArch64. Closes [#116074](https://github.com/ClickHouse/ClickHouse/issues/116074). [#116204](https://github.com/ClickHouse/ClickHouse/pull/116204) ([Groene AI](https://github.com/groeneai)).
* Improved the performance of the `splitByNonAlpha` and `splitByString` tokenizers. [#119434](https://github.com/ClickHouse/ClickHouse/pull/119434) ([Anton Popov](https://github.com/CurtizJ)).
* Speed up `lowerUTF8` and `upperUTF8` for mixed columns with mostly ASCII rows. [#119790](https://github.com/ClickHouse/ClickHouse/pull/119790) ([Minh Vu](https://github.com/fallintoplace)).
* Speed up sorting of wide tables (`ORDER BY` over many columns) by skipping an unnecessary per-row check in the merge step when no column can be replicated. This removes overhead that was noticeable on ARM. [#110627](https://github.com/ClickHouse/ClickHouse/pull/110627) ([Groene AI](https://github.com/groeneai)).
* Speed up query analysis for large parameterized views by avoiding repeated hashing of the substituted view query during query-tree comparisons. Closes [#118736](https://github.com/ClickHouse/ClickHouse/issues/118736). [#119517](https://github.com/ClickHouse/ClickHouse/pull/119517) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
#### Improvement
* AI functions (`aiGenerate`, `aiClassify`, `aiFilter`, `aiExtract`, `aiTranslate`, `aiRedact`, `aiEmbed`, `aiSimilarity`) are now beta and no longer require the `allow_experimental_ai_functions` setting, which is now obsolete. The `ai_function_*` settings moved to the beta tier, and `ai_function_max_retries` now defaults to `1` so that a single transient provider error does not fail the query. [#116227](https://github.com/ClickHouse/ClickHouse/pull/116227) ([George Larionov](https://github.com/george-larionov)).
* Added dimensional metrics for `S3Queue`. [#115422](https://github.com/ClickHouse/ClickHouse/pull/115422) ([Bharat Nallan](https://github.com/bharatnc)).
* Very large `max_streams_to_max_threads_ratio` values on `Merge` table reads are now validated correctly: stream-count calculations that overflow `size_t` or exceed the maximum source count are rejected with `PARAMETER_OUT_OF_BOUND` instead of hitting undefined behavior. [#113382](https://github.com/ClickHouse/ClickHouse/pull/113382) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* The Web UI no longer shows sort and filter controls in column headers when the first page of a result contains only a single row and those controls would only re-run the same query. Results that are already sorted or filtered, or truncated at the display limit, still show them. [#116181](https://github.com/ClickHouse/ClickHouse/pull/116181) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* A trace started by sampling (`opentelemetry_start_trace_probability`) is now written back into the query's client info, so remote and distributed secondary queries and DDL entries join the same trace instead of starting disjoint ones. [#115619](https://github.com/ClickHouse/ClickHouse/pull/115619) ([Diego Gomes Tomé](https://github.com/diegomestre2)).
* The `Empty query` syntax error now says which text was empty when the text is not the query itself but a fragment parsed on its own, such as the value of the `parallel_replicas_custom_key` or `additional_result_filter` setting: `Empty query (parallel replicas custom key)`. The error for custom-key filtering requested without `parallel_replicas_custom_key` now names the settings involved. [#115959](https://github.com/ClickHouse/ClickHouse/pull/115959) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Using `join_algorithm = 'direct'` against a `Buffer` table now returns the ordinary unsupported-storage error instead of `Cannot clone ReadFromPreparedSource plan step` (`NOT_IMPLEMENTED`). [#115309](https://github.com/ClickHouse/ClickHouse/pull/115309) ([Groene AI](https://github.com/groeneai)).
* `INSERT INTO ... SELECT` from a cluster table function such as `s3Cluster` with `parallel_distributed_insert_select` now expands aliases in the `WHERE` condition before pruning files to read, so alias-based filters participate in pruning and no longer write a stack trace to the server log. [#115932](https://github.com/ClickHouse/ClickHouse/pull/115932) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Wrapped object-storage disks now account reads and writes to the workload of the underlying object storage, so workload scheduling uses the intended limits and priorities. [#116288](https://github.com/ClickHouse/ClickHouse/pull/116288) ([Mikhail Artemenko](https://github.com/Michicosun)).
* A server started without a config file now declares the same single-node `default` cluster as the packaged config, so `cluster('default', ...)` and `clusterAllReplicas('default', ...)` work instead of failing with `CLUSTER_DOESNT_EXIST`. [#116382](https://github.com/ClickHouse/ClickHouse/pull/116382) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* The `/` commands of the client (`/help`, `/man`, `/clear`) are now offered by the line editor: typing `/` at the beginning of the input lists them as hints, and `Tab` completes the command being typed. A mistake in a command name is now reported with similar commands suggested, instead of being parsed as SQL. [#115039](https://github.com/ClickHouse/ClickHouse/pull/115039) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Support `Decimal` types when writing into `Iceberg` tables, including decimal partition columns and decimal min/max statistics. [#115832](https://github.com/ClickHouse/ClickHouse/pull/115832) ([Konstantin Vedernikov](https://github.com/scanhex12)).
* Web UI: the query text selection stays visible after the editor loses focus, so it is possible to see what the `Run selected` button will run. [#116201](https://github.com/ClickHouse/ClickHouse/pull/116201) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* `ReplicatedMergeTree` mutations now automatically prune affected partitions from the `WHERE` condition when possible. Mutation queries also now accept multiple values in the `IN PARTITION` clause. [#110968](https://github.com/ClickHouse/ClickHouse/pull/110968) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Allow `JOIN` on keys that have no common supertype, such as `UInt64` and `Int64`. Previously such queries were rejected with `There is no supertype for types UInt64, Int64`. Keys are now converted to the type of the values they have in common, and a value outside that range does not match anything. [#112951](https://github.com/ClickHouse/ClickHouse/pull/112951) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Reduce the volume of logs from the parallel replicas coordinator: it no longer prints every part and all its mark ranges on each announcement, read request, and response. [#115833](https://github.com/ClickHouse/ClickHouse/pull/115833) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* The `Maybe you meant` hint for an unknown column, function, or table is now printed before the query instead of after it, so it stays visible for long queries. When a column cannot be resolved from a table expression with an alias, the message also names the table behind the alias. [#116809](https://github.com/ClickHouse/ClickHouse/pull/116809) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Comparing a number with an empty or truncated string literal, such as `WHERE numeric_column <> ''`, now reports `Cannot convert string '' to type Int32` instead of `Attempt to read after eof`. A correlated subquery returning several columns where one value is expected now also reports that directly. [#116812](https://github.com/ClickHouse/ClickHouse/pull/116812) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* A `Values` row whose values are fine but whose `,` or `)` is missing or misplaced now reports the missing delimiter and the column it should follow, instead of claiming that the last value could not be parsed as its own type. [#116877](https://github.com/ClickHouse/ClickHouse/pull/116877) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* TLS CA certificates configured with `openSSL.server.caConfig` / `openSSL.client.caConfig` and `caConfig` of composable `protocols` are now reloaded on file changes and on `SYSTEM RELOAD CONFIG`, allowing CA rotation without restart for server, client, and Keeper connections. [#117387](https://github.com/ClickHouse/ClickHouse/pull/117387) ([James](https://github.com/sanjams2)).
* Bare `UNION` now tells you to write `UNION ALL` or `UNION DISTINCT`, or to set `union_default_mode`, instead of naming an internal AST class. The `EXCEPT` and `INTERSECT` variants are reworded the same way. [#116815](https://github.com/ClickHouse/ClickHouse/pull/116815) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* An aggregate function used in `WHERE` or `PREWHERE`, often through an alias such as `SELECT count() AS c FROM t WHERE c > 1`, is now told to use `HAVING` instead. Values that cannot be parsed as `Date` no longer claim to be too short when that is not the reason; the error now names the expected format. [#116817](https://github.com/ClickHouse/ClickHouse/pull/116817) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Invalid calls to the internal `viewExplain` table function now return `BAD_ARGUMENTS` instead of analyzing the invalid expression and potentially failing with an unrelated error such as `UNKNOWN_TABLE`. [#108384](https://github.com/ClickHouse/ClickHouse/pull/108384) ([Christoph Viebig](https://github.com/cv4g)).
* Unexpected `jemalloc` warnings are no longer suppressed, and the server now reports disabled per-CPU arenas in `system.warnings`. [#116899](https://github.com/ClickHouse/ClickHouse/pull/116899) ([Azat Khuzhin](https://github.com/azat)).
* Enable reading `ReplacingMergeTree` data in reverse order with `FINAL`. [#115345](https://github.com/ClickHouse/ClickHouse/pull/115345) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Added the `snapshot_zstd_compression_level` Keeper coordination setting to configure the `ZSTD` compression level used for snapshots. It defaults to `3`, preserving the existing behavior. [#116866](https://github.com/ClickHouse/ClickHouse/pull/116866) ([Antonio Andelic](https://github.com/antonio2368)).
* A typo in the key, index, or TTL expression of an `ALTER TABLE` now suggests the column that was probably meant, the way `SELECT` already does. Previously it printed a list of available columns that, for a `MergeTree` table, was dominated by virtual columns and truncated before the real ones. [#116915](https://github.com/ClickHouse/ClickHouse/pull/116915) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Aggregate functions that take parameters and are wrapped with the `-Array` combinator now preserve those parameters correctly, so expressions such as `argMaxArray(2)` and state types such as `AggregateFunction(groupArrayMovingSum(42), UInt64)` no longer drop them. In debug and sanitizer builds this also fixes an internal assertion. [#110143](https://github.com/ClickHouse/ClickHouse/pull/110143) ([Groene AI](https://github.com/groeneai)).
* `rseq` is now enabled correctly on x86-64 builds that use link-time optimization; previously it was silently disabled. [#117700](https://github.com/ClickHouse/ClickHouse/pull/117700) ([Azat Khuzhin](https://github.com/azat)).
* Take a column's `CODEC` into account when estimating how many bytes a query reads from compact parts. The estimate compressed a sample with the default codec (`LZ4`) no matter how the data is really stored, so a column stored with a stronger codec was overestimated, which inflates `effective_max_reading_threads` and can make automatic parallel replicas distribute a query that is cheaper to run on a single node. [#114535](https://github.com/ClickHouse/ClickHouse/pull/114535) ([Nikita Taranov](https://github.com/nickitat)).
* `Iceberg` tables stored on `S3` can now read data files from a different bucket than the table metadata. [#116771](https://github.com/ClickHouse/ClickHouse/pull/116771) ([Konstantin Vedernikov](https://github.com/scanhex12)).
* An aggregate function with the `-If` combinator whose condition has the wrong type, or is missing, now says that the last argument is the condition and must be `UInt8`, instead of only reporting an illegal type for the last argument. An `ASOF` join with no inequality predicate now says that one is needed in addition to the equality predicates, instead of ending the message in `, in .`. [#116916](https://github.com/ClickHouse/ClickHouse/pull/116916) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* `clickhouse-local` now exposes `system.warnings`, and ClickHouse now checks `rseq` compatibility at startup. [#117717](https://github.com/ClickHouse/ClickHouse/pull/117717) ([Azat Khuzhin](https://github.com/azat)).
* The `TimeSeries` table engine, the PromQL dialect and the `timeSeries*` aggregate functions are moved from the experimental tier to the private preview tier. Settings `allow_experimental_time_series_table` and `allow_experimental_time_series_aggregate_functions` are renamed to `enable_time_series_table` and `enable_time_series_aggregate_functions`; the old names remain as aliases. [#118124](https://github.com/ClickHouse/ClickHouse/pull/118124) ([Nikita Mikhaylov](https://github.com/nikitamikhaylov)).
* `TimeSeries` tables now store an explicit schema version in the `version` engine setting. The PromQL execution layer supports only a declared range of versions and rejects queries over tables outside that range with an instructive error. [#111204](https://github.com/ClickHouse/ClickHouse/pull/111204) ([Nikita Mikhaylov](https://github.com/nikitamikhaylov)). A `TimeSeries` table definition copied with `CREATE TABLE ... AS` now gets the settings of the new table, and the new `id_type` setting lets `CREATE TABLE ... AS src` copy only `src`'s definition without reading its target tables. [#118517](https://github.com/ClickHouse/ClickHouse/pull/118517) ([Vitaly Baranov](https://github.com/vitlibar)). [#119613](https://github.com/ClickHouse/ClickHouse/pull/119613) ([Vitaly Baranov](https://github.com/vitlibar)).
* Reads from `TimeSeries` tables now respect the `join_algorithm` and the partition-wise aggregation settings of the query instead of overriding them, and the internal join of samples and tags supports `full_sorting_merge`. [#118864](https://github.com/ClickHouse/ClickHouse/pull/118864) ([Nikita Mikhaylov](https://github.com/nikitamikhaylov)). The `promql_evaluation_time` setting defaults to `auto` regardless of the `compatibility` setting. [#119202](https://github.com/ClickHouse/ClickHouse/pull/119202) ([Raúl Marín](https://github.com/Algunenano)).
* Join runtime filter settings are now production-tier (previously experimental). [#117383](https://github.com/ClickHouse/ClickHouse/pull/117383) ([Robert Schulze](https://github.com/rschu1ze)).
* Improved syntax error messages. An unclosed bracket is now reported at the place where the parser stopped, which is next to the actual mistake, and every unclosed bracket is listed with its own position; previously the outermost bracket was blamed, which in a large query can be thousands of characters away from the mistake. A mistyped keyword is now named explicitly (`Maybe you meant: SELECT.`) instead of only being one item in a list of dozens of alternatives. [#116806](https://github.com/ClickHouse/ClickHouse/pull/116806) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* The `psql`-style `\d` of the interactive client now describes a table when a table name is given (`\d hits`), like it does in `psql`; without an argument it still lists the tables. [#118281](https://github.com/ClickHouse/ClickHouse/pull/118281) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* `clickhouse-local` now merges the `config.d` and `conf.d` directories of the current directory into its configuration even if there is no main configuration file, so a directory with a `config.d` no longer additionally requires an empty `config.xml`. [#118410](https://github.com/ClickHouse/ClickHouse/pull/118410) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Added the `clickhouse_version` and `system_processor` columns to the system log tables. [#117896](https://github.com/ClickHouse/ClickHouse/pull/117896) ([Miсhael Stetsyuk](https://github.com/mstetsyuk)).
* `EXPLAIN ANALYZE` now shows more information about the estimation for joins. [#114792](https://github.com/ClickHouse/ClickHouse/pull/114792) ([Kirill Kopnev](https://github.com/Fgrtue)).
* Automatic parallel replicas now support queries with `LIMIT` and `OFFSET`. [#117402](https://github.com/ClickHouse/ClickHouse/pull/117402) ([Nikita Taranov](https://github.com/nickitat)).
* Object storage writes (`INSERT` into `s3`, `azure` and other object storage tables) now support parallel replicas. [#119214](https://github.com/ClickHouse/ClickHouse/pull/119214) ([Konstantin Vedernikov](https://github.com/scanhex12)).
* Added the `min_partition_age_to_force_merge_seconds` `MergeTree` setting: when every part in a partition is at least this old, the `Simple` and `StochasticSimple` merge selectors compact that partition's parts within the `max_bytes_to_merge_at_max_space_in_pool` limit. [#115547](https://github.com/ClickHouse/ClickHouse/pull/115547) ([Valery Petrov](https://github.com/valerypetrov)).
* `TRUNCATE TABLE` on a `ReplicatedMergeTree` table no longer blocks concurrent `DROP`, `RENAME` and other DDL queries on the same table while the data is being removed. [#114672](https://github.com/ClickHouse/ClickHouse/pull/114672) ([Nikolay Degterinsky](https://github.com/evillique)).
* Allow `ALTER TABLE ... MODIFY SETTING storage_policy` for `MergeTree` tables when newly added disks contain only a matching `format_version.txt` and an empty `detached/` directory under the table path. [#107736](https://github.com/ClickHouse/ClickHouse/pull/107736) ([Maxim Orlovsky](https://github.com/UberDever)).
* Added the `s3_upload_checksum_algorithm` setting to choose the checksum sent with `S3` uploads (`MD5`, `CRC32` or `SHA256`). The default is empty and keeps the current behavior. Use `CRC32` or `SHA256` on FIPS builds, where `MD5` is unavailable and uploads would otherwise carry no checksum, which buckets with Object Lock reject. [#107318](https://github.com/ClickHouse/ClickHouse/pull/107318) ([Sebastian Vercruysse](https://github.com/sebver)).
* Partition field summaries are written into the manifest list of `Iceberg` tables. [#118796](https://github.com/ClickHouse/ClickHouse/pull/118796) ([Konstantin Vedernikov](https://github.com/scanhex12)). Concurrent `INSERT`s into an `Iceberg` table through a catalog no longer back off on a commit conflict and retry immediately. [#119238](https://github.com/ClickHouse/ClickHouse/pull/119238) ([Konstantin Vedernikov](https://github.com/scanhex12)).
* Log when an object storage listing returns an empty page while reporting that more objects follow. This is legal and is handled correctly, but it has twice been the trigger for silently losing objects and nothing recorded that it occurred. [#119065](https://github.com/ClickHouse/ClickHouse/pull/119065) ([Sema Checherinda](https://github.com/CheSema)).
* A warning is now logged when a CTE is declared as `MATERIALIZED` but the setting `enable_materialized_cte` is disabled, in which case the keyword is ignored and the CTE is inlined at each reference. Previously the keyword was silently ignored. [#118032](https://github.com/ClickHouse/ClickHouse/pull/118032) ([Dmitry Novik](https://github.com/novikd)).
* An unknown profile event name in the `trace_profile_events_list` setting now gives a readable error message with hints instead of `std::out_of_range: unordered_map::at: key not found`. [#116049](https://github.com/ClickHouse/ClickHouse/pull/116049) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* The dictionary loader now logs `never` instead of a timestamp in the year 294247 when an object has no automatic update scheduled (for example a dictionary with `LIFETIME(0)`), which previously looked like a scheduling bug next to a failed-update message. [#118443](https://github.com/ClickHouse/ClickHouse/pull/118443) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Correct the error message for an unsupported attribute in an `ip_trie` dictionary: it claimed that `Array` attributes are unsupported, while in fact they are supported and only `Nullable` attributes are rejected. [#118492](https://github.com/ClickHouse/ClickHouse/pull/118492) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* `MEMORY_LIMIT_EXCEEDED` is reported promptly for `parallel_hash` joins whose hash-table construction uses deferred memory tracking. [#116477](https://github.com/ClickHouse/ClickHouse/pull/116477) ([Konstantin Morozov](https://github.com/k-morozov)).
* Less verbose logging of `INSERT`s into `MergeTree` and `ReplicatedMergeTree` tables. [#116486](https://github.com/ClickHouse/ClickHouse/pull/116486) ([Azat Khuzhin](https://github.com/azat)).
* The hash tables behind the TLD lists (`firstSignificantSubdomainCustom` and similar functions), the naive Bayes classifier and text indexes use a simpler, packed string representation. [#117175](https://github.com/ClickHouse/ClickHouse/pull/117175) ([Surya Teja](https://github.com/sleepingeight)).
* ClickHouse Keeper now counts the per-entry allocation overhead in `latest_logs_cache_size_threshold`, `KeeperLatestLogsCacheSize`, and `lgif`'s `latest_logs_cache_size`, so the configured limit tracks cache memory rather than only serialized payload bytes. [#119045](https://github.com/ClickHouse/ClickHouse/pull/119045) ([Nikita Taranov](https://github.com/nickitat)). The `latest_logs_cache_entry_count_threshold` setting is effective again and limits the in-memory latest-log cache by entry count independently of `latest_logs_cache_size_threshold`. [#119151](https://github.com/ClickHouse/ClickHouse/pull/119151) ([Antonio Andelic](https://github.com/antonio2368)).
* Show the progress percentage again for queries reading from the `file` table function and `INFILE`. [#119213](https://github.com/ClickHouse/ClickHouse/pull/119213) ([Raúl Marín](https://github.com/Algunenano)).
* Warn when `CLEAR COLUMN` leaves an `EPHEMERAL`-derived `MATERIALIZED` column stale. [#115371](https://github.com/ClickHouse/ClickHouse/pull/115371) ([Shaohua Wang](https://github.com/tiandiwonder)).
* Reduced cancellation latency for `INTERSECT` and `EXCEPT` queries: `KILL QUERY` now interrupts the hash-table build and filter loops within a single chunk instead of waiting for the whole chunk. [#118046](https://github.com/ClickHouse/ClickHouse/pull/118046) ([Roman Vasin](https://github.com/rvasin)).
* The `compatibility` setting can now keep selected new defaults in effect: settings changes marked `StartUsingNew` are no longer rolled back to the previous default when `compatibility` points to an older version. [#114190](https://github.com/ClickHouse/ClickHouse/pull/114190) ([Mikhail Artemenko](https://github.com/Michicosun)).
* Added write support for `DeltaLake` tables on `Azure` storage. [#116698](https://github.com/ClickHouse/ClickHouse/pull/116698) ([Smita Kulkarni](https://github.com/SmitaRKulkarni)).
* Added aliases without the `allow_experimental_` prefix for existing settings whose tier already marks them as experimental or beta; the old names continue to work. [#119056](https://github.com/ClickHouse/ClickHouse/pull/119056) ([Robert Schulze](https://github.com/rschu1ze)).
* Bump the bundled `libssh` from `0.12.0` to `0.12.2`. [#119262](https://github.com/ClickHouse/ClickHouse/pull/119262) ([Robert Schulze](https://github.com/rschu1ze)).
* Function `replicate` now returns a constant column when all its arguments are constant, like `arrayWithConstant`. [#111069](https://github.com/ClickHouse/ClickHouse/pull/111069) ([sakshichitnis27](https://github.com/sakshichitnis27)).
* The `PROJECTION_NOT_USED` and `INCORRECT_DATA` errors of `force_optimize_projection` and `force_optimize_projection_name` now list every projection the optimizer considered and why each was rejected. [#119624](https://github.com/ClickHouse/ClickHouse/pull/119624) ([Mikhail Artemenko](https://github.com/Michicosun)).
#### Bug Fix (user-visible misbehavior in an official stable release)
* `ALTER TABLE ATTACH PARTITION FROM` is no longer replicated in `Replicated` databases. [#94835](https://github.com/ClickHouse/ClickHouse/pull/94835) ([MikhailBurdukov](https://github.com/MikhailBurdukov)).
* Invalid Azure upload-size settings (for example `azure_min_upload_part_size = 0` or `azure_max_blocks_in_multipart_upload = 0`) are now rejected early with a clear error instead of triggering an internal exception (`second_size > 0`) deep in the write path. This applies to both query settings and Azure disk configuration. [#103394](https://github.com/ClickHouse/ClickHouse/pull/103394) ([Statxc](https://github.com/statxc)).
* Fixed wrong results for comma or `CROSS JOIN` queries whose `WHERE` clause compares columns from the two sides through a non-deterministic expression such as `rand`. Such queries could return rows that contradict their own `WHERE` clause because rewriting the join to `INNER JOIN` re-evaluated the expression per row on each side. [#112938](https://github.com/ClickHouse/ClickHouse/pull/112938) ([Groene AI](https://github.com/groeneai)).
* `S3Queue` and `AzureQueue` tables whose metadata handle is gone no longer fail with `Logical error: 'Files metadata is empty'` when read, altered, or flushed; they now report `TABLE_IS_DROPPED` instead. `SYSTEM FLUSH OBJECT STORAGE QUEUE` on such a table no longer terminates the server. [#113695](https://github.com/ClickHouse/ClickHouse/pull/113695) ([Groene AI](https://github.com/groeneai)).
* Fix `LOGICAL_ERROR` when filtering an `Iceberg` column that `ALTER TABLE ... MODIFY COLUMN` made `Nullable`. Closes [#85029](https://github.com/ClickHouse/ClickHouse/issues/85029). [#114521](https://github.com/ClickHouse/ClickHouse/pull/114521) ([Groene AI](https://github.com/groeneai)).
* PromQL grouping modifiers now support quoted label names. [#114545](https://github.com/ClickHouse/ClickHouse/pull/114545) ([Minh Vu](https://github.com/fallintoplace)).
* Fixed reading a table while a mutation is in progress: a `MATERIALIZED` column could return a stale or incorrectly recomputed value, and selecting it together with an updated column could fail with an error. [#114561](https://github.com/ClickHouse/ClickHouse/pull/114561) ([Shaohua Wang](https://github.com/tiandiwonder)). [#115372](https://github.com/ClickHouse/ClickHouse/pull/115372) ([Shaohua Wang](https://github.com/tiandiwonder)).
* Fixed an RBAC bypass in the `Alias` table engine that allowed users without privileges on the target table to reveal its schema, row count, size, and existence. [#114596](https://github.com/ClickHouse/ClickHouse/pull/114596) ([Kai Zhu](https://github.com/nauu)).
* Fixed a column that was renamed, dropped, and added again in one `ALTER` returning the dropped column's values instead of its own default while the mutation was still pending. [#114601](https://github.com/ClickHouse/ClickHouse/pull/114601) ([Shaohua Wang](https://github.com/tiandiwonder)).
* `ANY RIGHT JOIN` and `SEMI RIGHT JOIN` with several `OR`-ed conditions in the `ON` clause no longer duplicate some right-table rows and lose others. A written `ANY LEFT JOIN` was affected too, because the planner may swap the tables and execute it as `ANY RIGHT JOIN`. [#114676](https://github.com/ClickHouse/ClickHouse/pull/114676) ([Vladimir Cherkasov](https://github.com/vdimir)).
* Fix invalid backslash escape handling in text, `tokenbf_v1`, and `ngrambf_v1` indexes. [#115634](https://github.com/ClickHouse/ClickHouse/pull/115634) ([Elmi Ahmadov](https://github.com/ahmadov)).
* Fix crashes of the `Parquet`, `ORC`, and `Iceberg` readers on malformed input: a `DELTA_BYTE_ARRAY` page with an empty length stream, a `DELTA_BYTE_ARRAY` page of a `Decimal` column read under a filter, an out-of-range enum in an `Iceberg` manifest file, and an oversized allocation in the ORC library. [#115703](https://github.com/ClickHouse/ClickHouse/pull/115703) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Reject invalid names of projections and indexes. [#115824](https://github.com/ClickHouse/ClickHouse/pull/115824) ([Alexander Tokmakov](https://github.com/tavplubix)).
* A `KeeperMap` table with unparsable metadata no longer prevents server startup; it is now quarantined instead. Closes [#115881](https://github.com/ClickHouse/ClickHouse/issues/115881). [#115941](https://github.com/ClickHouse/ClickHouse/pull/115941) ([Groene AI](https://github.com/groeneai)).
* Fixed `LOGICAL_ERROR: Index with name auto_minmax_index_ already exists` when a single `ALTER TABLE` statement combined `RENAME COLUMN` with another command, such as `MODIFY SETTING`, on a table with implicit minmax indices (`add_minmax_index_for_numeric_columns` and friends). Renaming a plain column also no longer leaves a following `DROP COLUMN` failing with `UNKNOWN_IDENTIFIER`, nor a following `ADD COLUMN` without its implicit index. [#116063](https://github.com/ClickHouse/ClickHouse/pull/116063) ([Groene AI](https://github.com/groeneai)).
* Fixed a crash of stateless workers with object storage. [#116067](https://github.com/ClickHouse/ClickHouse/pull/116067) ([Konstantin Vedernikov](https://github.com/scanhex12)).
* Fixed distributed queries that filter or compute on `Decimal`, `DateTime64`, or `Time64` constants: pushed-down constants could fail with `CANNOT_PARSE_DATETIME`, lose precision, or change their `Dynamic` subtype when sent to remote shards. [#95055](https://github.com/ClickHouse/ClickHouse/pull/95055) ([Yakov Olkhovskiy](https://github.com/yakov-olkhovskiy)).
* Fixed `JSON`, `Object`, and `Dynamic` columns hashing logically equal values differently depending on their physical layout: how `JSON`/`Object` paths were split between dynamic subcolumns and shared data, or whether a `Dynamic` value sat in a typed or shared variant. Hash-based joins on such a key silently missed matches, and a `grace_hash` spill could raise a `LOGICAL_ERROR` (`Invalid state transition`). A `JSON` key needed no non-default setting; `Dynamic` also required `allow_dynamic_type_in_join_keys`. [#109450](https://github.com/ClickHouse/ClickHouse/pull/109450) ([Groene AI](https://github.com/groeneai)).
* Setting a Keeper coordination timeout such as `operation_timeout_ms`, `session_timeout_ms`, or `startup_timeout` to a very large value no longer overflows and expires the wait immediately. Builds with the undefined behavior sanitizer no longer abort. [#112088](https://github.com/ClickHouse/ClickHouse/pull/112088) ([Groene AI](https://github.com/groeneai)).
* Fixed a `bloom_filter` skip index dropping granules that contain matching rows when a `String` or `FixedString` column is compared for equality against a constant that is wider than the indexed type, so queries such as `SELECT count() FROM t WHERE s = toFixedString('abc', 5)` no longer silently return too few rows. [#112639](https://github.com/ClickHouse/ClickHouse/pull/112639) ([Groene AI](https://github.com/groeneai)).
* Fixed a large `max_concurrent_threads_ratio_to_cores` value in `CREATE WORKLOAD` producing an unspecified concurrent-thread limit. The ratio is now clamped before narrowing, so such a value means "no limit". [#113206](https://github.com/ClickHouse/ClickHouse/pull/113206) ([Groene AI](https://github.com/groeneai)).
* Fix wrong results when plan-based parallel replicas shipped a read pinned by `select_sequential_consistency`. Follower replicas rebuilt the read without the pinned block-number boundary and returned rows the insert quorum never confirmed. Such a read is now executed locally. [#114263](https://github.com/ClickHouse/ClickHouse/pull/114263) ([Groene AI](https://github.com/groeneai)).
* Fixed reading `Parquet` files whose offset index does not start at row 0. Such a file could make the native `Parquet` reader return wrong rows, or report `LOGICAL_ERROR` instead of `INCORRECT_DATA`. The offset index is now validated when it is read. [#114530](https://github.com/ClickHouse/ClickHouse/pull/114530) ([Groene AI](https://github.com/groeneai)).
* Fix query condition cache poisoning by `JOIN` queries with `query_plan_join_shard_by_pk_ranges = 1`, which made later queries with the same `WHERE` condition return too few rows. [#114827](https://github.com/ClickHouse/ClickHouse/pull/114827) ([János Benjamin Antal](https://github.com/antaljanosbenjamin)).
* Fixed AI functions under-reporting provider usage in `system.query_log` and in per-query quotas: counters accumulated before a failed request were dropped, and tokens for a response the provider billed for but that failed validation were never counted. [#114905](https://github.com/ClickHouse/ClickHouse/pull/114905) ([George Larionov](https://github.com/george-larionov)).
* Fixed `Coordination mode mismatch for stream
: got Default, expected WithOrder` when a parameterized view is used as an `IN` subquery of an ordered query with parallel replicas enabled. A parameterized view used this way no longer plans its inner read with parallel replicas coordination on a replica. [#114916](https://github.com/ClickHouse/ClickHouse/pull/114916) ([Groene AI](https://github.com/groeneai)).
* Fix asynchronous inserts into `JSON` columns ignoring the `max_dynamic_subcolumns_in_json_type_parsing` setting. Previously, an asynchronous insert (`async_insert = 1`) could store more dynamic paths than the setting allows, giving a different column layout than a synchronous insert with the same settings. The cap is now preserved when asynchronous inserts aggregate parsed data. [#115329](https://github.com/ClickHouse/ClickHouse/pull/115329) ([Mikhail f. Shiryaev](https://github.com/Felixoid)).
* Validate the discriminator of deserialized `Variant` values, so malformed data is rejected instead of being read out of bounds. [#115443](https://github.com/ClickHouse/ClickHouse/pull/115443) ([Azat Khuzhin](https://github.com/azat)).
* Fix `UNKNOWN_IDENTIFIER` when creating a materialized view whose query uses an expression alias as the right argument of `IN`. Closes [#94894](https://github.com/ClickHouse/ClickHouse/issues/94894). [#115651](https://github.com/ClickHouse/ClickHouse/pull/115651) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fix `RESTORE ... AS ` leaving the `REFRESH ... DEPENDS ON` list of a refreshable materialized view pointing at the original database. The restored view refreshed in response to a table it no longer read, ignored refreshes of its own parent, and stopped refreshing entirely once the original database was dropped. [#115689](https://github.com/ClickHouse/ClickHouse/pull/115689) ([Groene AI](https://github.com/groeneai)).
* Validate the deserialized states of `stochasticLinearRegression`, `stochasticLogisticRegression`, `groupUniqArray`, `groupArrayIntersect`, and `topK`, and of the `Resample` combinator, so malformed data is rejected instead of being read out of bounds. [#115701](https://github.com/ClickHouse/ClickHouse/pull/115701) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Mask the `aws_external_id` setting of the `DataLakeCatalog` database engine in `SHOW CREATE DATABASE` and `system.databases.engine_full`. It was previously printed in plaintext, unlike the other AWS credential settings. Closes [#114999](https://github.com/ClickHouse/ClickHouse/issues/114999). [#115791](https://github.com/ClickHouse/ClickHouse/pull/115791) ([Groene AI](https://github.com/groeneai)).
* Fixed `SELECT count()` never terminating, or returning an invented row count, on a corrupted `MsgPack` or `ProtobufList` file. The `optimize_count_from_files` fast path counted rows without requiring the read position to advance, so a two-byte `ProtobufList` file produced billions of rows and never returned. Such input is now rejected with the same error the ordinary read path gives. [#115884](https://github.com/ClickHouse/ClickHouse/pull/115884) ([Groene AI](https://github.com/groeneai)).
* Fixed `ATTACH TABLE ... AS REPLICATED` and the `convert_to_replicated` flag file accepting a conversion whose ZooKeeper path is not a safe path. On a server whose `default_replica_path` substitutes `{database}` or `{table}`, a name containing `/` used to resolve to a path inside another table's subtree, letting the converted table register a replica under a table it has no privileges on. Such a conversion is now rejected with `BAD_ARGUMENTS`, the same way an equivalent `CREATE` already was. Closes [#115967](https://github.com/ClickHouse/ClickHouse/issues/115967). [#115991](https://github.com/ClickHouse/ClickHouse/pull/115991) ([Groene AI](https://github.com/groeneai)).
* Fixed wrong results when joining against a view or `view` whose projected column has the same name as a column of one of its own inner relations, for example `SELECT expr(x.c0) AS c0 FROM a AS x, b AS y`. The join order optimizer merged such an expression into the flattened join graph and then applied it twice, so the query silently returned skewed values. When the expression also changed the column type, the same cause produced `AMBIGUOUS_COLUMN_NAME` at plan time instead. Closes [#116036](https://github.com/ClickHouse/ClickHouse/issues/116036). [#116152](https://github.com/ClickHouse/ClickHouse/pull/116152) ([Groene AI](https://github.com/groeneai)).
* Listing `tlsv1_3` in `` (or the `client` equivalent) now actually disables TLS 1.3. Previously the token was dropped with no error or log line and the server kept negotiating TLS 1.3, so an operator who disabled it believed TLS 1.3 was off while it was not. Closes [#79876](https://github.com/ClickHouse/ClickHouse/issues/79876). [#116170](https://github.com/ClickHouse/ClickHouse/pull/116170) ([Groene AI](https://github.com/groeneai)).
* Fixed `Invalid number of columns in chunk pushed to OutputPort` (`LOGICAL_ERROR`) when a `SELECT ... FROM t STREAM ... ORDER BY ... LIMIT n` query read a table with a `PROJECTION`. Lazy materialization is no longer applied to a `STREAM` read. [#116187](https://github.com/ClickHouse/ClickHouse/pull/116187) ([Groene AI](https://github.com/groeneai)).
* Fixed `system.detached_tables` failing with `NOT_IMPLEMENTED` when the server has databases such as `Dictionary`, `Filesystem`, `HDFS`, `Overlay`, or `S3`. Unsupported database engines are now skipped during iteration. Closes [#104868](https://github.com/ClickHouse/ClickHouse/issues/104868). [#107943](https://github.com/ClickHouse/ClickHouse/pull/107943) ([Aditya Kumar](https://github.com/adityaksolves)).
* Skip the Query Condition Cache for object-storage files whose `ETag` is not a strong content identifier, such as `HDFS`. Previously a same-second, same-size overwrite could reuse stale skip marks and silently drop matching rows. Closes [#112016](https://github.com/ClickHouse/ClickHouse/issues/112016). [#112051](https://github.com/ClickHouse/ClickHouse/pull/112051) ([Zhang Yifan](https://github.com/zhangyifan27)).
* Fixed text index functions `hasToken`, `hasAnyTokens`, `hasAllTokens`, and `hasPhrase` outside `WHERE`/`PREWHERE`: they now apply the index's tokenizer and pre/postprocessing in the `SELECT` list, aggregate arguments, and with `use_skip_indexes = 0`, so results match the index path. Closes [#108808](https://github.com/ClickHouse/ClickHouse/issues/108808). [#113154](https://github.com/ClickHouse/ClickHouse/pull/113154) ([Elmi Ahmadov](https://github.com/ahmadov)).
* Fix wrong results for a query that calls the same table function twice with arguments that differ only in a part of the query that was not taken into account by the AST hash, such as `UNION ALL` against `UNION DISTINCT`, `INTERSECT` against `EXCEPT`, `LIMIT` against `OFFSET`, or the bounds of a window frame. The second call reused the result of the first one. [#114171](https://github.com/ClickHouse/ClickHouse/pull/114171) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fix `THERE_IS_NO_COLUMN` / `NOT_FOUND_COLUMN_IN_BLOCK` when a filter that runs after `FINAL` is a plain column reference. This affected an explicit `PREWHERE b` under `FINAL` and, with default settings, a row policy whose expression is a bare column. [#114578](https://github.com/ClickHouse/ClickHouse/pull/114578) ([Groene AI](https://github.com/groeneai)).
* Fix loading old `S3` tables with globbed paths and `PARTITION BY` after upgrading from versions before 26.6. [#115277](https://github.com/ClickHouse/ClickHouse/pull/115277) ([Bharat Nallan](https://github.com/bharatnc)).
* Fix `Iceberg` identity-partitioned reads: partition values are now taken from partition metadata instead of returned as `NULL`. Closes [#110216](https://github.com/ClickHouse/ClickHouse/issues/110216). [#116129](https://github.com/ClickHouse/ClickHouse/pull/116129) ([Konstantin Vedernikov](https://github.com/scanhex12)).
* `KeeperMap` now writes single-expression primary keys without redundant outer parentheses, so metadata created by newer servers remains readable by ClickHouse 26.4 during supported rolling upgrades and rollbacks. [#116369](https://github.com/ClickHouse/ClickHouse/pull/116369) ([Sergey Kuznetsov](https://github.com/skuznetsov-clickhouse)).
* Fixed `Kafka` tables using `kafka_sasl_mechanism = 'AWS_MSK_IAM'` failing authentication once an hour with `SASL authentication error: Access denied`. The `OAUTHBEARER` token lifetime advertised to `librdkafka` is now capped by the remaining validity of the AWS credentials that signed the token, so the next token refresh is always scheduled before those credentials expire. Successful token refreshes are now logged, and unhelpful ClickHouse-side stack traces are omitted from broker-originated SASL errors in `system.kafka_consumers`. [#109125](https://github.com/ClickHouse/ClickHouse/pull/109125) ([kalavt](https://github.com/kalavt)).
* Fixed silent truncation of `DateTime64` and `Time64` values with a scale above 6 when `date_time_64_output_format_cut_trailing_zeros_align_to_groups_of_thousands` is enabled. The printed fraction was capped at 6 digits, so a `DateTime64(9)` value of `00:00:00.000000700` rendered as `00:00:00.000000` even though the stored value was not zero. The documented output range of the setting widens from `[0, 3, 6]` to `[0, 3, 6, 9]`. [#112854](https://github.com/ClickHouse/ClickHouse/pull/112854) ([Groene AI](https://github.com/groeneai)).
* Fixed the `dpsub` and `dpsize` join-order optimizations (`query_plan_optimize_join_order_algorithm = 'dpsub'` / `'dpsize'`) silently dropping single-table filter conditions from a `JOIN ... ON` clause, which could return extra rows. [#114629](https://github.com/ClickHouse/ClickHouse/pull/114629) ([Fisnik Kastrati](https://github.com/fkastrati)). [#118126](https://github.com/ClickHouse/ClickHouse/pull/118126) ([Fisnik Kastrati](https://github.com/fkastrati)).
* `ZooKeeper` multi requests now reject unsupported and mixed read/write operations. [#115768](https://github.com/ClickHouse/ClickHouse/pull/115768) ([Antonio Andelic](https://github.com/antonio2368)).
* You can now read `Iceberg` v2 tables whose manifests omit the optional `snapshot_id` column, such as tables managed by BigQuery; reading one previously failed with `Cannot find column snapshot_id`. A manifest that omits `sequence_number` is also no longer read as sequence number `0`. Both values are inherited from the manifest list, as the `Iceberg` spec requires. [#116040](https://github.com/ClickHouse/ClickHouse/pull/116040) ([Takayuki Enomoto](https://github.com/tkykenmt)).
* Fixed `_path` path normalization for globbed files and object-storage reads, so `WHERE _path = ''` no longer misses rows because of redundant or leading separators. Globbed reads through symlinks and `..` names also no longer read or, with `rename_files_after_processing`, rename the wrong file. [#116244](https://github.com/ClickHouse/ClickHouse/pull/116244) ([Groene AI](https://github.com/groeneai)). [#116252](https://github.com/ClickHouse/ClickHouse/pull/116252) ([Groene AI](https://github.com/groeneai)).
* Fixed wrong window function results for `PARTITION BY` over a floating-point key (also `JSON`, `Dynamic`, and these types nested in `Nullable`, `LowCardinality`, `Array`, `Tuple`, `Map`, or `Variant`) with `max_threads > 1`: values that compare as equal, such as `-0.` and `0.`, could hash into different threads, and one logical partition got several window frames. [#116315](https://github.com/ClickHouse/ClickHouse/pull/116315) ([Alexander Gololobov](https://github.com/davenger)).
* A `Native`-protocol client can now forward an unknown setting to the server by name. Previously, when a client sent such a setting as a custom setting, the server left the real setting unchanged and reported it at its default value in the settings received with the query. [#116317](https://github.com/ClickHouse/ClickHouse/pull/116317) ([Miсhael Stetsyuk](https://github.com/mstetsyuk)).
* Fixed `h3Line` returning uninitialized memory in the tail of the result array when a line between two valid H3 indices cannot be drawn because it crosses pentagon distortion. Such a call now throws `INCORRECT_DATA`. [#116583](https://github.com/ClickHouse/ClickHouse/pull/116583) ([Groene AI](https://github.com/groeneai)).
* `CREATE TABLE ... AS
` no longer accepts a `PRIMARY KEY` in its column list. Previously, such a statement wrote table metadata that the server could not parse back on the next start, so the database failed to load with a syntax error. [#116645](https://github.com/ClickHouse/ClickHouse/pull/116645) ([Groene AI](https://github.com/groeneai)).
* Fixed wrong row counts and dropped rows when a `DateTime64` primary-key column is filtered through `toStartOfDay`, `toRelativeSecondNum`, `toRelativeMinuteNum`, `toRelativeHourNum`, `toRelativeDayNum`, `toRelativeWeekNum`, `toMonthNumSinceEpoch`, or `toYearNumSinceEpoch` with values outside the `UInt32`-seconds range (before 1970 or beyond 2106). These functions claimed to be always monotonic to the primary index, but their standard-precision results wrapped for out-of-range `DateTime64`, breaking primary-key pruning. [#110344](https://github.com/ClickHouse/ClickHouse/pull/110344) ([Groene AI](https://github.com/groeneai)).
* Fix regressions around `use_legacy_to_time`: `MergeTree` key expressions using `toTime` that were created with the legacy semantics now work again, and `CREATE TABLE ... AS SELECT`, `CREATE TABLE ... AS
`, and `CREATE MATERIALIZED VIEW` no longer fail or silently flatten `Nested` columns when `use_legacy_to_time = 1`. Closes [#117001](https://github.com/ClickHouse/ClickHouse/issues/117001). [#110958](https://github.com/ClickHouse/ClickHouse/pull/110958) ([Groene AI](https://github.com/groeneai)). [#116953](https://github.com/ClickHouse/ClickHouse/pull/116953) ([Yarik Briukhovetskyi](https://github.com/yariks5s)).
* Fix `OPTIMIZE TABLE ... MANIFEST` on `Iceberg` tables: tables whose metadata file omits the spec-optional top-level `refs` object no longer fail with `Poco::NullPointerException`, and an experimental `Iceberg` table whose rows had all been deleted no longer crashes. Closes [#112082](https://github.com/ClickHouse/ClickHouse/issues/112082). [#112163](https://github.com/ClickHouse/ClickHouse/pull/112163) ([Groene AI](https://github.com/groeneai)). [#111241](https://github.com/ClickHouse/ClickHouse/pull/111241) ([Smita Kulkarni](https://github.com/SmitaRKulkarni)).
* Fix a server crash during a `JOIN` that spills to disk. When an allocation failed while the join rehashed its buckets, the in-memory join was left either holding released data or absent altogether, and another build thread could dereference it. [#113410](https://github.com/ClickHouse/ClickHouse/pull/113410) ([Groene AI](https://github.com/groeneai)).
* Fix wrong statistics-part pruning for negated floating-point predicates with `NaN`. [#113507](https://github.com/ClickHouse/ClickHouse/pull/113507) ([Han Fei](https://github.com/hanfei1991)).
* Fix a spurious `PreconditionFailed` (`Code: 499`) error when creating or committing to an `Iceberg` table. If the object store drops the response to the metadata write after the object was written, the retry of that conditional write hits its own object and the query fails even though the write succeeded. Also stop a conditional multipart completion from reporting success over an object it did not write, silently losing the write it was meant to reject. [#113994](https://github.com/ClickHouse/ClickHouse/pull/113994) ([Groene AI](https://github.com/groeneai)).
* Fixed lightweight `UPDATE` on `ReplicatedMergeTree` being rejected with `TIMEOUT_EXCEEDED` after a few seconds under concurrent updates, long before the configured `lock_acquire_timeout` elapsed. The Keeper lock acquisition loop was bounded by a fixed number of tries instead of by the timeout, so raising `lock_acquire_timeout` had no effect. [#114125](https://github.com/ClickHouse/ClickHouse/pull/114125) ([Groene AI](https://github.com/groeneai)).
* Fix `ORDER BY ... LIMIT` queries on `Tuple()` columns raising a `NOT_IMPLEMENTED` exception when top-K dynamic filtering is enabled. Direct empty tuples now skip the optimization, while supported nested composite types continue to use top-K filtering. [#114182](https://github.com/ClickHouse/ClickHouse/pull/114182) ([Langning Zhang](https://github.com/Boulea7)).
* Fix `Iceberg` tables partitioned by `toRelativeDayNum` or `toRelativeHourNum` publishing the non-canonical transform names `days` and `hours` in metadata. ClickHouse now writes the spec-defined singular names `day` and `hour`, so external readers such as `pyiceberg` can parse the partition spec. [#114864](https://github.com/ClickHouse/ClickHouse/pull/114864) ([yanglongwei](https://github.com/ylw510)).
* Fix the server failing to start when `listen_host` contains both `::` and `0.0.0.0` and `arrowflight_port` is configured, and fix two gRPC listeners silently sharing one port in the same configuration. `listen_try` now also covers the gRPC and Arrow Flight protocols, which bind their listening socket when they are started. [#115074](https://github.com/ClickHouse/ClickHouse/pull/115074) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fix a case where expensive ZooKeeper exception logging could delay session finalization and leave pending requests unresolved. [#115396](https://github.com/ClickHouse/ClickHouse/pull/115396) ([Antonio Andelic](https://github.com/antonio2368)).
* An invalid `http_handlers` configuration is now reported with its own error instead of being wrapped into `NETWORK_ERROR "Listen [host]:port failed"`. Previously, when `listen_try` was in effect, the error was only logged as a warning about `listen_host` and the server started without serving HTTP at all. The same applies to the Prometheus listener on `prometheus.port`, to the Keeper control endpoints on `keeper_server.http_control`, and to `SYSTEM START LISTEN HTTP` in `clickhouse-local`, which blamed `listen_host` and `http_port`. [#115548](https://github.com/ClickHouse/ClickHouse/pull/115548) ([Groene AI](https://github.com/groeneai)).
* Fixed zero-precision `DateTime64` and `Time64` text conversions returning `DateTime` or `Time` instead of `DateTime64(0)` or `Time64(0)`: `toDateTime64OrNull`, `toDateTime64OrZero`, `parseDateTime64BestEffort`, `parseDateTime64BestEffortOrNull`, `parseDateTime64BestEffortOrZero`, `parseDateTime64BestEffortUS`, `parseDateTime64BestEffortUSOrNull`, `parseDateTime64BestEffortUSOrZero`, `toTime64OrZero`, and `toTime64OrNull`. This previously prevented conversion of dates before `1970-01-01` and made the `Time64` functions silently lose values that `toTime64` parses. [#115618](https://github.com/ClickHouse/ClickHouse/pull/115618) ([Mark Needham](https://github.com/mneedham)). [#116979](https://github.com/ClickHouse/ClickHouse/pull/116979) ([Navneet Kumar](https://github.com/navneet83)).
* Fixed a server startup failure after creating an `Alias` table whose target did not exist yet and later became an `Alias` table itself. Such a table was accepted by `CREATE`, but rejected while loading metadata, which aborted startup with `BAD_ARGUMENTS`. The `Alias` target restrictions are now applied only to freshly supplied definitions. [#116153](https://github.com/ClickHouse/ClickHouse/pull/116153) ([Groene AI](https://github.com/groeneai)).
* Fix `SHOW CREATE TABLE` failing instead of describing the table when the table's storage object cannot be opened, for example a `DataLakeCatalog` table the catalog reports as unreadable. The `Alias` target-access check now consults the engine name of the create query instead of opening the table. [#116231](https://github.com/ClickHouse/ClickHouse/pull/116231) ([Groene AI](https://github.com/groeneai)).
* Fix `ProfileEvents['SelectedRows']` and `ProfileEvents['SelectedBytes']` being counted twice for reads from file, object-storage, data lake, queue, and executable table engines and table functions, and for executable dictionaries and UDFs. They now agree with `read_rows` and `read_bytes`, as does the `Read:` line of `EXPLAIN ANALYZE`. [#116427](https://github.com/ClickHouse/ClickHouse/pull/116427) ([Groene AI](https://github.com/groeneai)). [#116679](https://github.com/ClickHouse/ClickHouse/pull/116679) ([Groene AI](https://github.com/groeneai)).
* Fixed `executable_pool` dictionaries, `executable_pool` user-defined functions, and `ExecutablePool` tables waiting ten times longer than the configured `max_command_execution_time` when the process pool is exhausted, while the resulting error still reported the configured value. Closes [#116467](https://github.com/ClickHouse/ClickHouse/issues/116467). [#116560](https://github.com/ClickHouse/ClickHouse/pull/116560) ([Groene AI](https://github.com/groeneai)).
* Fixed a server crash when reading an `Iceberg` table whose manifest list declares a very large `manifest_length`. The declared value was used as the metadata cache entry weight, overflowing the cache accounting and terminating the server. The size measured while reading the manifest file is now used instead. [#116564](https://github.com/ClickHouse/ClickHouse/pull/116564) ([Groene AI](https://github.com/groeneai)).
* Fixed a hang when a query names a database that does not exist, either through the `database` setting (for example `SELECT 1 SETTINGS database = 'no_such_db'`) or through the `database` field of a gRPC request. Such a query now fails with `UNKNOWN_DATABASE` instead of blocking its connection forever; while it was hung it was also invisible to `system.processes` and to `KILL QUERY`. [#116582](https://github.com/ClickHouse/ClickHouse/pull/116582) ([Groene AI](https://github.com/groeneai)).
* Fixed a use-after-free where a subscriber of workload entity changes, such as an object-storage disk, could be destroyed while its own change callback was still running. Destroying a workload entity subscription now waits for an in-flight callback and stops new ones from starting. Reachable from a `CREATE TABLE` with an inline `disk(...)` definition whose startup fails, concurrently with `CREATE RESOURCE` or `DROP RESOURCE` from another session. [#116607](https://github.com/ClickHouse/ClickHouse/pull/116607) ([Groene AI](https://github.com/groeneai)).
* Fixed an exception when reading an `Iceberg` table whose manifest marks a delete file as an equality delete without listing any equality field id. Such an entry is now rejected with `ICEBERG_SPECIFICATION_VIOLATION` instead of an untyped `std::out_of_range`. [#116617](https://github.com/ClickHouse/ClickHouse/pull/116617) ([Groene AI](https://github.com/groeneai)).
* Fixed the `file` table function reading and writing outside `user_files_path` when a `..` reached the path behind a directory symlink leaving `user_files_path`: through brace expansion in a glob pattern, or through a `..` partition id in `INSERT INTO FUNCTION file(...) PARTITION BY`. [#116767](https://github.com/ClickHouse/ClickHouse/pull/116767) ([Groene AI](https://github.com/groeneai)).
* Fixed corrupted or crafted `Gorilla`-compressed data being decoded to wrong values instead of being rejected. Such data is now rejected with `CANNOT_DECOMPRESS`. [#116820](https://github.com/ClickHouse/ClickHouse/pull/116820) ([Groene AI](https://github.com/groeneai)).
* Fixed the `loop` table function disclosing the column names and types of an `Alias` table's target to a user who holds no privilege on that target: a query that read no rows received them in its response header. `loop` now requires table-level `SELECT` on the target, matching what it already required of the table name it is given. [#116873](https://github.com/ClickHouse/ClickHouse/pull/116873) ([Groene AI](https://github.com/groeneai)).
* Fixed incorrect results or an exception for `-State` aggregates combined with `-OrDefault` or `-OrFill` under `WITH TOTALS`, `ROLLUP`, or `CUBE`. [#99980](https://github.com/ClickHouse/ClickHouse/pull/99980) ([Ilya Yatsishin](https://github.com/qoega)).
* Fixed `Iceberg` `INSERT` writing manifest-wide aggregate column statistics into every `data_file` entry when a partition produced more than one data file. Each entry's `null_value_counts`, `column_sizes`, `lower_bounds`, and `upper_bounds` now describe only the data file it points at. Previously an entry could report more nulls than the file had rows, so a spec-conforming external reader could prune files that contained matching rows. [#112414](https://github.com/ClickHouse/ClickHouse/pull/112414) ([Groene AI](https://github.com/groeneai)).
* Fix a server abort while committing a mutated part when its column or secondary-index sizes had not been computed yet. [#112691](https://github.com/ClickHouse/ClickHouse/pull/112691) ([Groene AI](https://github.com/groeneai)).
* Fix reading corrupted `ArrowStream` files. A malformed per-buffer uncompressed-length prefix in a compressed Arrow IPC record batch could reach the allocator as an enormous allocation size and produce `LOGICAL_ERROR`; it is now rejected as `INCORRECT_DATA`. [#113006](https://github.com/ClickHouse/ClickHouse/pull/113006) ([Groene AI](https://github.com/groeneai)).
* Fix wrong results for `GROUP BY` whose only key is an injective function of constants, for example `SELECT 1 FROM t GROUP BY materialize(NULL)`. Such a key could be removed, leaving the query with no `GROUP BY` and no aggregation, so it returned one row per input row instead of one row per group. Over a `Merge` table that mixes a local and a remote child, the same cause could also raise the exception `Chunk info was not set for chunk in GroupingAggregatedTransform`. [#114981](https://github.com/ClickHouse/ClickHouse/pull/114981) ([Groene AI](https://github.com/groeneai)).
* Fixed the exception `Not-ready Set is passed as the second argument for function 'in'` in three cases: when selecting from a `Merge` table (or the `merge` table function) whose underlying table has a row policy containing an `IN` subquery, when a query with `partial_result_on_first_cancel = 1` was cancelled while building the set for `IN (subquery)`, and when a correlated subquery whose body contains `IN (subquery)` runs with `correlated_subqueries_use_in_memory_buffer = 0`, which `make_distributed_plan = 1` also sets. [#114058](https://github.com/ClickHouse/ClickHouse/pull/114058) ([Groene AI](https://github.com/groeneai)). [#115083](https://github.com/ClickHouse/ClickHouse/pull/115083) ([Alexey Milovidov](https://github.com/alexey-milovidov)). [#115868](https://github.com/ClickHouse/ClickHouse/pull/115868) ([Groene AI](https://github.com/groeneai)).
* Fix authentication over the PostgreSQL wire protocol for users with several authentication methods. Users who also had an `ssh_key` method, or another method with no password, were rejected with `Invalid user or password` even when the correct password for `scram_sha256_password` was supplied, and the wrong SCRAM salt was sent when `scram_sha256_password` was not the last method. [#115084](https://github.com/ClickHouse/ClickHouse/pull/115084) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed `THERE_IS_NO_COLUMN` (`Cannot find column in source stream`) for `SELECT DISTINCT expr(k) ... ORDER BY k` on a table with an aggregate projection grouped on `k`. Closes [#112168](https://github.com/ClickHouse/ClickHouse/issues/112168). [#115147](https://github.com/ClickHouse/ClickHouse/pull/115147) ([Groene AI](https://github.com/groeneai)).
* A `text` index is now used for `hasAnyTokens`, `hasAllTokens`, and `hasPhrase` called with an explicit tokenizer argument when that argument denotes the same tokenizer as the index. Previously the three-argument form always fell back to a full scan. Closes [#115275](https://github.com/ClickHouse/ClickHouse/issues/115275). [#115348](https://github.com/ClickHouse/ClickHouse/pull/115348) ([Groene AI](https://github.com/groeneai)).
* Fix an exception in a window function over a `Tuple` with a sparse element, for example `groupConcat(t) OVER ()`. [#115705](https://github.com/ClickHouse/ClickHouse/pull/115705) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Conversion between named tuples with disjoint element names is now positional instead of silently filling the result with default values, and aliases that only give names to tuple elements can now repeat without error, for example `SELECT tuple(1 AS x), tuple(2 AS x)`. [#115717](https://github.com/ClickHouse/ClickHouse/pull/115717) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Cancel in-flight merges, mutations, and part fetches during graceful server shutdown instead of waiting for the running step to finish. Previously a single slow merge step or a large part download could delay shutdown for its whole duration. [#115733](https://github.com/ClickHouse/ClickHouse/pull/115733) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed a `WHERE _table = ...` or `WHERE _database = ...` condition over a `Merge` table silently returning no rows when the matching child table reads its data from other tables, for example a `Distributed`, `Merge`, `Buffer`, or `Alias` child. Such children are now always read, and the condition filters their rows. [#116371](https://github.com/ClickHouse/ClickHouse/pull/116371) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fix corrupted output when `framing_output_format` is used together with `http_write_exception_in_output_format = 1` (the default for `compatibility` below 25.11). Data packets after the first one repeated the bytes of the first packet padded with zeros, and the query failed with `std::length_error`. This affected the Web UI, which reported a JSON parse error after the first few rows. [#116620](https://github.com/ClickHouse/ClickHouse/pull/116620) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fix links between settings, functions, and section headings on the built-in `/docs` page. References to other settings or functions did nothing when clicked, and `#` heading anchors put a corrupted section into the URL. [#116635](https://github.com/ClickHouse/ClickHouse/pull/116635) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed an exception when reading from a table after `DETACH` and `ATTACH` of a partition with patch parts created by lightweight updates. [#116695](https://github.com/ClickHouse/ClickHouse/pull/116695) ([Anton Popov](https://github.com/CurtizJ)).
* Fixed silently wrong results when reading a `Parquet` file whose offset index disagrees with the page data on an `Array`, `Map`, or nested column. Such a page is now rejected with `INCORRECT_DATA` instead of returning another page's values under the requested row numbers. [#116788](https://github.com/ClickHouse/ClickHouse/pull/116788) ([Groene AI](https://github.com/groeneai)).
* Fix background cleanup of unused `store/` directories on encrypted disks. ClickHouse can now revoke permissions and remove these orphaned directories instead of failing during cleanup. [#116919](https://github.com/ClickHouse/ClickHouse/pull/116919) ([Ivan Shelestov](https://github.com/Shelestov7)).
* Fix `Native`-protocol memory allocation from truncated input: server-declared sizes no longer make the client allocate memory for data that has not arrived; exception strings are read as they arrive, the decompressed block size is bounded, and the maximum number of rows in a `Native` block is now one billion. [#117011](https://github.com/ClickHouse/ClickHouse/pull/117011) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fix the exception `max_rows > 0` (and possible incorrect merge results in release builds) in `MergingSortedTransform` when an input delivers a trailing empty chunk together with end-of-stream, for example under `optimize_read_in_order`. [#117048](https://github.com/ClickHouse/ClickHouse/pull/117048) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Internal queries derived from an existing `QueryPlan` now preserve execution limits and shared resources instead of losing settings such as `max_threads` and concurrency control. [#109722](https://github.com/ClickHouse/ClickHouse/pull/109722) ([Groene AI](https://github.com/groeneai)).
* Fix wrong results when an `Enum8` or `Enum16` constant is compared with a `String` or `FixedString` column. The constant was converted to the enum's underlying number instead of its name, so primary-key and `PARTITION BY` pruning, the `bloom_filter` skip index, `IN` and `NOT IN` sets, and the `values` table function could silently use the wrong value. Matching rows could be dropped, `NOT IN` could keep rows it should exclude, and `IN` could disagree with `=` on the same constant. [#112647](https://github.com/ClickHouse/ClickHouse/pull/112647) ([Groene AI](https://github.com/groeneai)).
* Fix wrong `ORDER BY` and `DISTINCT` results, and `CANNOT_CONVERT_TYPE` for aggregate functions, when reading a `Merge` table whose declared column type does not preserve the sort order of a source table's type, for example `UInt64` over a source holding negative `Int64`. [#113242](https://github.com/ClickHouse/ClickHouse/pull/113242) ([Groene AI](https://github.com/groeneai)).
* Fix `min` and `max` returning a wrong value when the implicit `_minmax_count_projection` answered them from a part-level bound that is not a real row value: `NULL` in a `Nullable` sorting key, `NaN` in a floating-point key, or a `Tuple` bound assembled component-wise. Such a query now reads rows instead of using the projection. [#115151](https://github.com/ClickHouse/ClickHouse/pull/115151) ([Groene AI](https://github.com/groeneai)).
* Fixed a settings-constraint bypass: a `SETTINGS` clause inside a subquery, a CTE, or a view's inner query was applied without checking the settings constraints, so it could leave `readonly` mode or override a `CONST`, `MIN`, or `MAX` constraint such as `additional_table_filters`, breaking row-level isolation. Nested clauses are now clamped to the constraints instead. [#115397](https://github.com/ClickHouse/ClickHouse/pull/115397) ([Itamar Tempelhof](https://github.com/tempel-it)).
* Fix `enable_adaptive_aggregator` with `max_rows_to_group_by` in `throw` mode: adaptive aggregation no longer silently falls back to the regular algorithm, and the merged total is now checked against the limit in parallel two-level aggregation, including bucket Top-K and spill-to-disk paths. [#116451](https://github.com/ClickHouse/ClickHouse/pull/116451) ([Nihal Z. Miaji](https://github.com/nihalzp)).
* Fixed wrong results and an exception in primary-key analysis for `intDiv` and `divide` over a `Decimal` key with an integer constant divisor that does not fit the decimal's native width. Such a query could return no rows at all instead of the matching ones. [#116608](https://github.com/ClickHouse/ClickHouse/pull/116608) ([Groene AI](https://github.com/groeneai)).
* Column names such as `inf`, `infinity`, `nan`, `true`, and `false` are now quoted when formatted, so a sorting key that refers to them no longer writes metadata the server cannot parse on the next start. Previously the table, and with it the whole database, failed to load. [#116802](https://github.com/ClickHouse/ClickHouse/pull/116802) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fix a server crash when creating a table whose columns form a long chain of `DEFAULT` expressions, such as `c1 DEFAULT c0 + 1, c2 DEFAULT c1 + 1, ...`. Planning such a statement no longer exhausts the thread stack. [#116978](https://github.com/ClickHouse/ClickHouse/pull/116978) ([Groene AI](https://github.com/groeneai)).
* Fixed a `ReplicatedMergeTree` replication queue getting stuck forever after a new replica was added by cloning an existing one. The queue could contain two `ALTER_METADATA` entries for the same `ALTER`, so subsequent `ALTER`s waited indefinitely and `SYSTEM SYNC REPLICA` timed out. [#117107](https://github.com/ClickHouse/ClickHouse/pull/117107) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Detect a column-count mismatch between a tuple and a subquery in the `IN` clause during analysis, preventing constant folding from silently hiding the error. [#97540](https://github.com/ClickHouse/ClickHouse/pull/97540) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fix `LOGICAL_ERROR` (`Temporary part ... already added`) when `OPTIMIZE ... DRY RUN` runs concurrently with a real merge, or with another `DRY RUN`, on the same parts. [#110916](https://github.com/ClickHouse/ClickHouse/pull/110916) ([Groene AI](https://github.com/groeneai)).
* Fixed a server startup crash when the background updater for dictionaries and executable user-defined functions applied an empty configuration before the first configuration repository was registered. [#113238](https://github.com/ClickHouse/ClickHouse/pull/113238) ([Groene AI](https://github.com/groeneai)).
* Fixed a data race and a use-after-free on the metadata of `DeltaLake` and `Iceberg` tables. Concurrent queries reading `total_rows` or `total_bytes` from `system.tables` for the same table could crash the server. Closes [#113265](https://github.com/ClickHouse/ClickHouse/issues/113265). [#113427](https://github.com/ClickHouse/ClickHouse/pull/113427) ([Groene AI](https://github.com/groeneai)).
* Fixed `arrayROCAUC` and `arrayAUCPR`, and their aliases `arrayAUC` and `arrayPRAUC`, returning a different result for the same data depending on the order of the array elements when a score was `NaN`. A `NaN` score now makes the result `NaN`. Closes [#104763](https://github.com/ClickHouse/ClickHouse/issues/104763). [#115101](https://github.com/ClickHouse/ClickHouse/pull/115101) ([Groene AI](https://github.com/groeneai)).
* Fix `RESTORE` of an incremental `S3` backup chain whose locator authenticates by assuming a role with `extra_credentials(role_arn = ...)`. The role identifiers are now kept in the `` locator of the backup metadata, so each backup in the chain can reopen its base; previously chains deeper than one level could not be restored at all. Chains already written without them can still be restored with `use_same_s3_credentials_for_base_backup = 1`, except when the locator is a named collection. [#116223](https://github.com/ClickHouse/ClickHouse/pull/116223) ([Julia Kartseva](https://github.com/jkartseva)).
* Fixed missed insert deduplication when a block reaches the sink with sparse column representation, for example `INSERT ... SELECT` from a part with sparse serialization. Such an insert did not deduplicate against the same data inserted seconds ago from unmerged parts. [#116287](https://github.com/ClickHouse/ClickHouse/pull/116287) ([Mikhail f. Shiryaev](https://github.com/Felixoid)).
* Functions `h3PolygonToCells` and `h3PolygonToCellsWithContainment` now check for query timeouts and `KILL QUERY` while covering a polygon, and reject vertices whose longitude is outside `-180..180` or latitude outside `-90..90` degrees. Previously a polygon with such a vertex could keep a thread busy for tens of minutes, ignoring both. Closes [#116195](https://github.com/ClickHouse/ClickHouse/issues/116195). [#116335](https://github.com/ClickHouse/ClickHouse/pull/116335) ([Raúl Marín](https://github.com/Algunenano)).
* Fixed the exception `... to have 0 rows, but it has 1: while executing function materialize` when a dictionary with `LAYOUT(DIRECT())` is read through the `merge` table function. Closes [#116269](https://github.com/ClickHouse/ClickHouse/issues/116269). [#116378](https://github.com/ClickHouse/ClickHouse/pull/116378) ([Groene AI](https://github.com/groeneai)).
* Fix a `bloom_filter` skip index returning fewer rows for `IN` on an `Array` column when the set contains an empty array, for example `WHERE x IN ([])`. Closes [#116431](https://github.com/ClickHouse/ClickHouse/issues/116431). [#116449](https://github.com/ClickHouse/ClickHouse/pull/116449) ([Groene AI](https://github.com/groeneai)).
* Fixed wrong results from search functions (`hasPhrase`, `hasToken`, `hasAnyTokens`, `hasAllTokens`) on a text index whose `preprocessor` or `postprocessor` uses `IN` or `NOT IN`, such as `if(token IN ('the'), '', token)`. The transform was silently ignored whenever the predicate was evaluated on rows instead of read from the index, so matching rows could be missing. Closes [#116476](https://github.com/ClickHouse/ClickHouse/issues/116476). [#116578](https://github.com/ClickHouse/ClickHouse/pull/116578) ([Elmi Ahmadov](https://github.com/ahmadov)).
* Fixed a 404 (`S3_ERROR`) when reading an `Iceberg` table through a path that is a parent of the table directory, with the metadata document named by the `iceberg_metadata_file_path` setting. Writes and maintenance operations on such a table are now refused instead of acting outside the table. Closes [#116985](https://github.com/ClickHouse/ClickHouse/issues/116985). [#117037](https://github.com/ClickHouse/ClickHouse/pull/117037) ([Groene AI](https://github.com/groeneai)).
* Fixed incorrect results from `sum(if(cond, 0, 1))` when `cond` has type `LowCardinality(Nullable(...))` and `optimize_rewrite_sum_if_to_count_if` is enabled, which is the default. Rows where the condition was `NULL` were not counted. Closes [#116938](https://github.com/ClickHouse/ClickHouse/issues/116938). [#117046](https://github.com/ClickHouse/ClickHouse/pull/117046) ([Pratham Nayak](https://github.com/protomn)).
* Fixed `clickhouse-client` and `clickhouse-local` not emitting the `--chime` alert for a long-running query that ends with an error. The threshold was checked against the query time last reported by the server, which is not refreshed when a query fails, so it could be arbitrarily behind the real duration of the query. It is now checked against the time the client actually waited. [#117179](https://github.com/ClickHouse/ClickHouse/pull/117179) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed a server crash when executing `ALTER TABLE ... MATERIALIZE TTL` on a table that is not a `MergeTree` but whose metadata carries a TTL. This can affect `Alias` tables whose target has a TTL and `MaterializedView` tables that declare a TTL on one of their own columns. Closes [#117327](https://github.com/ClickHouse/ClickHouse/issues/117327). [#117181](https://github.com/ClickHouse/ClickHouse/pull/117181) ([Groene AI](https://github.com/groeneai)).
* Fixed a `LOGICAL_ERROR` in KQL `timespan` parameter handling for `LowCardinality` interval arguments. [#117162](https://github.com/ClickHouse/ClickHouse/pull/117162) ([Groene AI](https://github.com/groeneai)).
* Fix `temporary_files_buffer_size` and `format_avro_schema_registry_*` accepting out-of-range values that then made every subsequent query in the session fail with no way to recover. Such values are now bounded when set. Closes [#113782](https://github.com/ClickHouse/ClickHouse/issues/113782). [#113787](https://github.com/ClickHouse/ClickHouse/pull/113787) ([Pedro Ferreira](https://github.com/PedroTadim)).
* Fix `allow_feature_tier` rejecting `merge_tree_`-prefixed settings in settings profiles as unknown and rejecting `CREATE TABLE` because of `MergeTree` settings applied by `compatibility` or the `merge_tree` config section. Also fix constraints on a `merge_tree_`-prefixed setting being bypassed when the setting is written through its alias, and a statement that rewrites such a setting to its current value being refused by a `CONST` constraint. [#113156](https://github.com/ClickHouse/ClickHouse/pull/113156) ([Raúl Marín](https://github.com/Algunenano)).
* Fix a server crash and out-of-bounds write when inserting into a column with a long chain of compression codecs, for example `CODEC(FPC, FPC, ..., FPC)`. Such chains are now rejected with `CANNOT_COMPRESS`; chains longer than 255 codecs, which previously could write unreadable parts, are rejected up front with `BAD_ARGUMENTS` unless `allow_suspicious_codecs` is set. [#113877](https://github.com/ClickHouse/ClickHouse/pull/113877) ([Groene AI](https://github.com/groeneai)).
* Fix `OpenSSL` `cipherList` being silently ignored when its value is written on its own line, as XML or YAML auto-formatters do. The configured value is now trimmed before it reaches `OpenSSL`, and an invalid cipher list is reported instead of discarded, so the server no longer keeps `OpenSSL`'s default cipher list while appearing to honor the configured restriction. Closes [#115808](https://github.com/ClickHouse/ClickHouse/issues/115808). [#116053](https://github.com/ClickHouse/ClickHouse/pull/116053) ([Groene AI](https://github.com/groeneai)).
* Fix a server crash in the `ReplicatedMergeTree` cleanup thread when `max_replicated_logs_to_keep = 0`. That value is now rejected, matching the documented domain of the setting. [#117147](https://github.com/ClickHouse/ClickHouse/pull/117147) ([Groene AI](https://github.com/groeneai)).
* Fix path traversal in `RESTORE`: backup metadata entries whose `` is not already normalized are now rejected with `INSECURE_PATH` instead of being restored outside the part directory while `RESTORE` reports success. [#117371](https://github.com/ClickHouse/ClickHouse/pull/117371) ([Groene AI](https://github.com/groeneai)).
* Fixed memory leaks of abandoned nested aggregate states. [#113926](https://github.com/ClickHouse/ClickHouse/pull/113926) ([Groene AI](https://github.com/groeneai)).
* Preserve row counts above the signed 32-bit range on the `PostgreSQL` wire protocol. [#114397](https://github.com/ClickHouse/ClickHouse/pull/114397) ([Minh Vu](https://github.com/fallintoplace)).
* Fixed `ILLEGAL_COLUMN` for `ARRAY JOIN` queries filtered by an empty `IN` set, including an empty list and an empty `Set` table. Closes [#116018](https://github.com/ClickHouse/ClickHouse/issues/116018). [#116057](https://github.com/ClickHouse/ClickHouse/pull/116057) ([Groene AI](https://github.com/groeneai)).
* Fixed `Alias` tables ignoring row policies defined on their target tables. An `Alias` table now combines the row policies of both the alias and its target table. [#116290](https://github.com/ClickHouse/ClickHouse/pull/116290) ([Kai Zhu](https://github.com/nauu)).
* Fixed concurrent writes of the same `format_schema_source = 'string'` or `'query'` schema being rejected with `CANNOT_OPEN_FILE` or `ATOMIC_RENAME_FAIL`. [#116502](https://github.com/ClickHouse/ClickHouse/pull/116502) ([Groene AI](https://github.com/groeneai)).
* Fixed `moduloOrNull`, `intDivOrNull`, `divideOrNull`, and `positiveModuloOrNull` returning the raw division result instead of `NULL` when dividing by a constant zero inside a subquery whose result is read or persisted by an outer query. Closes [#116500](https://github.com/ClickHouse/ClickHouse/issues/116500). [#116594](https://github.com/ClickHouse/ClickHouse/pull/116594) ([Groene AI](https://github.com/groeneai)).
* Fixed `Iceberg` partition pruning when a manifest's partition tuple contains fields ClickHouse cannot model. Such tables no longer fail with `STD_EXCEPTION`, and a manifest whose tuple length disagrees with its own spec is now rejected with `ICEBERG_SPECIFICATION_VIOLATION` instead of returning deleted rows. [#116615](https://github.com/ClickHouse/ClickHouse/pull/116615) ([Groene AI](https://github.com/groeneai)).
* Fixed wrong results from `sumKahan` and `sumKahanIf` when the aggregated batch does not start at the first row of the block, including window frames, parallel `GROUP BY`, and `optimize_aggregation_in_order = 1`. [#116990](https://github.com/ClickHouse/ClickHouse/pull/116990) ([Groene AI](https://github.com/groeneai)).
* Fixed `GenerateRandom` reads with a trivial `LIMIT` returning no rows because the source-count reduction could overflow to zero. Absurdly large requested stream counts are now also rejected with `PARAMETER_OUT_OF_BOUND`. [#117171](https://github.com/ClickHouse/ClickHouse/pull/117171) ([Groene AI](https://github.com/groeneai)).
* Fixed out-of-bounds access in `timeSeriesGroupArray`. [#117404](https://github.com/ClickHouse/ClickHouse/pull/117404) ([Vitaly Baranov](https://github.com/vitlibar)).
* Fixed `GROUP BY` emitting a group from a zero-row block, returning a row with `count() = 0`. Closes [#116830](https://github.com/ClickHouse/ClickHouse/issues/116830). [#117503](https://github.com/ClickHouse/ClickHouse/pull/117503) ([Yarik Briukhovetskyi](https://github.com/yariks5s)).
* Fixed `arrayIntersect` with mixed `Nullable` and not-`Nullable` arguments. Such calls could fail or return spurious default-valued elements for some data types; `arrayUnion` and `arraySymmetricDifference` are unaffected. [#117577](https://github.com/ClickHouse/ClickHouse/pull/117577) ([Groene AI](https://github.com/groeneai)).
* `ATTACH PARTITION FROM`, `REPLACE PARTITION`, and `MOVE PARTITION TO TABLE` no longer accept a non-adaptive part whose `index_granularity` differs from the destination table's. Previously such a part could return wrong row counts in release builds. Closes [#117524](https://github.com/ClickHouse/ClickHouse/issues/117524). [#117594](https://github.com/ClickHouse/ClickHouse/pull/117594) ([Groene AI](https://github.com/groeneai)).
* Fixed `max_joined_block_size_rows = 0` (documented as unlimited) making a hash join emit one left row per output block instead of honoring `max_joined_block_size_bytes` when a left row has multiple right matches. Closes [#102007](https://github.com/ClickHouse/ClickHouse/issues/102007). [#117604](https://github.com/ClickHouse/ClickHouse/pull/117604) ([Groene AI](https://github.com/groeneai)).
* Fixed `hasColumnInTable` disclosing whether a column exists on the target of an `Alias` table when the user lacks `SHOW COLUMNS` on the target. The function now requires that privilege on the target too. [#117621](https://github.com/ClickHouse/ClickHouse/pull/117621) ([Groene AI](https://github.com/groeneai)).
* Fix silent data loss when a TTL expression applies a large interval directly to a `Date` or `DateTime` column by widening the arithmetic away from 16/32-bit overflow. [#101793](https://github.com/ClickHouse/ClickHouse/pull/101793) ([BoloniniD](https://github.com/BoloniniD)).
* Fix `Cannot insert field with type ...` when inserting a row that omits an `AggregateFunction` column whose argument types contain `LowCardinality`. `defaultValueOfTypeName` is fixed for the same type names. [#102403](https://github.com/ClickHouse/ClickHouse/pull/102403) ([Enric Calabuig](https://github.com/eclbg)).
* Fixed a privilege-escalation gap where the `executable` table function did not enforce the `TABLE ENGINE ON Executable` grant. With `table_engines_require_grant` enabled, a user denied `CREATE TABLE ... ENGINE = Executable` could still run the same server-side script via `SELECT ... FROM executable(...)`. It now requires `GRANT TABLE ENGINE ON Executable`, matching `CREATE TABLE`. [#109331](https://github.com/ClickHouse/ClickHouse/pull/109331) ([Groene AI](https://github.com/groeneai)).
* Fix silently wrong `GROUP BY` results with `optimize_aggregation_in_order = 1`. Groups were merged into one another and aggregate values were wrong when the matched sorting-key prefix contained a reverse (`DESC`) column, and, independently of reverse keys, when a group-by key was a negative monotonic function of a `Float` sorting-key column around the `NaN` boundary. This affected a single `MergeTree` table and a `Merge` table over such tables. For a `Merge` table whose underlying tables read the matched prefix in opposite physical directions, aggregation in order is now declined because a single stream direction cannot describe both. [#112200](https://github.com/ClickHouse/ClickHouse/pull/112200) ([Groene AI](https://github.com/groeneai)).
* Fix `_path` / `_file` filtering for object storage, `file`, and `url` reads. A `GLOBAL IN` subquery over `_path` or `_file` of a path without globs no longer throws `Not-ready Set is passed as the second argument for function 'globalIn'`; an explicitly named archive member is filtered before the archive is opened; `Hive` partition columns are inferred for an explicitly named key that does not exist; and `urlCluster` / `fileCluster` now prune a filtered-out path on the initiator instead of handing it to a replica. [#112968](https://github.com/ClickHouse/ClickHouse/pull/112968) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* `FileLog` tables no longer silently skip files that appear after `CREATE TABLE`. The directory watch ran as a `BackgroundSchedulePool` task but never returned, so it held its slot of the per-task-type budget forever; once `background_schedule_pool_size` times `background_schedule_pool_max_parallel_tasks_per_type_ratio` tables existed, further tables never watched their directory at all and `SELECT` returned fewer rows instead of erroring. The watch now runs on its own thread. [#113897](https://github.com/ClickHouse/ClickHouse/pull/113897) ([Groene AI](https://github.com/groeneai)).
* A query queued on a full distributed connection pool now responds to `KILL QUERY`, and to `max_execution_time` at the default `timeout_overflow_mode = 'throw'`, instead of waiting until another query happens to release a connection, and a positive `connection_pool_max_wait_ms` now actually expires. Previously the wait ended only on success at every value of the setting, so the configured timeout was ignored, `max_execution_time` was reported long after its deadline, and the query could not be killed. The wait applies per replica, so an expired one is a soft failure that fails over to the remaining replicas and only then reports `ALL_CONNECTION_TRIES_FAILED`. [#113979](https://github.com/ClickHouse/ClickHouse/pull/113979) ([Groene AI](https://github.com/groeneai)).
* Fix wrong results when a filter on a `JSON` subcolumn that mixes a literal prefix with a quoted path segment is analyzed against a `JSONAllPaths` skip index. The subcolumn name was misparsed, so all granules were skipped and the query returned fewer rows than it should. [#114873](https://github.com/ClickHouse/ClickHouse/pull/114873) ([Pavel Kruglov](https://github.com/Avogar)).
* Fix wrong results when a `SELECT` with `select_sequential_consistency = 1` on a `ReplicatedMergeTree` table runs with classic (task-based) parallel replicas. Every replica performed a complete local read clamped to the quorum boundary instead of a coordinator-assigned slice, so rows were returned once per participating replica. [#114945](https://github.com/ClickHouse/ClickHouse/pull/114945) ([Groene AI](https://github.com/groeneai)).
* Fixed `CREATE DICTIONARY` failing with `Incorrect type of ID column: must be UInt64, but it is LowCardinality` when the simple primary key is declared as `LowCardinality(UInt64)` and `dictionary_validate_primary_key_type` is enabled. Closes [#104539](https://github.com/ClickHouse/ClickHouse/issues/104539). [#115139](https://github.com/ClickHouse/ClickHouse/pull/115139) ([Groene AI](https://github.com/groeneai)).
* Fix a hang in workload memory reservations when an increase races with an in-flight decrease. [#116085](https://github.com/ClickHouse/ClickHouse/pull/116085) ([Azat Khuzhin](https://github.com/azat)).
* A `Kafka` table with `kafka_keeper_path` set (`StorageKafka2`) no longer skips messages it had already consumed when a streaming cycle fails part-way through; previously those messages were never delivered to the materialized views and a later cycle committed an offset past them. As a consequence, with the default `kafka_handle_error_mode` an unparseable message now blocks the table instead of being silently skipped, matching `StorageKafka`. `kafka_handle_error_mode = 'stream'`, `kafka_handle_error_mode = 'dead_letter_queue'`, and `kafka_skip_broken_messages` remain the ways to skip such a message. [#116485](https://github.com/ClickHouse/ClickHouse/pull/116485) ([Groene AI](https://github.com/groeneai)).
* Fixed the `Unexpected return type from materialize` logical error when reading a column that has a `text` index through the index after a metadata-only or not-yet-materialized `ALTER MODIFY COLUMN` (including lazy `JSON` type hints) that requires a read-time type conversion. [#116549](https://github.com/ClickHouse/ClickHouse/pull/116549) ([Pavel Kruglov](https://github.com/Avogar)).
* A table created with `CREATE TABLE ... AS
(...)` is no longer resolved to answer a `SYSTEM STOP`-family lock query or a `system.tables` size query about it. Previously those statements contacted the endpoint of every such table, so one unreachable endpoint made them fail or stall. Until such a table is first accessed it now reports `NULL` sizes and an empty `data_paths`, and `DROP TABLE ... IF EMPTY` removes it instead of reporting `TABLE_NOT_EMPTY`. [#116774](https://github.com/ClickHouse/ClickHouse/pull/116774) ([Groene AI](https://github.com/groeneai)).
* Fixes wrong results when a `minmax` skip index, `ORDER BY`, or `PARTITION BY` is built over an `Array`, `Tuple`, or `Map` holding a `Bool`, such as `Array(Tuple(Float64, Bool))` or `Map(String, Bool)`, and when a `minmax` index serves an `ORDER BY ... LIMIT` over a `Bool` column. Previously, rows that the predicate accepts could be dropped, because the stored bound and the value compared against it represented the boolean differently. [#116897](https://github.com/ClickHouse/ClickHouse/pull/116897) ([Groene AI](https://github.com/groeneai)).
* Fixed an external `GROUP BY` exceeding `max_memory_usage` when `enable_adaptive_aggregator` is on. Intermediate data the adaptive aggregator held and could not release kept a thread on the baseline algorithm flushing its own hash table on every block, so each block wrote a temporary file and the merge then allocated a reader per file. That data is now written out first. [#117326](https://github.com/ClickHouse/ClickHouse/pull/117326) ([Groene AI](https://github.com/groeneai)).
* Malformed `Native` blocks can no longer overflow the allocation of aggregate-function states during deserialization and cause out-of-bounds writes. [#117370](https://github.com/ClickHouse/ClickHouse/pull/117370) ([Raúl Marín](https://github.com/Algunenano)).
* Fixed the byte width of the `Iceberg` manifest `lower_bounds` and `upper_bounds` written for `int` and `date` columns: they were 8 bytes wide where the `Iceberg` specification requires 4. Spec-conformant readers such as `pyiceberg` failed with `unpack requires a buffer of 4 bytes` while planning any scan carrying a filter on such a column. [#117571](https://github.com/ClickHouse/ClickHouse/pull/117571) ([Groene AI](https://github.com/groeneai)).
* Remote-write async insert flush timeouts are now handled correctly: they return retryable `503 Service Unavailable` instead of `408 Request Timeout`, so Prometheus-compatible senders can retry them, and `wait_for_async_insert_timeout` is now clamped instead of overflowing for large magnitudes. [#117632](https://github.com/ClickHouse/ClickHouse/pull/117632) ([Vitaly Baranov](https://github.com/vitlibar)). [#118040](https://github.com/ClickHouse/ClickHouse/pull/118040) ([Groene AI](https://github.com/groeneai)).
* Fixed `base58Encode` and `base58Decode` of 32- and 64-byte values on big-endian builds such as `s390x`. The fixed-size codec byte-swapped every 4-byte word unconditionally, so on a big-endian host `base58Encode` returned a string that disagrees with the base58 specification and with every other architecture, and `base58Decode` rejected well-formed input when given a 32- or 64-byte size hint. Little-endian builds are bit-identical to before. Strings previously produced by a big-endian build will change, because they were wrong. [#117649](https://github.com/ClickHouse/ClickHouse/pull/117649) ([Groene AI](https://github.com/groeneai)).
* Fixed `format_schema_source = 'query'` running the schema query with full privileges when used from a background task, such as a streaming engine consumer (`Kafka`, `NATS`, `RabbitMQ`, `ObjectStorageQueue`) or a `Buffer` background flush. The schema query is now rejected there; use `format_schema_source = 'file'` or `format_schema_source = 'string'` instead, or pre-populate the schema cache. [#117737](https://github.com/ClickHouse/ClickHouse/pull/117737) ([Pavel Kruglov](https://github.com/Avogar)).
* Fix `absent` and `scalar` PromQL queries returning no result when `empty_result_for_aggregation_by_empty_set` is enabled. [#117816](https://github.com/ClickHouse/ClickHouse/pull/117816) ([Valery Petrov](https://github.com/valerypetrov)).
* A `bloom_filter` index over an `Array(Nullable(T))` column is now rejected at `CREATE` / `ALTER` time. It used to be accepted and then made every insert, merge, and mutation of the table fail, with `DROP INDEX` refused until the failed mutation was killed. [#117899](https://github.com/ClickHouse/ClickHouse/pull/117899) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fix the `GROUPING` function rejecting constant aliases that are valid `GROUP BY` keys. [#97504](https://github.com/ClickHouse/ClickHouse/pull/97504) ([Héctor Pablos](https://github.com/hctpbl)).
* Fixed SQL injection in the `PostgreSQL` wire protocol emulation. Prepared-statement parameters, in both the extended-query `Parse` / `Bind` / `Execute` path used by `psycopg2`, JDBC, `node-postgres`, Npgsql, and others, and the simple-query `EXECUTE` path, were substituted into the executed SQL by raw string splicing, so a crafted parameter could break out of its value position and inject SQL. Parameters are now bound as data. This also fixes string parameters that previously failed with `UNKNOWN_IDENTIFIER` when a client sent them unquoted. [#108469](https://github.com/ClickHouse/ClickHouse/pull/108469) ([Groene AI](https://github.com/groeneai)).
* Fix a `LOGICAL_ERROR` (`Part ... intersects previous part ... It is a bug or a result of manual intervention`) that makes a `MergeTree` table impossible to load: attaching it, and every later attempt to load it, fails with that exception, and debug and sanitizer builds abort. A merge could span a block gap holding an outdated part whose mutation version is higher than the merge result's, producing a pair of parts on disk that neither contain nor are disjoint from each other. Closes [#113864](https://github.com/ClickHouse/ClickHouse/issues/113864). [#113941](https://github.com/ClickHouse/ClickHouse/pull/113941) ([Groene AI](https://github.com/groeneai)).
* Fix a `LOGICAL_ERROR: Next task callback is not set for query with id` exception when `parallel_replicas_plan_based` is enabled and the query reads a system log table. [#114022](https://github.com/ClickHouse/ClickHouse/pull/114022) ([Groene AI](https://github.com/groeneai)).
* Fix `files_read` and `bytes_read` in `system.backups` and `system.backup_log` being permanently undercounted after a successful `RESTORE`, because a concurrent restore task holding an early snapshot could overwrite a larger count published by another task. [#114304](https://github.com/ClickHouse/ClickHouse/pull/114304) ([Groene AI](https://github.com/groeneai)).
* Fix wrong results when a non-boolean condition, such as a bare integer column in `WHERE`, is left alone after the other conditions are merged into the `JOIN` condition or pushed down. Rows whose condition value was a non-zero multiple of 256 were skipped. [#114533](https://github.com/ClickHouse/ClickHouse/pull/114533) ([Vladimir Cherkasov](https://github.com/vdimir)).
* Fixed a single `ALTER` with two `MODIFY COLUMN` subcommands on the same column silently corrupting that column's default: a default set by one subcommand was dropped, and a `REMOVE DEFAULT` / `MATERIALIZED` / `ALIAS` was undone, whenever a following subcommand restated the column type. [#114807](https://github.com/ClickHouse/ClickHouse/pull/114807) ([Groene AI](https://github.com/groeneai)).
* You can now access nested properties on a `Nullable(JSON)` value, for example `col::Nullable(JSON).Id`. Previously this failed with `First argument for function tupleElement cannot be Nullable(JSON)`, which made it impossible to combine a cast to `Nullable(JSON)` with property access on the result. Outer `NULL` rows now propagate through extracted paths using the existing subcolumn semantics: paths whose type can represent `NULL` return `NULL`, while types such as `Array` and `Map` return their default values. [#114863](https://github.com/ClickHouse/ClickHouse/pull/114863) ([Luís Lizardo](https://github.com/lizardoluis)).
* Fix an integer overflow in the deserialization of `String` values in the binary formats, and bound the recursion of the binary deserialization of `Dynamic` and `JSON` values. [#115702](https://github.com/ClickHouse/ClickHouse/pull/115702) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* `PostgreSQL` compatibility now handles `pg_catalog` qualifiers case-insensitively like PostgreSQL does, and the synthetic OIDs exposed through `pg_namespace` and `pg_class` are now unique, so `psql` commands such as `\d` no longer duplicate tables or list them under the wrong schema. [#115960](https://github.com/ClickHouse/ClickHouse/pull/115960) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed data loss in `MergeTree` when a merge runs while an `ALTER TABLE ... RENAME COLUMN` is still pending. The merge applied the rename but did not record it, so the mutation applied it a second time and read the renamed column as missing, filling it with defaults. Columns without a default expression, such as `Dynamic`, lost their values. [#115981](https://github.com/ClickHouse/ClickHouse/pull/115981) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed a query over an `Iceberg` table returning fewer rows than the table holds when a manifest declares a lower bound above the upper bound for a filtered column. Such a pair describes an empty range, so min/max pruning dropped the data file holding the matching rows; those bounds are now ignored instead. Closes [#116499](https://github.com/ClickHouse/ClickHouse/issues/116499). [#116604](https://github.com/ClickHouse/ClickHouse/pull/116604) ([Groene AI](https://github.com/groeneai)).
* Fixed two `Binary Viewer` (`/binary`) bugs: the image was not centered on load if the URL contained parameters such as `user`, and the connection parameters (`host`, `user`) were lost from the URL after moving the view. The `password` parameter is no longer kept in the address bar or browser history. [#117065](https://github.com/ClickHouse/ClickHouse/pull/117065) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fix a large performance regression, present since 26.5, for a query that filters on a column with an equality and orders by a later column of the same sorting key. Read-in-order analysis did not look through an `ALIAS` node on the filter column, so the filtered column was not recognized as constant and the read was not done in order, forcing a full sort of every matching row before the `LIMIT` applied. This reaches a table with a normal `PROJECTION`, whose rewrite wraps the query filter in such an alias, and a table-level `ALIAS` column used as a predicate. [#116854](https://github.com/ClickHouse/ClickHouse/issues/116854) separately made a base table that can serve the `ORDER BY` itself preferred; this fixes the case where only the projection can. [#116835](https://github.com/ClickHouse/ClickHouse/pull/116835) ([Groene AI](https://github.com/groeneai)).
* Fixed wrong results when reading the `.null` subcolumn of a column that went through a metadata-only `T` to `Nullable(T)` `ALTER` and then had a `RENAME COLUMN` still pending: `IS NULL`, `IS NOT NULL`, `count()`, and an explicit `x.null` read reported rows holding real data as `NULL`. [#116901](https://github.com/ClickHouse/ClickHouse/pull/116901) ([Groene AI](https://github.com/groeneai)).
* Fixed a stack overflow when reading hadoop-snappy data containing many blocks that decode to nothing. [#116994](https://github.com/ClickHouse/ClickHouse/pull/116994) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* The handshake response of the `MySQL` wire protocol is now bounded, so a client can no longer make the server grow memory during the handshake. The `mysql_require_secure_transport` server setting is now enforced from the actual state of the connection instead of a capability bit advertised by the client. [#117003](https://github.com/ClickHouse/ClickHouse/pull/117003) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fix background `Distributed` inserts that deleted unsent spool files after a split batch got a transient error. ClickHouse now keeps the files and retries the batch. [#117034](https://github.com/ClickHouse/ClickHouse/pull/117034) ([Rory Shanks](https://github.com/rorylshanks)).
* Fix wrong results for `GROUP BY` and `uniq*` over `MACNumToString`, `unhex`, `unbin`, and `UUIDStringToNum`. All four declared themselves injective, so the default-enabled `optimize_injective_functions_in_group_by` and `optimize_injective_functions_inside_uniq` grouped and counted by the raw argument: arguments that map to the same result came back as separate groups and were counted separately by `uniqExact`. [#117210](https://github.com/ClickHouse/ClickHouse/pull/117210) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fix wrong results from the default-enabled `optimize_uniq_to_count`. `uniq(x)` over a `SELECT DISTINCT x` or `GROUP BY x` subquery reported one distinct value too many when the column contained a `NULL`, and counted the extra super-aggregate rows of `WITH ROLLUP` / `WITH CUBE` as additional distinct values. [#117222](https://github.com/ClickHouse/ClickHouse/pull/117222) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fix `NO_SUCH_COLUMN_IN_TABLE` for every query using a text index while a mutation is pending with `apply_mutations_on_fly = 1`. Until the mutation materialized, `hasToken`, `hasAnyTokens`, and `hasAllTokens` on the indexed column could not be executed at all. [#117277](https://github.com/ClickHouse/ClickHouse/pull/117277) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Several aggregate function deserializers allocated memory from a size declared in the serialized state before reading the payload, so a state of a few bytes could request gigabytes. They now read only what the buffer already holds. [#117536](https://github.com/ClickHouse/ClickHouse/pull/117536) ([Groene AI](https://github.com/groeneai)).
* `getServerSetting`, `getMergeTreeSetting`, and `getMacro` returned the values of `system.server_settings`, `system.merge_tree_settings`, and `system.macros` to any user, bypassing the `SELECT` grant that reading those tables requires. They now require the same grant. [#117551](https://github.com/ClickHouse/ClickHouse/pull/117551) ([Raúl Marín](https://github.com/Algunenano)).
* Fixed a bug where the `analyzer_inline_views` setting could bypass the `SELECT` access check on a view, letting a user without a grant on the view read its contents. [#117555](https://github.com/ClickHouse/ClickHouse/pull/117555) ([Dmitry Novik](https://github.com/novikd)).
* `ENGINE = EmbeddedRocksDB(ttl, rocksdb_dir, read_only)` with an explicit `rocksdb_dir` now requires the `FILE` source grant that `file` requires for the same directory: `READ ON FILE` to create such a table, plus `WRITE ON FILE` when `read_only = 0`. Previously it required no source grant, so a user holding only `CREATE TABLE` in a database of their own could point a table at another table's directory and read its rows. `ON CLUSTER` and `Replicated`-database DDL are not covered: the replay runs with no user. The argument-less form is unaffected. Backward incompatible for anyone already using an explicit `rocksdb_dir` without them. [#117428](https://github.com/ClickHouse/ClickHouse/pull/117428) ([Groene AI](https://github.com/groeneai)). [#117665](https://github.com/ClickHouse/ClickHouse/pull/117665) ([Pedro Ferreira](https://github.com/PedroTadim)).
* Fix `ALTER` and `CREATE TABLE ... AS` dropping the other settings of a `TimeSeries` table. [#117693](https://github.com/ClickHouse/ClickHouse/pull/117693) ([Vitaly Baranov](https://github.com/vitlibar)). [#117839](https://github.com/ClickHouse/ClickHouse/pull/117839) ([Vitaly Baranov](https://github.com/vitlibar)). [#118119](https://github.com/ClickHouse/ClickHouse/pull/118119) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fix incorrect results for suffix `LIKE` patterns with escape sequences when `optimize_rewrite_like_perfect_affix` is enabled. Such patterns are now rewritten to `endsWith` only when the suffix is an exact literal. [#117712](https://github.com/ClickHouse/ClickHouse/pull/117712) ([Alex Prabhat Bara](https://github.com/alexprabhat99)).
* Fix a dictionary with a `Redis` source and an `Int256` key column silently returning the default value from `dictGet` for keys that exist in `Redis`. Wide integer key columns are now refused with a clear error instead of being admitted and never matching. [#117735](https://github.com/ClickHouse/ClickHouse/pull/117735) ([Pratham Nayak](https://github.com/protomn)).
* Fixed excessive memory usage when reading from `File`, `URL`, object storage, `GenerateRandom`, or any other storage that uses the generic read path with `max_streams_to_max_threads_ratio` above 1. The number of output ports created after a read is now bounded by `max_threads`, so a `SELECT` over a tiny table no longer allocates tens of gigabytes while the pipeline is still being built. [#117772](https://github.com/ClickHouse/ClickHouse/pull/117772) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fix `ARRAY JOIN` producing rows in incorrect order in some cases. [#117918](https://github.com/ClickHouse/ClickHouse/pull/117918) ([Yarik Briukhovetskyi](https://github.com/yariks5s)).
* Fix a potential out-of-bounds write in `formatDateTimeInJodaSyntax` when called with a time zone name longer than 32 characters. [#117925](https://github.com/ClickHouse/ClickHouse/pull/117925) ([Robert Schulze](https://github.com/rschu1ze)).
* Fix `EXPLAIN QUERY TREE` and `EXPLAIN SYNTAX` exposing column names and types of tables the user has no privileges for: the analyzer now checks that the user may see at least one column of the table at the moment a table identifier is resolved. The check also makes the error kind independent of whether the queried column exists and stops recording column names the user may not see into `missing_privileges` of the query log. Closes [#78938](https://github.com/ClickHouse/ClickHouse/issues/78938). [#117979](https://github.com/ClickHouse/ClickHouse/pull/117979) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed Keeper aborting when memory usage stays near the limit: moving finished changelogs and snapshots to object storage was refused, so the local log disk filled up. [#117983](https://github.com/ClickHouse/ClickHouse/pull/117983) ([Shaohua Wang](https://github.com/tiandiwonder)).
* Fixed a `Kafka` / `RabbitMQ` / `NATS` / `FileLog` / `S3Queue` / `AzureQueue` table in a database with `lazy_load_tables` silently stopping to feed its materialized views after a server restart. [#118009](https://github.com/ClickHouse/ClickHouse/pull/118009) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed cancellation of a synchronous distributed `INSERT` (`distributed_foreground_insert`) waiting for that `INSERT` to finish instead of interrupting it. `KILL QUERY` against such an insert, a client disconnect, and server shutdown could block for as long as a shard was slow. [#118013](https://github.com/ClickHouse/ClickHouse/pull/118013) ([Groene AI](https://github.com/groeneai)).
* Fixed a `LIMIT` being pushed into `numbers()` when the query's `WHERE` referenced an `arrayJoin` through a `WITH` alias, which could make the source stop before the expansion produced enough rows. [#118045](https://github.com/ClickHouse/ClickHouse/pull/118045) ([Yarik Briukhovetskyi](https://github.com/yariks5s)).
* Fix `Iceberg` schema evolution for additional nested `Array`, `Map`, and `Struct` combinations whose inner fields are added, removed, or reordered. [#118127](https://github.com/ClickHouse/ClickHouse/pull/118127) ([Konstantin Vedernikov](https://github.com/scanhex12)).
* Fixed incremental backups to Azure Blob Storage storing the beginning of each file instead of its tail. Restoring such a backup silently dropped all the data written after the base backup. [#114975](https://github.com/ClickHouse/ClickHouse/pull/114975) ([Smita Kulkarni](https://github.com/SmitaRKulkarni)).
* Fixed potential data loss when an `INSERT` into `ReplicatedMergeTree` was cancelled or timed out while ClickHouse was recovering an uncertain Keeper commit. [#111196](https://github.com/ClickHouse/ClickHouse/pull/111196) ([kakao-tars-case](https://github.com/kakao-tars-case)).
* Fixed object storage listing silently skipping objects when S3 returns an empty page together with a continuation token. This could make a `plain_rewritable` disk appear empty and hide table parts, and could make data lake tables read a stale snapshot. [#118615](https://github.com/ClickHouse/ClickHouse/pull/118615) ([Sema Checherinda](https://github.com/CheSema)).
* Fixed a SQL injection in the PostgreSQL metadata queries. The `schema` of the `PostgreSQL` database engine, the requested column names and the publication name were formatted into SQL literals without escaping, so a value containing a quote could execute arbitrary SQL on the connected PostgreSQL server as the role ClickHouse connects with. Reaching it through `schema` needed only `CREATE DATABASE` plus use of a named collection whose `schema` is overridable. [#111516](https://github.com/ClickHouse/ClickHouse/pull/111516) ([Shaohua Wang](https://github.com/tiandiwonder)).
* Hide the credentials that a setting value can carry, such as the password in `format_avro_schema_registry_url` or `url_base`, everywhere a setting value is displayed or logged. `system.query_log`, `system.processes`, `system.settings`, `system.settings_profile_elements`, `system.session_log`, `system.distributed_ddl_queue`, `SHOW CREATE USER` and `SHOW CREATE SETTINGS PROFILE` previously showed them in plaintext to any user who could read them. [#117523](https://github.com/ClickHouse/ClickHouse/pull/117523) ([Raúl Marín](https://github.com/Algunenano)). `EXPLAIN` now respects `format_display_secrets_in_show_and_select` as well. [#118129](https://github.com/ClickHouse/ClickHouse/pull/118129) ([Kirill Kopnev](https://github.com/Fgrtue)).
* `CREATE USER OR REPLACE` and the `OR REPLACE` form of `CREATE ROLE`, `CREATE QUOTA`, `CREATE SETTINGS PROFILE` and `CREATE ROW POLICY` now require the corresponding `DROP` privilege in addition to `CREATE`, because they overwrite an existing entity. Previously `CREATE USER` alone was enough to reset the password of any other user, including a privileged one. [#117960](https://github.com/ClickHouse/ClickHouse/pull/117960) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fix `CREATE OR REPLACE TABLE`/`VIEW`/`DICTIONARY` and `REPLACE TABLE` requiring privileges on the internal temporary table they create (`_tmp_replace_*`). Its name is random, so no grant could cover it and the query failed with `ACCESS_DENIED` unless the user held wildcard grants on the whole database. The required privileges are now checked against the user-visible names only: replacing an object needs the `CREATE` and `DROP` grants of its own kind, plus `INSERT` on it when the statement populates it. [#117967](https://github.com/ClickHouse/ClickHouse/pull/117967) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* `TRUNCATE DATABASE ... ON CLUSTER` and `TRUNCATE [ALL] TABLES FROM ... ON CLUSTER` ran without checking any privilege: a user holding only `SELECT` and `CLUSTER` could destroy every table in a database, and `readonly = 1` did not prevent it. Both now require `DROP DATABASE`, the privilege the non-cluster spellings have always required. [#118155](https://github.com/ClickHouse/ClickHouse/pull/118155) ([Groene AI](https://github.com/groeneai)).
* Fixed a privilege escalation in implicit access-rights computation: holding any single child privilege of the `ALTER TABLE` group (for example `ALTER MODIFY COMMENT`) on a view implicitly conferred the entire `ALTER VIEW` group, so such a user could run `ALTER TABLE MODIFY QUERY` and rewrite the view's query. `ALTER VIEW` is now implied only by the complete `ALTER TABLE` grant. A deployment that relied on a partial `ALTER TABLE` grant to alter views must now grant `ALTER VIEW` (or one of its members) or the full `ALTER TABLE` explicitly. [#118194](https://github.com/ClickHouse/ClickHouse/pull/118194) ([Groene AI](https://github.com/groeneai)).
* Expressions supplied through the `additional_table_filters` and `parallel_replicas_custom_key` settings are now subject to the column-level `SELECT` check, and are no longer injected into the body of `SQL SECURITY DEFINER` or `NONE` views. Previously a user could evaluate predicates over columns they were not granted. [#118063](https://github.com/ClickHouse/ClickHouse/pull/118063) ([Dmitry Novik](https://github.com/novikd)).
* Forbid `CREATE TABLE ... AS viewIfPermitted(...)`, including `viewIfPermitted` nested in another table function such as `remote`, which now fails with `BAD_ARGUMENTS`, as it already does for `eval` and the `*Cluster` table functions. The function chooses between its `SELECT` query and the `ELSE` function according to the current user, but a persisted table is resolved with no user and therefore full access: reading one reported the source table's column names and types to a user with no grant on it, and the `ELSE` fallback was unreachable. Tables created before this change keep loading; drop them to close the disclosure. [#116885](https://github.com/ClickHouse/ClickHouse/pull/116885) ([Groene AI](https://github.com/groeneai)).
* Fixed a `Filesystem` database serving a table from its internal cache without the `READ ON FILE` grant. The grant was checked only while a table name was resolved for the first time, so once any user holding it had read a name, every user with `SELECT` on the database was served the contents of the file. `EXISTS TABLE`, which requires only `SHOW TABLES`, answered from that cache and probed the directory without the grant too. Both now require it, and a user without it is refused before the existence of the file is observed. [#119029](https://github.com/ClickHouse/ClickHouse/pull/119029) ([Groene AI](https://github.com/groeneai)).
* Apply `remote_url_allow_hosts` before SQL-supplied S3 and Azure endpoints send schema, metadata, or container requests. [#114357](https://github.com/ClickHouse/ClickHouse/pull/114357) ([Rory Shanks](https://github.com/rorylshanks)).
* Fixed the server deserializing the payload of a `Data` packet that arrives on a connection before any query. In interserver mode the connection is not authenticated until the `Query` packet is processed, so such a packet was rejected only after its Native block had been read, which let an unauthenticated peer choose the column type the server constructed. The packet is now rejected before its payload is touched. [#118588](https://github.com/ClickHouse/ClickHouse/pull/118588) ([Groene AI](https://github.com/groeneai)).
* Each code for a time-based one-time password is now accepted at most once, as required by RFC 6238: reusing an already used code, or a code for an earlier time step, is rejected. A user with `time_based_one_time_password` can successfully authenticate at most once per `period`. [#117563](https://github.com/ClickHouse/ClickHouse/pull/117563) ([Vladimir Cherkasov](https://github.com/vdimir)).
* Fixed wrong results when `join_algorithm = 'parallel_hash'` is combined with a sorted consumer such as `optimize_aggregation_in_order`, `optimize_distinct_in_order` or `LIMIT BY`. With several join slots and a single-level hash map the join does not keep the order of the left table, so the read-in-order-through-join optimization must not advertise the left sort order in that case. [#109225](https://github.com/ClickHouse/ClickHouse/pull/109225) ([Groene AI](https://github.com/groeneai)).
* Fixed a `LOGICAL_ERROR` (`Join is supported only for pipelines with one output port`) raised by a merge `JOIN` when its two sides reached the join with a different number of output ports. [#109393](https://github.com/ClickHouse/ClickHouse/pull/109393) ([Groene AI](https://github.com/groeneai)).
* Fix wrong results when a doubly negated expression is compared with a constant, such as `WHERE (NOT NOT c) > -0.5`. Index analysis cancelled the two `NOT`s and compared the column itself with the constant, pruning parts, granules and partitions that do match. [#116381](https://github.com/ClickHouse/ClickHouse/pull/116381) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed wrong results after `ALTER TABLE ... MODIFY ORDER BY` on a table with a descending sorting key column (`ORDER BY a DESC`). The `ALTER` silently dropped the `DESC` direction while existing parts stayed physically sorted the old way, so primary key index analysis pruned the wrong granules and queries returned missing rows. Such an `ALTER` is now rejected. [#116473](https://github.com/ClickHouse/ClickHouse/pull/116473) ([Groene AI](https://github.com/groeneai)).
* Fix the `Invalid status NotActive for associated output` logical error that could happen for queries with a high `max_threads`, for example a `GROUPING SETS` aggregation over a remote table. [#116478](https://github.com/ClickHouse/ClickHouse/pull/116478) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed reading uninitialized memory as literal data when decompressing a malformed `LZ4`-compressed block. [#116992](https://github.com/ClickHouse/ClickHouse/pull/116992) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fix silently missing rows for a predicate on `toMillisecond`, `toMicrosecond` or `toNanosecond` of a `DateTime64` primary key. All three claimed to be monotonic everywhere, although they restart at zero every second, so primary-key analysis treated the predicate as one contiguous key range and pruned granules that contain matching rows. [#117246](https://github.com/ClickHouse/ClickHouse/pull/117246) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fix wrong row counts from the default-enabled `query_plan_merge_filter_into_join_condition` when an equality conjunct of the `WHERE` filter contains a non-deterministic function such as `rand()`. The conjunct was moved into the join condition, where it is evaluated once per join input row instead of once per output row, and cloned into the build-side runtime filter as a second evaluation site. [#117247](https://github.com/ClickHouse/ClickHouse/pull/117247) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fix the default-enabled `query_plan_merge_expression_into_join` returning rows that violate the query's own `JOIN ON` condition when a subquery computes a non-deterministic expression that is then used as a join key. The merged expression was computed twice from the raw inputs, drawing independently for the match and for the output column. [#117250](https://github.com/ClickHouse/ClickHouse/pull/117250) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fix the default-enabled `use_join_disjunctions_push_down` silently dropping rows when the filter above a join hides a non-deterministic function inside a lambda body, as in `arrayExists(z -> rand(z) % 2 = 0, [a])`. The extracted pre-filter was pushed below the join while the original filter stayed on top, so the lambda was drawn twice per row and only rows passing both draws survived. [#112700](https://github.com/ClickHouse/ClickHouse/pull/112700) ([Groene AI](https://github.com/groeneai)).
* Fixed a filter containing a non-deterministic function being moved below `ARRAY JOIN`, which evaluated it once per source row instead of once per expanded row and made whole arrays pass or fail together. [#117756](https://github.com/ClickHouse/ClickHouse/pull/117756) ([Alexey Milovidov](https://github.com/alexey-milovidov)). Fixed `rand`, `generateUUIDv4` and other non-deterministic functions being evaluated before an `arrayJoin` replicates the rows, which silently duplicated their values across the expanded rows. [#118963](https://github.com/ClickHouse/ClickHouse/pull/118963) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Reject a `CHECK` constraint whose expression contains `arrayJoin`. Such a constraint was accepted and then read past the end of the inserted block, surfacing as a nonsensical `Array of size 18446744073709551613 is too large`, or an abort in a debug build, or blamed a violation on the wrong row. [#117267](https://github.com/ClickHouse/ClickHouse/pull/117267) ([Alexey Milovidov](https://github.com/alexey-milovidov)). `arrayJoin` in a table constraint is now also rejected when the definition is copied by `CREATE TABLE ... AS src` or `CLONE AS src`, stated by a full-definition `ATTACH`, or declared as `ASSUME`. A constraint containing it that is already stored in the metadata of a table is no longer used by the query-time constraint optimizer, which could remove a `WHERE` that the constraint did not really imply. [#117799](https://github.com/ClickHouse/ClickHouse/pull/117799) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Reject a TTL expression that contains `arrayJoin`. Such a TTL was accepted and then silently deleted rows whose own TTL was far in the future, and read past the end of the expression column when an array was empty. [#117266](https://github.com/ClickHouse/ClickHouse/pull/117266) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fix a silent result change for a query over a trivial view over a `Distributed` table whose `WHERE` or view-keyed `additional_table_filters` contains a bare `IN some_table` predicate. The default-enabled `optimize_trivial_view_pushdown_to_distributed` shipped that predicate to the shards, where it was evaluated against each shard's local table of that name instead of the initiator's, so it disagreed with the `IN (SELECT ...)` spelling of the same predicate. [#117278](https://github.com/ClickHouse/ClickHouse/pull/117278) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed `query_plan_aggregation_bucket_top_k` silently dropping result rows when an `arrayJoin` sits between the aggregation and the `ORDER BY ... LIMIT`. [#117464](https://github.com/ClickHouse/ClickHouse/pull/117464) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed `SELECT ... FINAL` with a `WHERE` on the partition key expression returning a superseded row when the partition key is computed from a floating-point sorting-key column: partition pruning dropped the partition holding the deduplication winner. [#117509](https://github.com/ClickHouse/ClickHouse/pull/117509) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed `mutations_sync = 3`, `lightweight_deletes_sync = 3` and `alter_sync = 3` performing no wait at all on `ReplicatedMergeTree`, so a mutation or `ALTER` returned as if it had synchronised. As documented, the value now behaves the same as `2` and waits for all replicas. This also affects `OPTIMIZE`, `TRUNCATE`, `DROP`/`DETACH PARTITION`, `REPLACE PARTITION` and `MOVE PARTITION TO TABLE`, which take the same `alter_sync` wait path. Statements that previously returned immediately now wait, and can raise `UNFINISHED` when a replica is inactive; set the value to `0`, `1` or `2` to choose a different wait explicitly. [#117517](https://github.com/ClickHouse/ClickHouse/pull/117517) ([Groene AI](https://github.com/groeneai)).
* Fixed the logical error `Cannot add ZooKeeper operation because query is executed` when running `TRUNCATE TABLE` on a `TimeSeries` table in a `Replicated` database. [#117902](https://github.com/ClickHouse/ClickHouse/pull/117902) ([Raúl Marín](https://github.com/Algunenano)).
* Fix a lightweight `UPDATE` silently not applied to rows of a data part when the patch part is written in the `v1` format (`patch_parts_version = 'v1'`) and covers rows of several data parts. One row was lost when a data part's patch rows began in a later granule of the patch part, which made the result depend on `merge_tree_min_read_task_size` and `max_block_size`. All updates for a data part were lost, on disk as well as at read time, when the patch part had no final mark (`index_granularity_bytes = 0`) and that part's patch rows began in the patch part's last granule. [#117962](https://github.com/ClickHouse/ClickHouse/pull/117962) ([Groene AI](https://github.com/groeneai)).
* Fix wrong results and a `NOT_IMPLEMENTED` exception when a lightweight update's patch part is applied on top of a pending `ALTER TABLE ... UPDATE col = ` with `apply_mutations_on_fly = 1`. The constant-folded column was not materialized before the patch was written into it, so the patch was either silently discarded or the read failed. [#118545](https://github.com/ClickHouse/ClickHouse/pull/118545) ([Shaohua Wang](https://github.com/tiandiwonder)).
* Fixed `system.tables.total_rows`/`total_bytes` overcounting a non-replicated `MergeTree` table while a patch part from a lightweight `UPDATE` is alive, and `SELECT count()` returning that inflated number with `apply_patch_parts = 0`. [#117463](https://github.com/ClickHouse/ClickHouse/pull/117463) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed a query with a `hasToken`-family predicate on a `text` index silently returning no rows when the query also read a column modified by a pending lightweight update. [#118496](https://github.com/ClickHouse/ClickHouse/pull/118496) ([Shaohua Wang](https://github.com/tiandiwonder)).
* Fix excessive patch-part reads for lightweight updates on tables with redundant parentheses in sorting-key expressions, such as `ORDER BY (k)`. [#118878](https://github.com/ClickHouse/ClickHouse/pull/118878) ([Anton Popov](https://github.com/CurtizJ)).
* Fixed the `LOGICAL_ERROR` `Reading from materialized CTE '...' before its materialization completed` raised by a lightweight `UPDATE`, or a lightweight `DELETE` in `lightweight_update_force` mode, whose predicate contains an `IN` subquery that defines a materialized CTE, when the set is built at run time. [#119489](https://github.com/ClickHouse/ClickHouse/pull/119489) ([Dmitry Novik](https://github.com/novikd)).
* Fixed a retried `INSERT SELECT` over a join not being deduplicated when the two attempts differed only in whether a column was carried as a lazily replicated column. [#118004](https://github.com/ClickHouse/ClickHouse/pull/118004) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed a logical error `Cannot write to finalized buffer` (an abort in debug and sanitizer builds) in the non-replicated `MergeTree` deduplication log when opening the next log file during rotation failed, for example after a transient I/O error on the deduplication log's disk. Such a failure no longer fails the insert that triggered the rotation, so a retry of that insert is not wrongly deduplicated. [#118089](https://github.com/ClickHouse/ClickHouse/pull/118089) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fix silent data loss on upgrade in `Distributed` background inserts with `background_insert_split_batch_on_failure`: batch recovery no longer deletes a spool file that was never sent when a later file of the same batch was quarantined into `broken/` by a previous server version. [#118211](https://github.com/ClickHouse/ClickHouse/pull/118211) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed `SELECT count()` returning too many rows for a negated comparison (`!=`, `NOT IN`, `NOT LIKE`) over a `Nullable` primary key column: the exact-count optimization counted the NULL-key rows that the `WHERE` condition rejects. [#118214](https://github.com/ClickHouse/ClickHouse/pull/118214) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed `AMBIGUOUS_COLUMN_NAME` on every read of a table that has a column named like a subcolumn of another column (for example `a.size0` next to an `Array` column `a`) after `ALTER TABLE ... MODIFY COLUMN` changed that column's type. [#118228](https://github.com/ClickHouse/ClickHouse/pull/118228) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fix unbounded memory growth from time zone names of the form `Fixed/UTC±HH:MM:SS`. Every distinct name permanently cost ~4.6 MiB that the server never gave back, and 172801 of them were accepted. Only offsets that a time zone can have are accepted now: a whole number of quarters of an hour, no further from UTC than 14 hours. [#118286](https://github.com/ClickHouse/ClickHouse/pull/118286) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed `MULTIPLE_EXPRESSIONS_FOR_ALIAS` under `rewrite_in_to_join` for a query that repeats one identical aliased `IN (subquery)` expression more than once. [#118292](https://github.com/ClickHouse/ClickHouse/pull/118292) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* A table created with `CREATE TABLE ... AS
(...)` is no longer resolved to answer a `system.columns` size query about it. Previously selecting `data_compressed_bytes`, `data_uncompressed_bytes` or `marks_bytes` contacted the endpoint of every such table, so one unreachable endpoint made the whole scan fail. Until such a table is first accessed it now reports zero sizes. [#118302](https://github.com/ClickHouse/ClickHouse/pull/118302) ([Groene AI](https://github.com/groeneai)).
* Fixed an `Inconsistent AST formatting` logical error for an aliased `IN` expression whose left operand also has an alias when it is nested inside a function-argument list, e.g. `SELECT ifNull(sum((x AS a1) IN [y] AS c3 = TRUE), 0)`. [#110229](https://github.com/ClickHouse/ClickHouse/pull/110229) ([Groene AI](https://github.com/groeneai)).
* Fix a logical error (server abort in debug/sanitizer builds) when a constant-folded comparison appears in the `SELECT` list together with `group_by_use_nulls = 1` and `GROUP BY GROUPING SETS`. [#110703](https://github.com/ClickHouse/ClickHouse/pull/110703) ([Groene AI](https://github.com/groeneai)). Fixed a `Bad cast` error, and wrong results in release builds, when an aggregate reads a derived table that uses `GROUP BY ALL` with `ROLLUP` or `CUBE` under `group_by_use_nulls = 1`. [#110921](https://github.com/ClickHouse/ClickHouse/pull/110921) ([Groene AI](https://github.com/groeneai)). Fixed a return type mismatch error when `group_by_use_nulls` is used with `GLOBAL IN` in a `GROUP BY` key. [#116980](https://github.com/ClickHouse/ClickHouse/pull/116980) ([George Larionov](https://github.com/george-larionov)).
* Fixed a `LOGICAL_ERROR` ("query tree node does not have valid source node") when a `Merge` table wrapping a `Distributed` table is joined and a bare column of the joined-away side is used as a predicate. [#111327](https://github.com/ClickHouse/ClickHouse/pull/111327) ([Groene AI](https://github.com/groeneai)).
* Fixes a `LOGICAL_ERROR` (`Column identifier ... is already registered`), a `MULTIPLE_EXPRESSIONS_FOR_ALIAS` error and a `NOT_FOUND_COLUMN_IN_BLOCK` error for a query whose `IN` / `NOT IN` / `GLOBAL IN` right operand names a table expression that also appears in the `FROM` section, for example `SELECT l.x FROM l JOIN (SELECT x FROM r) AS r ON l.x = r.x WHERE l.x IN r`. Also makes `ORDER BY WITH FILL ... INTERPOLATE ( ...)` inside a CTE or any other copied subquery raise `INVALID_WITH_FILL_EXPRESSION`, as the same query already does when it is not copied: the check was silently skipped for the copy, and such a query returned rows instead of the error. [#112219](https://github.com/ClickHouse/ClickHouse/pull/112219) ([Groene AI](https://github.com/groeneai)).
* Fixes `NOT_FOUND_COLUMN_IN_BLOCK` when `query_plan_join_shard_by_pk_ranges = 1` is combined with `join_algorithm = 'full_sorting_merge'` and a join input is filtered on a sorting-key column that is not the join key and is not selected. Closes [#112402](https://github.com/ClickHouse/ClickHouse/issues/112402). [#112664](https://github.com/ClickHouse/ClickHouse/pull/112664) ([Groene AI](https://github.com/groeneai)). Fixed rows being silently dropped from a join when `query_plan_join_shard_by_pk_ranges` is enabled and the primary key is a floating-point column containing `NaN`. [#118918](https://github.com/ClickHouse/ClickHouse/pull/118918) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed `Code: 476` (`Can not use WITH TIES without ORDER BY`) raised by a remote shard, and the logical error `LIMIT WITH TIES without ORDER BY` raised on the initiator, when selecting from a `Merge` table over a `Distributed` table with a `JOIN` and `ORDER BY ... LIMIT n WITH TIES`. The child query kept its `LIMIT` clause after its `ORDER BY` was removed. [#113594](https://github.com/ClickHouse/ClickHouse/pull/113594) ([Groene AI](https://github.com/groeneai)).
* Fixed `LOGICAL_ERROR: There are no events in epoll` when a distributed query with `use_hedged_requests` is cancelled or completes early (for example because of a `LIMIT`) while a replacement replica is still pending. Closes [#113981](https://github.com/ClickHouse/ClickHouse/issues/113981). [#114065](https://github.com/ClickHouse/ClickHouse/pull/114065) ([Groene AI](https://github.com/groeneai)).
* Fixed `... PARTITION ` statements against a table whose `PARTITION BY` contains `modulo` with an unsigned left operand and a signed right operand, such as `PARTITION BY (37528 % c0)` with `c0 Int32`. Such a statement raised `LOGICAL_ERROR`, or silently affected no partition. A value outside the range of the partition key type is now rejected with `ARGUMENT_OUT_OF_BOUND` instead of silently matching nothing. [#116606](https://github.com/ClickHouse/ClickHouse/pull/116606) ([Groene AI](https://github.com/groeneai)).
* Fix `BAD_ARGUMENTS` for a query that combines several `quantile` calls where at least one level is written as an integer literal, for example `SELECT quantile(1)(x), quantile(0.5)(x)`. The default-enabled `optimize_syntax_fuse_functions` rejected the integer level while the aggregate function itself accepts it, so the query failed although each call is valid on its own. [#117211](https://github.com/ClickHouse/ClickHouse/pull/117211) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed wrong results for `GROUP BY`, `LIMIT BY` and `uniq*` over `bech32Encode`, `dictGetHierarchy` and `reverseUTF8`: the three functions declared themselves injective, so the default-enabled `optimize_injective_functions_in_group_by` and `optimize_injective_functions_inside_uniq` grouped and counted by the raw argument, although distinct inputs can produce the same result. [#117239](https://github.com/ClickHouse/ClickHouse/pull/117239) ([Alexey Milovidov](https://github.com/alexey-milovidov)). [#117357](https://github.com/ClickHouse/ClickHouse/pull/117357) ([Alexey Milovidov](https://github.com/alexey-milovidov)). [#118432](https://github.com/ClickHouse/ClickHouse/pull/118432) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fix `has`, `indexOf` and `countEqual` over an array of numbers returning a match for a needle that `equals` does not consider equal: `has(arr, -1)` matched an `Array(UInt64)` element equal to the `UInt64` maximum, and `has(arr, 16777217)` matched an `Array(Float32)` element equal to `16777216`. The constant-array path already answered correctly, so the same haystack gave different results depending on whether it was a constant or a materialized column. The same phantom matches were returned for an `Array(LowCardinality(T))` column, which also matched a needle its element type cannot represent outside the numeric domain and reported every element equal to the default value as a match for a `NULL` needle. In the other direction, a needle counting a different unit than the element, such as a `DateTime` searched in an `Array(Date)`, was found nowhere although `equals` considers the pair equal; such a pair is now compared in the type the two meet in. [#117313](https://github.com/ClickHouse/ClickHouse/pull/117313) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed `uniqTheta` and its variants silently returning a value that is too low when reading an `AggregateFunction(uniqTheta, ...)` state that another Apache DataSketches implementation had written in the compressed Theta sketch form. [#117422](https://github.com/ClickHouse/ClickHouse/pull/117422) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed undefined behavior and an empty result of a `SELECT ... ORDER BY LIMIT n OFFSET m` over a table with a `vector_similarity` index when `n + m`, or `LIMIT` multiplied by `vector_search_index_fetch_multiplier`, overflows `UInt64`; such a query now skips the index and runs the exact search. [#117713](https://github.com/ClickHouse/ClickHouse/pull/117713) ([Alexey Milovidov](https://github.com/alexey-milovidov)). [#117892](https://github.com/ClickHouse/ClickHouse/pull/117892) ([Groene AI](https://github.com/groeneai)).
* Fixed a `LOGICAL_ERROR` (`Invalid number of columns in chunk pushed to OutputPort`) for a vector search over a column with a `Quantized(...)` codec when `vector_search_use_quantized_codes` and the experimental `make_distributed_plan` were both enabled. [#118850](https://github.com/ClickHouse/ClickHouse/pull/118850) ([Groene AI](https://github.com/groeneai)).
* Fixed an external `GROUP BY` with `enable_adaptive_aggregator` exceeding `max_memory_usage` or failing with `MEMORY_LIMIT_EXCEEDED` inside the aggregator's own memory valve: the working set of the memory-pressure sweeps was sized from constants unrelated to `max_bytes_before_external_group_by`, and records staged before the aggregator thawed its tables stayed resident until the merge, so a thawed thread wrote a temporary file per block. Both are now bounded by that threshold. [#117880](https://github.com/ClickHouse/ClickHouse/pull/117880) ([Alexey Milovidov](https://github.com/alexey-milovidov)). [#118474](https://github.com/ClickHouse/ClickHouse/pull/118474) ([Groene AI](https://github.com/groeneai)).
* Fixed a comment `ALTER` on a `KeeperMap` table in a `Replicated` database being applied only to the local replica. Keeper kept the pre-`ALTER` `CREATE` statement and digest, so other replicas never saw the change and the next start declared the replica lost, reverting the `ALTER` and, if no other table shared its `KeeperMap` path, dropping its data. [#118011](https://github.com/ClickHouse/ClickHouse/pull/118011) ([Groene AI](https://github.com/groeneai)).
* Fixes `bloom_filter` skip indexes on big-endian platforms (s390x), where the index payload was never written or read, so a query using such an index returned no rows for data that is present. [#118164](https://github.com/ClickHouse/ClickHouse/pull/118164) ([Vadim Ilves](https://github.com/vadimilves)).
* Fixed `arrayIntersect` returning a spurious `NULL` when it is missing from one of the input arrays. [#118312](https://github.com/ClickHouse/ClickHouse/pull/118312) ([Minh Vu](https://github.com/fallintoplace)). Fixed `arrayIntersect`, `arrayUnion` and `arraySymmetricDifference` mishandling a `Nullable` argument whose elements do not fit the common element type: `arrayIntersect([toNullable(1)], [toNullable(257)])` returned `[1]`, and `arrayUnion([1], [toNullable(257)])` failed with `ILLEGAL_COLUMN` instead of returning `[1,257]`. [#118485](https://github.com/ClickHouse/ClickHouse/pull/118485) ([Groene AI](https://github.com/groeneai)).
* Fixed a `UInt64` constant that does not fit `UInt32` matching an unrelated row of a `DateTime` column in `IN` (and in an `OR` chain of equalities, which is rewritten into `IN`): the constant was truncated modulo 2^32 instead of being excluded from the set. [#118367](https://github.com/ClickHouse/ClickHouse/pull/118367) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed `CORRUPTED_DATA` ("Cannot get value from Set") for a `FINAL` query with `ORDER BY ... WITH FILL INTERPOLATE` whose filter is an `IN` set moved into `PREWHERE`: the set placeholder column is no longer kept alive past the filter. [#118420](https://github.com/ClickHouse/ClickHouse/pull/118420) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed `lcm` returning a negative result for `Int128` and `Int256` arguments when exactly one of them is negative, e.g. `lcm(toInt128(-6), toInt128(4))` returned `-12` instead of `12`. [#118431](https://github.com/ClickHouse/ClickHouse/pull/118431) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed `text`, `tokenbf_v1` and `ngrambf_v1` skip indexes not being used when the searched constant has type `LowCardinality(String)` (e.g. `hasToken(s, toLowCardinality('rare'))` or `s = toLowCardinality('rare')`), which caused a silent full scan. Such predicates now prune granules like their plain `String` counterparts. [#110017](https://github.com/ClickHouse/ClickHouse/pull/110017) ([Groene AI](https://github.com/groeneai)).
* Fix a `text` or `ngrambf_v1` index silently dropping matching rows when the indexed column is compared for equality against a `FixedString` value, or searched with `hasAny` or `hasAll` over `FixedString` needles. Happens at default settings, since `use_skip_indexes` and `enable_full_text_index` are both on. [#117314](https://github.com/ClickHouse/ClickHouse/pull/117314) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fix rows silently dropped by an `ngrambf_v1` index for a `LIKE` pattern with a run of escaped backslashes before a wildcard. [#118673](https://github.com/ClickHouse/ClickHouse/pull/118673) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed a `bloom_filter` skip index dropping granules that hold matching rows for `hasAny`/`hasAll` against a constant array whose elements are of a different date/time type than the indexed column, and `TYPE_MISMATCH` for a `Date32` element. [#118956](https://github.com/ClickHouse/ClickHouse/pull/118956) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed wrong results when a table declares both a `Map` column `m` and a column named exactly `` `m.key_` `` (dots are legal in column names), or has that name claimed by a subcolumn such as a `Tuple` element or a typed JSON path. Skip-index analysis read the name as the map's key subcolumn and pruned every granule whose map lacks ``, so a `mapKeys` or `mapValues` index (`ngrambf_v1`, `tokenbf_v1`, `sparse_grams`, `bloom_filter`, `text`) dropped rows that matched the predicate. [#119457](https://github.com/ClickHouse/ClickHouse/pull/119457) ([Groene AI](https://github.com/groeneai)).
* Fixes incorrect primary-key pruning for `has` and `notHas` when array element types differ from the key type, such as `String` literals against `Enum` or `FixedString` keys. [#115294](https://github.com/ClickHouse/ClickHouse/pull/115294) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed rows being silently dropped by partition pruning, primary key analysis and `minmax` skip indexes when a `NaN` is involved: a comparison constant that holds a `NaN`, possibly nested in a tuple or appearing only after conversion to the key type, as in `NOT (f < 'nan')`. [#116763](https://github.com/ClickHouse/ClickHouse/pull/116763) ([Groene AI](https://github.com/groeneai)). A string constant such as `'nan'` compared with a floating point column under an injective key transform such as `ORDER BY toString(f)`, so `f != 'nan'` skipped the granule holding the `NaN` row. [#117501](https://github.com/ClickHouse/ClickHouse/pull/117501) ([Groene AI](https://github.com/groeneai)). A `Float` primary key holding `±inf` where the predicate's arithmetic maps that endpoint to `NaN`, e.g. `WHERE k / inf = 0`. [#118468](https://github.com/ClickHouse/ClickHouse/pull/118468) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fix wrong results when `indexHint` is given an argument that index analysis cannot read as a condition. `indexHint(256)` was narrowed to `CAST(256, 'UInt8')` = 0 and discarded every part, so the query silently returned an empty result; a wide integer such as `indexHint(toUInt256(256))` did the same, and a `String`, `Decimal` or `NULL` argument threw. Such an argument now contributes no filter, consistently for the primary key, `minmax`, `set` and `bloom_filter` analysis. Closes [#111684](https://github.com/ClickHouse/ClickHouse/issues/111684). [#114048](https://github.com/ClickHouse/ClickHouse/pull/114048) ([Groene AI](https://github.com/groeneai)). Also fixed a bare key column of a type with no boolean reading (`UInt256`, `Int128`, `BFloat16`, or their `LowCardinality` forms) being read as `column != 0` inside `indexHint`, `NOT indexHint(x)` failing with `ILLEGAL_TYPE_OF_ARGUMENT`, and a negated `indexHint` in a disjunction keeping its condition un-inverted, so `count()` could report rows that no row of the table matches. [#119209](https://github.com/ClickHouse/ClickHouse/pull/119209) ([Groene AI](https://github.com/groeneai)).
* Fixed wrong results from `optimize_functions_to_subcolumns`. A `Tuple` element or a `JSON` path named like an automatic subcolumn could be mistaken for it, so for example `length(c.a)` on ``Tuple(`a.size` UInt64, `a` String)`` returned the element instead of the length; `empty`, `notEmpty`, `isNull`, `isNotNull`, `count`, `mapKeys`, `mapValues`, `mapContains`, and `m['key']` were affected the same way. Separately, `length` on an `Array` or `Map` inside a `Nullable` (for example ``Nullable(JSON(`a` Array(Int64)))``) returned `NULL` instead of `0` for a `NULL` row, `tupleElement` on a member of a `Nullable(Tuple(...))` column could fail with `LOGICAL_ERROR`, and a function is now rewritten only to a subcolumn of the same root column, so a physical column such as `` `j.m` `` is no longer confused with the `m` path of `JSON` column `j`. [#115777](https://github.com/ClickHouse/ClickHouse/pull/115777) ([Pavel Kruglov](https://github.com/Avogar)). [#119150](https://github.com/ClickHouse/ClickHouse/pull/119150) ([Groene AI](https://github.com/groeneai)). [#119631](https://github.com/ClickHouse/ClickHouse/pull/119631) ([Groene AI](https://github.com/groeneai)).
* Declaring `STATISTICS(...)` on an `ALIAS` or `EPHEMERAL` column is now rejected when the table is created or altered, instead of being accepted and making every subsequent `INSERT` fail with `NOT_FOUND_COLUMN_IN_BLOCK`. Closes [#114791](https://github.com/ClickHouse/ClickHouse/issues/114791). [#115882](https://github.com/ClickHouse/ClickHouse/pull/115882) ([Groene AI](https://github.com/groeneai)).
* Fixed `CREATE TABLE` accepting a subcolumn as a `UNIQUE KEY` element, of either a user column (for example `` UNIQUE KEY (`c.null`) ``) or a virtual one (`` UNIQUE KEY (`_partition_value.1`) ``), which produced a table that could never be inserted into, failing every `INSERT` with `NOT_FOUND_COLUMN_IN_BLOCK`. Such a definition is now rejected with `BAD_ARGUMENTS`. Closes [#114470](https://github.com/ClickHouse/ClickHouse/issues/114470). [#115854](https://github.com/ClickHouse/ClickHouse/pull/115854) ([Groene AI](https://github.com/groeneai)).
* Fixed an in-process Keeper client (`KeeperOverDispatcher`) reporting a failed `multi` transaction as successful, because a rolled-back batch's aggregate error was left `ZOK`. [#117135](https://github.com/ClickHouse/ClickHouse/pull/117135) ([Sergei Trifonov](https://github.com/serxa)).
* Fixed OOM when reading a `Parquet` file with an invalid `num_children` field in the schema. [#117797](https://github.com/ClickHouse/ClickHouse/pull/117797) ([Michael Kolupaev](https://github.com/al13n321)).
* Fixed a `Parquet` reader bug where a filter on a `UUID` column could silently return fewer rows than the file holds, or reject a valid file with `INCORRECT_DATA: Statistics have min_value > max_value`. Parquet sorts `uuid` statistics by big-endian bytes while ClickHouse sorts `UUID` by its second half, so those statistics are no longer used for row group or page pruning. Closes [#118371](https://github.com/ClickHouse/ClickHouse/issues/118371). [#118387](https://github.com/ClickHouse/ClickHouse/pull/118387) ([Groene AI](https://github.com/groeneai)).
* Fixed wrong results when reading a `Parquet` file with a nullable struct column without an explicit schema. Schema inference pushed the nullability down to the tuple elements and returned `Tuple(Nullable(...), ...)`, which cannot hold a struct-level NULL, so a NULL struct was read as a tuple of NULLs. Such a column is now inferred as `Nullable(Tuple(...))` when `allow_experimental_nullable_tuple_type` is enabled. That setting was also added to the `Parquet` schema inference cache key, so a schema cached under one of its values is no longer reused under the other. [#115653](https://github.com/ClickHouse/ClickHouse/pull/115653) ([Groene AI](https://github.com/groeneai)).
* Fix reading `Arrow` and `ArrowStream` files containing values hidden by NULLs or unused nested ranges, which could cause validation errors or expose undefined values. Fix nullable tuple conversions and destination defaults, dictionary decoding under requested types, and NULL dictionary entries for complex types. Accept compatible shared dictionaries with differing field annotations and reject replacement dictionaries in `Arrow` files. Validate nested row counts before allocation and read bufferless batches incrementally without materializing their entire declared row count. [#110531](https://github.com/ClickHouse/ClickHouse/pull/110531) ([Nihal Z. Miaji](https://github.com/nihalzp)). Fix reading a flattened `Tuple` subcolumn (e.g. `` `s.v` ``) from an `Arrow`/`ArrowStream` file whose column is a nullable struct returning column defaults instead of the actual data when `allow_experimental_nullable_tuple_type` is enabled. Also fix `ORC` reads resolving a column or struct field name to the first case-folded match under `input_format_orc_case_insensitive_column_matching`, which returned another field's data when two names differ only by case. [#109741](https://github.com/ClickHouse/ClickHouse/pull/109741) ([Groene AI](https://github.com/groeneai)).
* Fix a crash and wrong results when reading the `DWARF` format with column types other than the ones the format produces, for example `SELECT * FROM file('a.elf', DWARF, 'tag String')`. Requesting a column that does not exist in the format now reports a proper error instead of `std::out_of_range`. [#118794](https://github.com/ClickHouse/ClickHouse/pull/118794) ([Raúl Marín](https://github.com/Algunenano)).
* Fix data silently dropped when reading a hadoop-snappy stream whose block has several subblocks and the input is refilled in the middle of that block, which happens when the file is read over a pipe or HTTP. [#118705](https://github.com/ClickHouse/ClickHouse/pull/118705) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed two defects in the legacy binary settings format, used for native-protocol clients declaring a revision below 54429. Signed integer settings (for example `max_partitions_to_read` or `iceberg_snapshot_id`) were silently ignored, and were reported as changed while holding their default, so they overrode the table-level value with that default. Settings required to be greater than zero (for example `max_block_size`) were not validated when read from that format. [#118610](https://github.com/ClickHouse/ClickHouse/pull/118610) ([Groene AI](https://github.com/groeneai)).
* Fixed a query over an `Iceberg` table returning rows that had been deleted, when a position-delete manifest declares a lower bound above the upper bound for the reserved `file_path` column. Such a pair describes an empty range, so the delete file was skipped for every data file it covers; those bounds are now ignored instead. Closes [#118113](https://github.com/ClickHouse/ClickHouse/issues/118113). [#118181](https://github.com/ClickHouse/ClickHouse/pull/118181) ([Groene AI](https://github.com/groeneai)).
* Fixed reading an `Iceberg` table failing with `ICEBERG_SPECIFICATION_VIOLATION` after a column was dropped while its data is still present in the data files. Closes [#113324](https://github.com/ClickHouse/ClickHouse/issues/113324). [#116488](https://github.com/ClickHouse/ClickHouse/pull/116488) ([Konstantin Vedernikov](https://github.com/scanhex12)).
* Fixed `write_full_path_in_iceberg_metadata` writing an unresolvable `local://` URI, with a doubled root slash, into the metadata of an `IcebergLocal` table, so that no external Iceberg reader could open it. A local table location is now spelled `file:///path`, and a backend without a namespace no longer contributes an empty authority segment. [#117828](https://github.com/ClickHouse/ClickHouse/pull/117828) ([Groene AI](https://github.com/groeneai)).
* Fixed writing `Iceberg` statistics on top of Azure storage. [#119369](https://github.com/ClickHouse/ClickHouse/pull/119369) ([Konstantin Vedernikov](https://github.com/scanhex12)).
* `ATTACH TABLE` of a data lake table no longer reads anything from object storage, and such tables no longer report row statistics in system tables. [#117584](https://github.com/ClickHouse/ClickHouse/pull/117584) ([Konstantin Vedernikov](https://github.com/scanhex12)).
* Reading a table backed by local object storage (`paimonLocal`, `icebergLocal`, `deltaLakeLocal`, or a disk with `object_storage_type: local`) whose metadata references a file that is missing on disk now fails with a `FILE_DOESNT_EXIST` exception naming the file, instead of a raw `std::filesystem` error surfaced as the opaque `STD_EXCEPTION` (code 1001). [#115542](https://github.com/ClickHouse/ClickHouse/pull/115542) ([JIaQi Tang](https://github.com/JiaQiTang98)).
* Fixed a `SELECT` from a table with `paimon_incremental_read = 1` failing with `REPLICA_IS_ALREADY_ACTIVE` ("Failed to activate Paimon replica after Keeper reconnection") on the first read after the server's Keeper session was lost and re-established. [#118457](https://github.com/ClickHouse/ClickHouse/pull/118457) ([Groene AI](https://github.com/groeneai)).
* Fixed a spurious `Code: 76 CANNOT_OPEN_FILE` error (`Parent directory doesn't exist`) on any write to an `hdfs` disk. Removing a blob deleted its emptied object-key prefix directory, which could race a concurrent write that had just created the same directory and not yet opened its object. Emptied prefix directories are now kept. [#118654](https://github.com/ClickHouse/ClickHouse/pull/118654) ([Groene AI](https://github.com/groeneai)).
* Fixed a server refusing to start after `remote_url_allow_hosts` was tightened while a database with the `HDFS` engine existed: the host check ran during metadata loading and took every other database down with it. [#118964](https://github.com/ClickHouse/ClickHouse/pull/118964) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed a server that refused to start after the directory backing a `Filesystem` database had been removed. Such a database is now loaded without tables and can be inspected and dropped, while a `CREATE DATABASE` or `ATTACH DATABASE` issued by a user is still rejected when the path does not exist. [#118684](https://github.com/ClickHouse/ClickHouse/pull/118684) ([Groene AI](https://github.com/groeneai)).
* With `enable_analyzer = 1` (the default), fixed `INCOMPATIBLE_TYPE_OF_JOIN` and `NOT_FOUND_COLUMN_IN_BLOCK` errors when an `ALL INNER JOIN` against a table with the `Join` table engine carried an `ON` condition referencing only that table, such as `ON t.key = j.key AND j.value > 100`. The condition is now applied after the join, which is what the equivalent `WHERE` spelling already did. Closes [#116541](https://github.com/ClickHouse/ClickHouse/issues/116541). [#116612](https://github.com/ClickHouse/ClickHouse/pull/116612) ([Groene AI](https://github.com/groeneai)).
* Fixed uneven partition distribution in the `Kafka` engine with `kafka_keeper_path` (`StorageKafka2`) when `kafka_num_consumers` is greater than 1. A node running N consumers could claim N times its fair share of the topic's partitions and hold them indefinitely, leaving other replicas idle. [#116843](https://github.com/ClickHouse/ClickHouse/pull/116843) ([Aparajita Pandey](https://github.com/aparajita31pandey)).
* `clickhouse-local` now preserves detailed `Poco::Exception` messages from local query execution instead of reporting them as generic `STD_EXCEPTION` errors. This includes errors returned by the `mysql` table function. [#116884](https://github.com/ClickHouse/ClickHouse/pull/116884) ([Mark Needham](https://github.com/mneedham)).
* Fixed `HashJoin` right-side memory accounting when a memory limit interrupts a join build. A block could be stored without being counted, so the join under-reported its size to the memory limits and the spilling thresholds, and a `Join` engine table held the memory of a failed `INSERT` for the rest of its lifetime. [#116991](https://github.com/ClickHouse/ClickHouse/pull/116991) ([Groene AI](https://github.com/groeneai)).
* Fix wrong aggregate values from the default-enabled `optimize_rewrite_aggregate_function_with_if` when the constant is in the first branch of the `if` and the condition can be NULL, for example `sum(if(c, 0, x))` or `avg(if(c, NULL, x))`. Rows whose condition was NULL were silently dropped from the aggregate. [#117221](https://github.com/ClickHouse/ClickHouse/pull/117221) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed a signed integer overflow when the effective table lock timeout, the smaller of `lock_acquire_timeout` and a non-zero `max_execution_time`, was above roughly 9.2e9 seconds or a large negative value. Reading or writing a `Log`, `TinyLog`, `StripeLog` or `File` table built the lock deadline from it without bounding it first, so the wait was no longer bounded by the setting. [#117974](https://github.com/ClickHouse/ClickHouse/pull/117974) ([Groene AI](https://github.com/groeneai)).
* `divideDecimal` no longer returns `0` instead of the correct value when the dividend reduces to a single digit after being rescaled to the result scale, for example `divideDecimal(toDecimal256(5, 0), toDecimal256(1, 0), 0)` or `divideDecimal(toDecimal32(5.6789, 4), toDecimal32(2, 0), 0)`. The bug was present in every release since 22.12, so any stored result of such a division is wrong and should be recomputed. [#118346](https://github.com/ClickHouse/ClickHouse/pull/118346) ([Minh Vu](https://github.com/fallintoplace)).
* Fixed `ClickHouseDictionarySource table cannot be dictionary table` being raised for a dictionary whose source is a table on another ClickHouse server that happens to share the dictionary's database and table name. The check against a dictionary using itself as its own source now applies only when the source is the local server. [#118441](https://github.com/ClickHouse/ClickHouse/pull/118441) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fix `arrayElementOrNull` over an array of tuples, and `arrayElement` over an array of `Nullable` tuples, returning a tuple of default values instead of `NULL` for a constant `UInt64` index close to the maximum of `UInt64`, such as `toUInt64(18446744073709551615)`. [#118447](https://github.com/ClickHouse/ClickHouse/pull/118447) ([Minh Vu](https://github.com/fallintoplace)).
* Fixed a query parameter being reported as unset (`UNKNOWN_QUERY_PARAMETER`) when it is the entire `INTERPOLATE` expression, as in `ORDER BY x WITH FILL INTERPOLATE (value AS {p:Int64})`, while the same parameter nested in a larger expression worked. Closes [#118458](https://github.com/ClickHouse/ClickHouse/issues/118458). [#118568](https://github.com/ClickHouse/ClickHouse/pull/118568) ([Groene AI](https://github.com/groeneai)). The same for a parameter that is the entire predicate of a lightweight `DELETE`, as in `DELETE FROM t WHERE {p:UInt8}`. [#118667](https://github.com/ClickHouse/ClickHouse/pull/118667) ([Groene AI](https://github.com/groeneai)).
* Fix partition pruning and primary key filtering being silently disabled when `parallel_replicas_min_number_of_rows_per_replica` is set inside a subquery or CTE instead of at top query level. [#116529](https://github.com/ClickHouse/ClickHouse/pull/116529) ([Yarik Briukhovetskyi](https://github.com/yariks5s)).
* Fixed wrong results and a `LOGICAL_ERROR` for `SELECT ... FINAL` under `make_distributed_plan = 1` when a `PREWHERE` or a row policy is deferred until after `FINAL` (`apply_prewhere_after_final`, or the default `apply_row_policy_after_final`). [#116626](https://github.com/ClickHouse/ClickHouse/pull/116626) ([Groene AI](https://github.com/groeneai)).
* Fixed wrong results from JIT-compiled conversions of a floating point value to an integer or `Decimal` type when the value does not fit the destination: a comparison against the converted value could be evaluated against the pre-conversion value, so the same query could flip between repeated executions. Such conversions are now evaluated by the interpreter, which also means they raise `CANNOT_CONVERT_TYPE` for `NaN` or `Inf` and `DECIMAL_OVERFLOW` on `Decimal` overflow where an arbitrary value was previously returned. Closes [#117442](https://github.com/ClickHouse/ClickHouse/issues/117442). [#117590](https://github.com/ClickHouse/ClickHouse/pull/117590) ([Groene AI](https://github.com/groeneai)). Fixed wrong results from a JIT-compiled `CAST` of a `Nullable` value to a non-`Nullable` type: converting a NULL must raise `CANNOT_INSERT_NULL_IN_ORDINARY_COLUMN`, but the compiled expression returned the nested value instead, so the same query silently started answering with wrong data once `min_count_to_compile_expression` was crossed. Such a conversion is no longer compiled. [#119079](https://github.com/ClickHouse/ClickHouse/pull/119079) ([Groene AI](https://github.com/groeneai)).
* A simple `Query` in the PostgreSQL wire protocol now destroys the unnamed prepared statement and the unnamed portal, as PostgreSQL does, so a later `Bind` or `Execute` on them is rejected instead of silently reusing stale extended-query state. [#118210](https://github.com/ClickHouse/ClickHouse/pull/118210) ([Groene AI](https://github.com/groeneai)).
* `portRFC` now returns the explicit port of a URL whose host is an IPv6 address in brackets, such as `http://[2001:db8::1]:8080/`, instead of the default port. [#118632](https://github.com/ClickHouse/ClickHouse/pull/118632) ([Alexey Milovidov](https://github.com/alexey-milovidov)). `port` and `portRFC` now return the explicit port for valid URLs with a query string or fragment after the port. [#118482](https://github.com/ClickHouse/ClickHouse/pull/118482) ([Minh Vu](https://github.com/fallintoplace)).
* `fuzzBits` and `generateULID` now return an independently generated value per row when all of their arguments are constants, instead of one value repeated for every row. [#118643](https://github.com/ClickHouse/ClickHouse/pull/118643) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fix `EmbeddedRocksDB`, `KeeperMap` and `Redis` returning no rows for `WHERE key = `, such as a `Date` key compared with a `DateTime` literal. [#118689](https://github.com/ClickHouse/ClickHouse/pull/118689) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed the row numbers shown in the Web UI for a page other than the first one: they restarted at 1 on every page instead of counting from the page's position in the whole result. [#116614](https://github.com/ClickHouse/ClickHouse/pull/116614) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fix delayed ClickHouse Keeper shutdown when idle client sessions are blocked in socket polling. [#118014](https://github.com/ClickHouse/ClickHouse/pull/118014) ([Antonio Andelic](https://github.com/antonio2368)). Fix graceful shutdown of `clickhouse-keeper` hanging for up to 300 seconds when a client connection on `keeper_server.tcp_port_secure` is stalled in a TLS read. [#119450](https://github.com/ClickHouse/ClickHouse/pull/119450) ([Groene AI](https://github.com/groeneai)).
* Fixed a Keeper crash when a member that was removed from the cluster is added back without its process being restarted. Such a member could also replay already-applied entries. [#118740](https://github.com/ClickHouse/ClickHouse/pull/118740) ([Shaohua Wang](https://github.com/tiandiwonder)).
* Fix handling of regular expressions ending with an unescaped backslash in `match`, `extractAll`, `countMatches` and `splitByRegexp`. Such invalid patterns are no longer incorrectly treated as trivial substring matches. [#118229](https://github.com/ClickHouse/ClickHouse/pull/118229) ([Alex Prabhat Bara](https://github.com/alexprabhat99)).
* Fixed `match` and `countMatches` returning wrong results for a pattern whose character class starts with a literal `]` (`[]a]b`) or contains a literal `[` next to an alternation (`abc[[]|b`): the required-substring prefilter demanded a substring the pattern does not require. The same defect made `optimize_rewrite_regexp_functions` turn such a `replaceRegexpAll` into `replaceRegexpOne`. [#118342](https://github.com/ClickHouse/ClickHouse/pull/118342) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fix `startsWith*` array functions returning suffix matches for some variants. [#118672](https://github.com/ClickHouse/ClickHouse/pull/118672) ([Minh Vu](https://github.com/fallintoplace)).
* Fixed an out-of-bounds access that could happen with the `getURLHostRFC` function. [#119026](https://github.com/ClickHouse/ClickHouse/pull/119026) ([Groene AI](https://github.com/groeneai)).
* Fix the HTTP connection pool comparing `disk_connections_store_limit`, `storage_connections_store_limit`, and `http_connections_store_limit` against the total number of connections in the group instead of the number of stored connections. A server whose concurrency exceeded the limit cached no connections at all, opened a new TCP connection for every request to object storage, and could exhaust the ephemeral port range of the host. The limit now bounds only the idle connections kept for reuse. [#119078](https://github.com/ClickHouse/ClickHouse/pull/119078) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed the hash-family join algorithms treating a non-NULL `Nullable(Tuple(...))` key that contains a NULL element as a NULL key, which made the result of a join depend on the `join_algorithm` setting. `IN` with a subquery over such a key was affected in the same way. [#119081](https://github.com/ClickHouse/ClickHouse/pull/119081) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fix wrong results when `analyzer_compatibility_join_using_top_level_identifier = 1` and a `JOIN ... USING` key resolves to a `SELECT`-list alias whose name is a virtual column of the left table expression, such as `SELECT upper(t._part) AS _part FROM t JOIN r USING (_part)`. The raw virtual column value was silently used as the join key instead of the aliased expression. [#119102](https://github.com/ClickHouse/ClickHouse/pull/119102) ([Groene AI](https://github.com/groeneai)).
* Fixed a `LOGICAL_ERROR` (`Got read request from replica N for unknown stream
`) when `parallel_replicas_plan_based` is enabled and a join is distributed across replicas. [#118084](https://github.com/ClickHouse/ClickHouse/pull/118084) ([Groene AI](https://github.com/groeneai)).
* Fixes a case where `date_time_overflow_behavior = 'saturate'` clamped an out-of-range value to the whole second and discarded the sub-second component. Closes [#113152](https://github.com/ClickHouse/ClickHouse/issues/113152). [#116122](https://github.com/ClickHouse/ClickHouse/pull/116122) ([Yarik Briukhovetskyi](https://github.com/yariks5s)).
* Fix `system.dictionaries.bytes_allocated` misreporting memory for `HASHED_ARRAY` dictionaries: the key containers contributed their element count instead of their buffer size in bytes, so the reported figure came out roughly 2-5x lower than the memory the dictionary actually held, and the bit-packed per-attribute null masks were counted in elements, which over-reported that term by 8x. [#118641](https://github.com/ClickHouse/ClickHouse/pull/118641) ([George Viamontes](https://github.com/gviamont)). Fixed the same figure over-reporting memory for nullable `RANGE_HASHED` dictionaries, whose bit-packed nullable mask was counted one byte per flag. [#118675](https://github.com/ClickHouse/ClickHouse/pull/118675) ([Minh Vu](https://github.com/fallintoplace)).
* Fixed `max_execution_time_leaf` and `timeout_overflow_mode_leaf` being ignored for queries executed with parallel replicas (including `INSERT SELECT` with `parallel_distributed_insert_select = 2`). [#69540](https://github.com/ClickHouse/ClickHouse/pull/69540) ([Igor Nikonov](https://github.com/devcrafter)).
* Fix `CREATE TABLE ... CLONE AS SELECT ...` and `CREATE TABLE ... CLONE AS ` silently ignoring the `CLONE` keyword and creating a plain `CREATE ... AS SELECT` instead. These shapes are now rejected with `BAD_ARGUMENTS`. [#105004](https://github.com/ClickHouse/ClickHouse/pull/105004) ([Tuan Pham Anh](https://github.com/tuanpach)).
* Fix a logical error (a server abort in debug builds) when a non-transactional `DROP PARTITION`, `DETACH PARTITION`, `DROP PART`, `REPLACE PARTITION FROM` or `MOVE PARTITION TO TABLE` covered a part whose creating transaction had not committed yet. Such an operation now fails with `SERIALIZATION_ERROR` and can be retried once the creating transaction finishes; it no longer removes or replaces any part of the affected batch. [#105116](https://github.com/ClickHouse/ClickHouse/pull/105116) ([Tuan Pham Anh](https://github.com/tuanpach)).
* Fix a logical error when a correlated `MATERIALIZED` CTE is referenced more than once inside a `JOIN`. Such a CTE is now rejected at analysis time with `UNSUPPORTED_METHOD`, consistently with the single-reference and `IN`-subquery paths. [#108883](https://github.com/ClickHouse/ClickHouse/pull/108883) ([Groene AI](https://github.com/groeneai)).
* Fix a logical error `Invalid cast from Nothing to native type` (an abort in debug/sanitizer builds) when `compile_expressions = 1` compiled an expression with a `Nullable(Nothing)` operand, e.g. `and(Nullable(Nothing), )`. [#111508](https://github.com/ClickHouse/ClickHouse/pull/111508) ([Groene AI](https://github.com/groeneai)).
* Fix wrong results with `enable_parallel_replicas = 1` when a join tree contains a join other than the leftmost one that cannot be applied independently per replica: a strictness other than `ALL` outside a `LEFT` join, for example `t1 INNER JOIN t2 ON t1.c = t2.c ANY INNER JOIN t3 ON 1`, which returned the row once per replica instead of once; a `FULL` join, which emitted every row twice; or a `PASTE` join, which pairs rows by position. Parallel replicas are now disabled for such a join tree, as they already are for the equivalent two-table join. [#112317](https://github.com/ClickHouse/ClickHouse/pull/112317) ([Groene AI](https://github.com/groeneai)).
* Fix a segfault and silently wrong results when reading a `sizeN` subcolumn of a nested `Array(JSON)` path. Closes [#113686](https://github.com/ClickHouse/ClickHouse/issues/113686). [#113752](https://github.com/ClickHouse/ClickHouse/pull/113752) ([Groene AI](https://github.com/groeneai)).
* Fixed wrong results and a server abort when a `JOIN ON` condition evaluated during an `ie_join` join contains `arrayJoin`. Such a condition is now rejected with `INVALID_JOIN_ON_EXPRESSION`. Previously `SEMI`/`ANTI`/`LEFT`/`RIGHT`/`FULL` joins using the `ie_join` algorithm could return duplicated or missing rows, or abort the server. [#114325](https://github.com/ClickHouse/ClickHouse/pull/114325) ([Groene AI](https://github.com/groeneai)).
* Fix reading a `Log` or `TinyLog` table whose array or map elements are missing while their sizes are present: such a table returned rows with elements that are not there and made the server read out of bounds. It is now reported as `INCORRECT_DATA`. [#115528](https://github.com/ClickHouse/ClickHouse/pull/115528) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fix a segmentation fault when reading in order from a `Merge` table over `MergeTree` tables whose sorting key is shorter than the key prefix chosen for the query. [#116364](https://github.com/ClickHouse/ClickHouse/pull/116364) ([Groene AI](https://github.com/groeneai)).
* Fix `LOGICAL_ERROR: GroupingAggregatedTransform pushed bucket N twice` when `make_distributed_plan` picks the `Shuffle` aggregation strategy while the aggregation must produce results in bucket order (for example with `distributed_aggregation_memory_efficient`). It is now planned as a partial aggregation plus a merge. [#116446](https://github.com/ClickHouse/ClickHouse/pull/116446) ([Groene AI](https://github.com/groeneai)).
* Fix wrong row order when sorting a `LowCardinality` column of a floating-point type whose dictionary holds two entries that compare equal, such as `-0.0` and `+0.0`. A multi-column `ORDER BY` did not apply the remaining keys to those rows, and the `MergeTree` writer's stable sort did not keep them in insertion order, changing which row `ReplacingMergeTree` keeps. [#116870](https://github.com/ClickHouse/ClickHouse/pull/116870) ([Groene AI](https://github.com/groeneai)).
* Fixed wrong results from the default-on `optimize_time_filter_with_preimage` for `toYear`/`toYYYYMM` predicates at the column type's maximum (`Date` at 2149, `DateTime` at 2106), a `DECIMAL_OVERFLOW` exception for the same predicates on a `DateTime64(9)` column at 2262, and wrong results for the same predicates on `DateTime`/`DateTime64` columns in time zones whose year or month boundary is not local midnight (`America/Lima`, `America/Managua`). [#117451](https://github.com/ClickHouse/ClickHouse/pull/117451) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed `NOT_IMPLEMENTED` ("Cannot decorrelate query, because 'DelayedCreatingSets' step is not supported") for a correlated subquery whose `WHERE` builds a set, for example an `IN (subquery)`, or a `dictGet(...) >= const` comparison that `optimize_inverse_dictionary_lookup` rewrites into one. [#118412](https://github.com/ClickHouse/ClickHouse/pull/118412) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed a race between `SYSTEM RESTORE DATABASE REPLICA` and the DDL worker of a `Replicated` database. The restore re-initialised the replica while the previous DDL worker was still running its own startup recovery, so the recovery could mark the wrong range of replicated-DDL log entries as finished, or move local tables to `_broken_replicated_tables`. The worker is now stopped before the restore touches Keeper. [#118481](https://github.com/ClickHouse/ClickHouse/pull/118481) ([Groene AI](https://github.com/groeneai)).
* Fixed `WITH RECURSIVE` losing its recursiveness in the second and later branches of a `UNION`, `INTERSECT` or `EXCEPT`. When a later branch had no `WITH` clause of its own, the first branch's `WITH` list was copied into it without the `RECURSIVE` marker, so `WITH RECURSIVE src AS (SELECT 1 AS id UNION ALL SELECT id + 1 FROM src WHERE id < 3) SELECT sum(id) FROM src UNION ALL SELECT sum(id) FROM src` was rejected with `UNKNOWN_TABLE`, and returned a wrong value for the copied branch when an enclosing CTE of the same name existed. `CREATE VIEW` also stored the copied branch without `RECURSIVE`. [#118510](https://github.com/ClickHouse/ClickHouse/pull/118510) ([Groene AI](https://github.com/groeneai)).
* Fixed a `GLOBAL RIGHT JOIN` over `Distributed` tables returning unmatched rows of the right table once per shard: the original left table is now broadcast and the preserved right side stays sharded. Closes [#95728](https://github.com/ClickHouse/ClickHouse/issues/95728). [#118611](https://github.com/ClickHouse/ClickHouse/pull/118611) ([Anton Ivashkin](https://github.com/ianton-ru)).
* Fix an endless `ORDER BY ... WITH FILL` when the `STEP` is too small to change the value it is added to. [#118633](https://github.com/ClickHouse/ClickHouse/pull/118633) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fix the `Invalid local IN function name globalIn` error for a query with `IN` over a `UNION` of `Distributed` tables when `distributed_product_mode = 'global'` or `prefer_global_in_and_join` is enabled. [#118639](https://github.com/ClickHouse/ClickHouse/pull/118639) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* `toLastDayOfMonth` and `toLastDayOfWeek` of a `Date` argument now saturate at the `Date` maximum (`2149-06-06`) instead of wrapping around to 1970. The wrapped result also silently dropped matching rows through primary-key pruning. [#118642](https://github.com/ClickHouse/ClickHouse/pull/118642) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed a crash and a `LOGICAL_ERROR` in the `mergeTreeIndex` table function when reading a key column whose `ALTER TABLE ... MODIFY COLUMN` between `T` and `LowCardinality(T)` has an unmaterialized mutation. The key column is now emitted in the type the current metadata declares. [#118709](https://github.com/ClickHouse/ClickHouse/pull/118709) ([Groene AI](https://github.com/groeneai)).
* Fix `SYNTAX_ERROR` when loading views, materialized views, or projections whose `SELECT` list starts with a column named `TOP`. [#118754](https://github.com/ClickHouse/ClickHouse/pull/118754) ([Kirill](https://github.com/kirillgarbar)).
* Fixed `optimize_or_like_chain` returning extra rows for `OR` chains of `LIKE`/`ILIKE` patterns that do not end in `%`: a value followed by a trailing newline wrongly matched the filter. [#118766](https://github.com/ClickHouse/ClickHouse/pull/118766) ([Jimmy Aguilar Mena](https://github.com/Ergus)).
* Fixed a `LOGICAL_ERROR` ("Expected CommonSubplanReferenceStep to reference CommonSubplanStep") raised at query planning time when `query_plan_convert_join_to_in = 1` was used with a correlated aggregating scalar subquery. The optimization now keeps the `JOIN` instead of rewriting it when either join input carries a common subplan node. [#118797](https://github.com/ClickHouse/ClickHouse/pull/118797) ([Groene AI](https://github.com/groeneai)).
* Fix a wrong result for `SELECT * APPLY (x -> f(x))` over `JOIN ... USING (a, b)`: every `USING` column was named after the lambda parameter (`f(x)`) instead of the matched column, so two output columns shared one name, and wrapping the query in `SELECT * FROM (...)` returned one `USING` column's values under the other column's position; a type-returning lambda such as `toTypeName` failed with `AMBIGUOUS_COLUMN_NAME` instead. The same happened for `COLUMNS(a, b) APPLY (x -> f(x))`, and for two or more `ARRAY JOIN` columns. The lambda form of `APPLY` now names these columns like `APPLY f` and a plain `*` already did. [#118825](https://github.com/ClickHouse/ClickHouse/pull/118825) ([Groene AI](https://github.com/groeneai)).
* Fixed a server crash that could happen when a `WORKLOAD` setting limiting concurrency (e.g. `max_concurrent_queries` or `max_bytes_inflight`) was lowered below the number of currently in-flight resource requests while the workload was active. [#118836](https://github.com/ClickHouse/ClickHouse/pull/118836) ([Sergei Trifonov](https://github.com/serxa)).
* Fixed a logical error (`Method == not implemented for AST`) raised by a `SET` of a custom setting that already held an AST value such as `disk(type = 's3', ...)`. Assigning such a setting a second time in one session, or clamping a nested `SETTINGS` clause against it, reached a comparison that was never implemented. [#118993](https://github.com/ClickHouse/ClickHouse/pull/118993) ([Groene AI](https://github.com/groeneai)).
* Fixed a broken part in `detached/` never being renamed with the `broken_` prefix by the `ATTACH_PART` executor, which left it occupying a valid part name and failing every later attach attempt. [#118999](https://github.com/ClickHouse/ClickHouse/pull/118999) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fix `TOO_DEEP_SUBQUERIES` being thrown for `GLOBAL IN` and `GLOBAL JOIN` subqueries in two analyzer cases: when `max_subquery_depth` is set, the depth is now counted in nested subqueries instead of query tree nodes; and when a `UNION` is on the path to the `GLOBAL` subquery, `UNION` nodes no longer count toward that depth. Closes [#79345](https://github.com/ClickHouse/ClickHouse/issues/79345). Closes [#119623](https://github.com/ClickHouse/ClickHouse/issues/119623). [#119033](https://github.com/ClickHouse/ClickHouse/pull/119033) ([Vladimir Cherkasov](https://github.com/vdimir)). [#119650](https://github.com/ClickHouse/ClickHouse/pull/119650) ([Groene AI](https://github.com/groeneai)).
* With `prefer_column_name_to_alias = 1`, an unqualified column name that is ambiguous between joined tables now resolves to the alias with the same name, as the old analyzer did, instead of throwing `AMBIGUOUS_IDENTIFIER`. [#119192](https://github.com/ClickHouse/ClickHouse/pull/119192) ([Vladimir Cherkasov](https://github.com/vdimir)). [#119906](https://github.com/ClickHouse/ClickHouse/pull/119906) ([Vladimir Cherkasov](https://github.com/vdimir)).
* Fix a wrong-order merge (logical error `Virtual row does not cover sort column` in debug builds) when reading in order with virtual rows and `ORDER BY` contains constants, e.g. `SELECT DISTINCT a, b FROM t ORDER BY 'x', a, 'd' COLLATE 'cs', b` on a table with key `(a, b)`. [#119195](https://github.com/ClickHouse/ClickHouse/pull/119195) ([Vladimir Cherkasov](https://github.com/vdimir)).
* Fixed wrong results when a table's sorting key expression resolves to a different result type in the query than in the table, for example a key of `CAST(json.b, 'String')` read with `cast_keep_nullable = 1`. Read-in-order treated the two as interchangeable, so rows could come back out of order, `optimize_aggregation_in_order` could split groups and report wrong aggregates, and `read_in_order_use_virtual_row = 1` could fail with `LOGICAL_ERROR: Virtual row has different type`. [#119385](https://github.com/ClickHouse/ClickHouse/pull/119385) ([Groene AI](https://github.com/groeneai)).
* Fixed `BACKUP` of a `Memory` table reading an unrelated file named `tmp_sizes_json` from the server's working directory: the `sizes.json` shipped inside the backup is now built in memory, so such a file can no longer make the backup fail or add foreign entries to it. [#119330](https://github.com/ClickHouse/ClickHouse/pull/119330) ([Groene AI](https://github.com/groeneai)).
* Fix `NOT_FOUND_COLUMN_IN_BLOCK` when a `MergeTree` skip index uses `mortonEncode` or `hilbertEncode` directly and a query filters on one of the curve arguments. [#119355](https://github.com/ClickHouse/ClickHouse/pull/119355) ([Minh Vu](https://github.com/fallintoplace)).
* Fixed an `ALTER` on a view or materialized view with `SQL SECURITY DEFINER` deleting the auto-created `:definer` account when the `ALTER` did not change the definer. Every later `SELECT` from the view, and every `INSERT` into a materialized view's source table, then failed permanently with `There is no user ':definer' in 'user directories'` (`UNKNOWN_USER`). [#119357](https://github.com/ClickHouse/ClickHouse/pull/119357) ([Groene AI](https://github.com/groeneai)).
* Fixed a materialized view whose `SELECT` contains a `UNION`, `INTERSECT` or `EXCEPT` in a subquery or CTE breaking after `DETACH TABLE` + `ATTACH TABLE`, or after `RESTORE`: every subsequent `INSERT` into its source table failed with `UNION mode UNION_DEFAULT must be normalized`, and under `enable_analyzer = 0` it was silently evaluated as a plain union, returning wrong results. `ATTACH TABLE` (short form) and `RESTORE` now re-run set-operation normalization on the stored definition. [#119365](https://github.com/ClickHouse/ClickHouse/pull/119365) ([Groene AI](https://github.com/groeneai)).
* Fix an `ALIAS` column that references another column (`b UInt64 ALIAS a`) reading back as the default value of its type when the table is read through a `Merge` table over a `Distributed` table with a remote shard. [#119561](https://github.com/ClickHouse/ClickHouse/pull/119561) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fix `arrayShiftLeft` and `arrayShiftRight` when an explicit `NULL` default is used with a nullable array. [#119626](https://github.com/ClickHouse/ClickHouse/pull/119626) ([Minh Vu](https://github.com/fallintoplace)).
* Fix `ALTER TABLE ... MODIFY SETTING name = DEFAULT` being ignored. Closes [#49613](https://github.com/ClickHouse/ClickHouse/issues/49613). [#118526](https://github.com/ClickHouse/ClickHouse/pull/118526) ([Vitaly Baranov](https://github.com/vitlibar)).
* Fix `arrayNormalizedGini` rejecting valid rows with different array sizes in the same block. [#118631](https://github.com/ClickHouse/ClickHouse/pull/118631) ([Minh Vu](https://github.com/fallintoplace)).
* Fix `substringIndex` and `substringIndexUTF8` rejecting `UInt64` counts above `Int64::max()` instead of interpreting them as negative counts. [#118645](https://github.com/ClickHouse/ClickHouse/pull/118645) ([Minh Vu](https://github.com/fallintoplace)).
* Fix a logical error for an asynchronous `INSERT` combined with a non-parallel quorum (`insert_quorum` greater than one or `'auto'` together with `insert_quorum_parallel = 0`) when the data is sent as blocks over the native protocol. Such a query is now rejected with `UNSUPPORTED_PARAMETER`, as it already was when the data was inlined in the query text. [#118968](https://github.com/ClickHouse/ClickHouse/pull/118968) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed a graceful shutdown silently discarding the rows of a `Buffer` table whose destination lives in another database or is another `Buffer` table. [#118985](https://github.com/ClickHouse/ClickHouse/pull/118985) ([Alexey Milovidov](https://github.com/alexey-milovidov)). [#116898](https://github.com/ClickHouse/ClickHouse/pull/116898) ([Jayme Bird](https://github.com/jaymebrd)).
* Fix a use-after-free in the gRPC server when a query with a streaming input finishes while a read of the next message is still in flight. [#115707](https://github.com/ClickHouse/ClickHouse/pull/115707) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Custom object metadata written to Google Cloud Storage over the S3 API without HMAC credentials, which is how ClickHouse Cloud on GCP accesses object storage, now takes effect: the headers that GCS spells with the `x-goog-` prefix are translated for every request, not only for server-side copies. Previously GCS discarded the `x-amz-` spelling silently, so the write succeeded and the metadata was not applied. [#119042](https://github.com/ClickHouse/ClickHouse/pull/119042) ([Sema Checherinda](https://github.com/CheSema)).
* Fixed a crash when reading a subcolumn of a `Variant`, `Dynamic`, or `JSON` column whose own type is `Nullable` or `LowCardinality(Nullable)` from a `MergeTree` table, for example ``SELECT value.`Tuple(a Nullable(UInt32), b String)`.a`` over a `Dynamic` column. Previously such a read hit a `LOGICAL_ERROR` in debug builds and crashed in release builds. [#112338](https://github.com/ClickHouse/ClickHouse/pull/112338) ([Groene AI](https://github.com/groeneai)).
* With `shutdown_wait_backups_and_restores = 0`, a `BACKUP` or `RESTORE` whose I/O did not return could keep the server from terminating on a single `SIGTERM`. That wait is now bounded by `shutdown_wait_unfinished`, and new backups and restores are refused once shutdown has begun. [#115377](https://github.com/ClickHouse/ClickHouse/pull/115377) ([Groene AI](https://github.com/groeneai)).
* Fix wrong results when query plan optimizations treat non-deterministic expressions as deterministic, including lambdas and WebAssembly UDFs, which could silently drop rows. [#117248](https://github.com/ClickHouse/ClickHouse/pull/117248) ([Alexey Milovidov](https://github.com/alexey-milovidov)). [#117249](https://github.com/ClickHouse/ClickHouse/pull/117249) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fix `Column identifier ... is already registered` (`LOGICAL_ERROR`) for a correlated subquery over a `VIEW` on a `Distributed` table. Such a query is now refused with `Correlated subqueries are not supported with remote tables`, the same as a correlated subquery over the `Distributed` table itself. The same applies to parameterized views, `Merge` tables over such views, and materialized views whose target is such a view. [#117335](https://github.com/ClickHouse/ClickHouse/pull/117335) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed `transform` and the simple `CASE expr WHEN` form returning the default value instead of the matching one when the expression is a `Nullable(Enum)` column. Only the member whose numeric value was `0` used to match. Closes [#117206](https://github.com/ClickHouse/ClickHouse/issues/117206). [#117520](https://github.com/ClickHouse/ClickHouse/pull/117520) ([Groene AI](https://github.com/groeneai)).
* Fix `SYSTEM RELOAD DICTIONARY ON CLUSTER` and `SYSTEM UNLOAD DICTIONARY ON CLUSTER` so normal distributed DDL clusters resolve the bare dictionary name against the initiator's current database before queuing the task, matching existing table-like `ON CLUSTER` DDL behavior. Closes [#114322](https://github.com/ClickHouse/ClickHouse/issues/114322). [#117596](https://github.com/ClickHouse/ClickHouse/pull/117596) ([Alexander Yoon](https://github.com/XanderYoon)).
* Fixed silently missing rows for predicates on `toUnixTimestamp` of a `Date` or `Date32` primary key or column with statistics: the conversion wraps around `UInt32` for dates after 2106-02-07, but index analysis assumed it was monotonic everywhere. [#117709](https://github.com/ClickHouse/ClickHouse/pull/117709) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed a query getting stuck when the server fails to start a thread for a parallel task, for example when a thread pool is exhausted. [#117781](https://github.com/ClickHouse/ClickHouse/pull/117781) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed wrong results for a distributed query whose folded constant contains a `DateTime` value. The constant is now sent to secondary servers as its raw Unix timestamp wherever the receiving side re-applies the literal's declared type, so DST fall-back overlaps no longer reinterpret it as another instant. [#117837](https://github.com/ClickHouse/ClickHouse/pull/117837) ([Groene AI](https://github.com/groeneai)).
* Fixed queries failing with `AUTHENTICATION_FAILED` after `RENAME DATABASE` on a `Replicated` database that uses `cluster_secret`. The cached cluster object kept the old database name, which participates in the interserver handshake. [#117874](https://github.com/ClickHouse/ClickHouse/pull/117874) ([Kirill Shokhin](https://github.com/kirillshokhin)).
* Fixed `NOT_FOUND_COLUMN_IN_BLOCK` when `transform_null_in = 1` and a distributed or parallel-replicas query aggregates over a predicate that an analyzer pass rewrote into `IN`, such as `SELECT sumIf(id, has([1, 2, 3], id)) FROM t`. [#117897](https://github.com/ClickHouse/ClickHouse/pull/117897) ([Groene AI](https://github.com/groeneai)).
* Fixed `THERE_IS_NO_COLUMN` (`Cannot find column ... in source stream`) when a query shipped as a serialized query plan (`serialize_query_plan = 1`) reads a `Merge` table that spans a local table and a `Distributed` table. [#117969](https://github.com/ClickHouse/ClickHouse/pull/117969) ([Groene AI](https://github.com/groeneai)).
* Fixed a `SELECT` returning fewer rows than it should when a `JSON` subcolumn is compared with an `Enum` constant whose label is the empty string, and the table has a `JSONAllPaths` skip index (`bloom_filter`, `tokenbf_v1`, `ngrambf_v1`, or `sparse_grams`). [#117975](https://github.com/ClickHouse/ClickHouse/pull/117975) ([Groene AI](https://github.com/groeneai)).
* An `Enum` constant wrapped in `Variant` or `Dynamic` and compared against a `String` or `FixedString` column no longer uses the enum's underlying number instead of its name, which previously made `IN`, `NOT IN`, and key analysis use the wrong value. [#117998](https://github.com/ClickHouse/ClickHouse/pull/117998) ([Groene AI](https://github.com/groeneai)).
* Fixed a `Replicated` database being unable to recover a lost replica if it held a `Remote` or `RemoteSecure` table whose target is a table function such as `merge(...)` that no longer resolves. [#118221](https://github.com/ClickHouse/ClickHouse/pull/118221) ([Groene AI](https://github.com/groeneai)).
* Fixed `Not found column ... in block` for a query that combines a constant `ORDER BY` key, `LIMIT BY`, and `LIMIT ... WITH TIES`. [#118222](https://github.com/ClickHouse/ClickHouse/pull/118222) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed two overflow cases where `memory_usage_overcommit_max_wait_microseconds` lost the wait it was asked for and timed out immediately instead of waiting for memory to be freed. [#118227](https://github.com/ClickHouse/ClickHouse/pull/118227) ([Groene AI](https://github.com/groeneai)).
* Fixed `CREATE VIEW` being refused with `SUSPICIOUS_TYPE_FOR_LOW_CARDINALITY` or `ILLEGAL_COLUMN` when the view's inferred column type is gated by settings such as `allow_suspicious_low_cardinality_types` or `enable_time_time64_type`. Views store no data, so those storage-type checks no longer block them. [#118298](https://github.com/ClickHouse/ClickHouse/pull/118298) ([Groene AI](https://github.com/groeneai)).
* Fixed `Not-ready Set is passed as the second argument for function 'globalIn'` when a `PREWHERE` or row-level filter expression containing an `IN` subquery is evaluated by a query planned to the `FetchColumns` stage. [#118359](https://github.com/ClickHouse/ClickHouse/pull/118359) ([Groene AI](https://github.com/groeneai)).
* `SELECT count() FROM ` now works for the `Set` engine, using the table's stored row count instead of failing with `Method read is not supported by storage Set`. Reading regular columns from a `Set` table is still unsupported. [#118491](https://github.com/ClickHouse/ClickHouse/pull/118491) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed `sequenceMatchEvents` returning an event chain that the pattern does not authorize, for example one that skips a `(?t...)` time gate between two of the returned events. The returned chain now always matches a prefix of the pattern. Closes [#118120](https://github.com/ClickHouse/ClickHouse/issues/118120). [#118497](https://github.com/ClickHouse/ClickHouse/pull/118497) ([Groene AI](https://github.com/groeneai)).
* Fixed `toSecond`, `toStartOfMinute`, `toStartOfHour`, `toStartOfInterval`, and the other `toStartOf*` functions returning wrong values for pre-1970 `DateTime64` values in time zones whose historical offset had a sub-minute component, such as `Europe/Amsterdam` before 1937 or `Asia/Kolkata` before 1906. [#118501](https://github.com/ClickHouse/ClickHouse/pull/118501) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fix array aggregation functions returning non-default values for empty arrays when the lambda result is constant. [#118636](https://github.com/ClickHouse/ClickHouse/pull/118636) ([Minh Vu](https://github.com/fallintoplace)).
* Conversions of 128- and 256-bit integers to `DateTime`, `DateTime64`, and `Time64` now saturate like the 64-bit conversions instead of wrapping or storing an out-of-range value. This also fixes silent row loss through primary-key pruning. [#118717](https://github.com/ClickHouse/ClickHouse/pull/118717) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fix a possible heap buffer overflow on malformed blob-storage responses. [#119054](https://github.com/ClickHouse/ClickHouse/pull/119054) ([Arsen Muk](https://github.com/arsenmuk)).
* Preserve input sorting for `groupArrayInsertAt`, `stochasticLinearRegression`, and `stochasticLogisticRegression`, so an `ORDER BY` feeding them is not optimized away. [#119142](https://github.com/ClickHouse/ClickHouse/pull/119142) ([Ivan Babrou](https://github.com/bobrik)).
* Fixed a crash and a `LOGICAL_ERROR` for statements that write `trim(BOTH '' FROM x)` where a function is expected, such as in a column's `STATISTICS(...)` or `CODEC(...)` list, `INDEX ... TYPE`, `ALTER TABLE ... ADD STATISTICS`, a table function, a named collection, or `SETTINGS`. [#119317](https://github.com/ClickHouse/ClickHouse/pull/119317) ([Groene AI](https://github.com/groeneai)).
* Fix `CHECK TABLE` permanently reporting `Found unexpected projection directories` after a mutation when the part carries a projection that the table has since dropped. [#119348](https://github.com/ClickHouse/ClickHouse/pull/119348) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fix a wedged mutation queue after `ATTACH PARTITION` of a partition that was detached before a `DROP COLUMN`: mutations of a Compact part carrying the dropped column no longer fail forever with `UNKNOWN_IDENTIFIER`. [#119354](https://github.com/ClickHouse/ClickHouse/pull/119354) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fix a bug where unfiltered `TRUNCATE ALL TABLES FROM` queries permanently disabled merges on retained `MergeTree` tables, causing later `OPTIMIZE TABLE ... FINAL` queries to fail with `ABORTED`. [#119425](https://github.com/ClickHouse/ClickHouse/pull/119425) ([Paul Annesley](https://github.com/pda)).
* Fix `Unexpected value 0 in enum` thrown by string functions such as `LIKE`, `match`, and `position` when applied to a `Nullable(Enum)` value that is `NULL`, including `NULL`s produced by a `LEFT JOIN` with `join_use_nulls = 1`. [#119513](https://github.com/ClickHouse/ClickHouse/pull/119513) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fix `arrayJaccardIndex` when its input arrays contain duplicate elements. [#119560](https://github.com/ClickHouse/ClickHouse/pull/119560) ([Minh Vu](https://github.com/fallintoplace)).
* `modulo`, `positiveModulo`, `moduloOrZero`, and `moduloOrNull` no longer return wrong results when one operand is a signed integer and the other is an unsigned integer at least as wide. [#119616](https://github.com/ClickHouse/ClickHouse/pull/119616) ([Serhiy Bzhezytskyy](https://github.com/serhiy-bzhezytskyy)).
* A `Filesystem` database no longer keeps pointing at a removed directory, which previously made the server refuse to start on the next restart. [#119618](https://github.com/ClickHouse/ClickHouse/pull/119618) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed a standalone `UPDATE ... SET` reading the wrong table when a mutation expression names a table that a same-named `WITH` element hides but the subquery does not see because its own `SETTINGS` clause disables `enable_global_with_statement`. [#119630](https://github.com/ClickHouse/ClickHouse/pull/119630) ([Groene AI](https://github.com/groeneai)).
* Fixed a stack buffer overflow when reading a `BIT` column from MySQL through the `mysql` table function, the `MySQL` table and database engines, or MySQL dictionaries. [#119680](https://github.com/ClickHouse/ClickHouse/pull/119680) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fix `sparseGrams` ignoring `max_ngram_length` when `min_cutoff_length` is specified. [#119713](https://github.com/ClickHouse/ClickHouse/pull/119713) ([Minh Vu](https://github.com/fallintoplace)).
* Fix `BACKUP` and `RESTORE` of a `Log` or `TinyLog` table when one column occupies zero bytes on disk while the table has rows, such as a column of `countResample` states over an empty range. Previously the restored table could come back empty or fail with `FILE_DOESNT_EXIST`. [#119722](https://github.com/ClickHouse/ClickHouse/pull/119722) ([Groene AI](https://github.com/groeneai)).
* Fix a race between `ALTER TABLE` and `RENAME TABLE` / `EXCHANGE TABLES`. [#103044](https://github.com/ClickHouse/ClickHouse/pull/103044) ([Nikolay Degterinsky](https://github.com/evillique)).
* Fix `BACKUP` of `EmbeddedRocksDB` tables. Previously only the table metadata was stored in the backup and the actual data was silently dropped, so `RESTORE` produced an empty table. The backup now includes all key-value pairs and restores them correctly. [#109327](https://github.com/ClickHouse/ClickHouse/pull/109327) ([Groene AI](https://github.com/groeneai)).
* Fix `toStartOfWeek` and `toLastDayOfWeek` with a Sunday-first week mode returning a wrapped day number for a `Date32` value outside the representable calendar, for example after `toDate32('1970-01-01') + INTERVAL 2147483647 DAY`. The week boundary is now computed at the calendar boundary, consistently with the Monday-first week modes. [#111923](https://github.com/ClickHouse/ClickHouse/pull/111923) ([Groene AI](https://github.com/groeneai)).
* Fixed `mergeTreeCodecBlockCounts` disclosing whether a source table exists, and even its engine type, to a user without any privilege on that table. Resolving the table function, for example with `DESCRIBE`, now checks access before consulting the catalog. [#116647](https://github.com/ClickHouse/ClickHouse/pull/116647) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Messages of the PostgreSQL wire protocol are now parsed within their declared size, so a malformed message can no longer make the server allocate memory for a payload that never arrives. [#116998](https://github.com/ClickHouse/ClickHouse/pull/116998) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed `CREATE TABLE dst AS src` copying the schema of an `ENGINE = Alias` table's target for a user who holds `SHOW COLUMNS` on the alias but no privilege on its target. The statement now requires table-level `SHOW COLUMNS` on the target, matching `DESCRIBE` of that target. [#117702](https://github.com/ClickHouse/ClickHouse/pull/117702) ([Groene AI](https://github.com/groeneai)).
* Fixed the query condition cache serving a "no matching rows" verdict to a query that differs from the cached one only in a setting that changes how a function evaluates, such as the `formatdatetime_*` / `parsedatetime_*` settings or `function_locate_has_mysql_compatible_argument_order`, which silently dropped all matching rows. [#117803](https://github.com/ClickHouse/ClickHouse/pull/117803) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed a `CAST AS Tuple can only be performed between tuple types or from String` error, and silently wrong results for a `Tuple(String, ...)` key, when a `MergeTree` sorting, partition or skip-index key wraps a single `Tuple`-typed column in a deterministic function (for example `ORDER BY toString(k)`) and the query filters that column with `k IN (tuple(...))`, `k NOT IN (tuple(...))` or a multi-column subquery set. [#118899](https://github.com/ClickHouse/ClickHouse/pull/118899) ([Groene AI](https://github.com/groeneai)).
* Fix queries that use a higher-order function together with `ARRAY JOIN`: a lambda that captures nothing is no longer moved across the `ARRAY JOIN` step away from the function that applies it. [#119186](https://github.com/ClickHouse/ClickHouse/pull/119186) ([Yarik Briukhovetskyi](https://github.com/yariks5s)).
* Fix `TYPE_MISMATCH` in the selectivity estimator when a predicate on a `DateTime64` column uses an unconvertible string literal. Closes [#119126](https://github.com/ClickHouse/ClickHouse/issues/119126). [#119265](https://github.com/ClickHouse/ClickHouse/pull/119265) ([Han Fei](https://github.com/hanfei1991)).
* Fix unstable ordering of equal sorting keys during inserts, which could cause `CollapsingMergeTree` to retain stale rows when cancellation and replacement rows were inserted together with `optimize_on_insert` enabled, and `ReplacingMergeTree` to retain the wrong row when versions were equal. [#119474](https://github.com/ClickHouse/ClickHouse/pull/119474) ([Anton Kovalenko](https://github.com/antonkovalenko)).
* Fixed cleartext credentials in `system.asynchronous_insert_log.query`. Secrets of table functions such as `s3`, `url` or `mysql` are now masked as `[HIDDEN]`, the same way `system.query_log` masks them. [#119487](https://github.com/ClickHouse/ClickHouse/pull/119487) ([Sema Checherinda](https://github.com/CheSema)).
* Fix a crash when reading a table with active lightweight updates whose sorting key contains a column that is missing in the data part and has a `DEFAULT` expression. [#119540](https://github.com/ClickHouse/ClickHouse/pull/119540) ([Groene AI](https://github.com/groeneai)).
* Fixed Keeper replaying its local changelog tail one entry at a time after a restart when the changelog is stored on object storage. The commit read-ahead used to discard its own prefetched entries whenever it missed the serve deadline, so on storage slower than that deadline it could never catch up and every entry cost two object reads. The default of `log_readahead_commit_window_bytes` is now 16 MiB instead of 500 MiB, since it bounds a prefetch window rather than a cache. [#119627](https://github.com/ClickHouse/ClickHouse/pull/119627) ([Shaohua Wang](https://github.com/tiandiwonder)).
* Fix unbounded memory growth from time zone names of the form `libc:`. These are internal interfaces of the `cctz` library that ClickHouse never intended to expose: any suffix was accepted, each distinct name permanently cost ~4.6 MiB that the server never gave back, and the time zone silently behaved as UTC instead of the name being reported as unknown. They are rejected now. [#119634](https://github.com/ClickHouse/ClickHouse/pull/119634) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fix incorrect pruning for space-filling-curve indexes with `UInt64` arguments. [#119663](https://github.com/ClickHouse/ClickHouse/pull/119663) ([Minh Vu](https://github.com/fallintoplace)).
* Fixed `sum(x + 1) OVER (...)` returning a single row holding the overall total instead of the windowed result. `optimize_arithmetic_operations_in_aggregate_functions`, which is enabled by default, rewrote the windowed `sum` into `sum(x) + 1 * count(x)`, an expression over plain aggregates that cannot carry the `OVER` clause, so the window definition was discarded. Both `enable_analyzer = 1` (the default) and `enable_analyzer = 0` were affected. [#119699](https://github.com/ClickHouse/ClickHouse/pull/119699) ([Groene AI](https://github.com/groeneai)).
* Fix `substringUTF8` returning too many code points when a negative offset starts before the beginning of a string. [#119840](https://github.com/ClickHouse/ClickHouse/pull/119840) ([Minh Vu](https://github.com/fallintoplace)).
* Fix `URLHierarchy`, `URLPathHierarchy`, and `URLHash` failing to recognize valid URL schemes containing `a`, `z`, `0`, or `9`. [#119844](https://github.com/ClickHouse/ClickHouse/pull/119844) ([Minh Vu](https://github.com/fallintoplace)).
* Fix `mapSubtract` subtracting duplicate keys in its first argument. [#119845](https://github.com/ClickHouse/ClickHouse/pull/119845) ([Minh Vu](https://github.com/fallintoplace)).
* Fixed the server not validating the schema of the second and subsequent data blocks that a client sends for an external table over the `Native` protocol. Such a block could make the data be interpreted as a type other than the one it was sent as. [#119849](https://github.com/ClickHouse/ClickHouse/pull/119849) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed AST formatting of the `APPLY` column transformer: a column-name prefix containing a single quote or a backslash, or a function name that needs back-quoting, was emitted without escaping, so `formatQuery` returned a query that either could not be parsed or parsed back to a different query. [#119851](https://github.com/ClickHouse/ClickHouse/pull/119851) ([Groene AI](https://github.com/groeneai)).
* Fixed a crash of the server caused by a table with `ENGINE = NATS` whose credentials the broker started to reject, for example after a password rotation or on an expired token. Such a table now recreates its connection and resumes consuming once the credentials are accepted again, instead of staying silently idle. [#119853](https://github.com/ClickHouse/ClickHouse/pull/119853) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed `timeSeriesTagsToMap` treating `FixedString` tag names and values differently between the array form and the separate-argument form. `FixedString` padding is now trimmed consistently, so the same logical tags produce the same map and lookups such as `mapContains(..., 'a')` work in both forms. [#119859](https://github.com/ClickHouse/ClickHouse/pull/119859) ([Minh Vu](https://github.com/fallintoplace)).
* Fixed wrong results when `join_algorithm = 'direct'` reads the right-hand table of a join from a `MergeTree` table and plan-based parallel replicas (`parallel_replicas_plan_based = 1`) are enabled. Such a join could silently return only part of the rows that should have matched, with no error reported. The lookup read that the join performs is no longer distributed across replicas. [#119861](https://github.com/ClickHouse/ClickHouse/pull/119861) ([Groene AI](https://github.com/groeneai)).
* Fixed data loss where a `MergeTree` part whose `columns.txt` was left empty (zero bytes) by an interrupted metadata rewrite was detached as broken on load, discarding all of its rows. For a wide part the column list is now rebuilt from the part's own `columns_substreams.txt` and the table metadata, as it already was for an absent `columns.txt`; when the rebuilt list cannot be validated, the part is left untouched for recovery instead. [#111597](https://github.com/ClickHouse/ClickHouse/pull/111597) ([Groene AI](https://github.com/groeneai)).
* Integers in the `TSV`, `TSVRaw`, `TSKV` and `CustomSeparated` formats can now be zero-padded (`007`) or carry a redundant leading `+` (`+7`), spellings that previously failed to parse but that `CSV` already accepted. The same reader serves other conversions from text to an integer, so `WHERE i = '007'` on a numeric column, query parameters and `CAST('[007]' AS Array(Int64))` accept them too. A field that is a lone `+` remains an error, now reported as `CANNOT_PARSE_NUMBER` on every one of these routes instead of a route-specific code. Schema inference is unchanged: `007` still infers as `String`. [#113910](https://github.com/ClickHouse/ClickHouse/pull/113910) ([Groene AI](https://github.com/groeneai)).
* Fixed permanent data loss in `ALTER TABLE ... EXECUTE remove_orphan_files` on `Iceberg` tables with `iceberg_use_version_hint = 1`. When `metadata/version-hint.text` named an older version than the newest committed metadata file, every object of the newer committed snapshot, including its data files, was deleted as an orphan. Reachability is now computed from the authoritative current metadata, and a metadata listing this command cannot order unambiguously is refused instead of resolved by listing order. [#114324](https://github.com/ClickHouse/ClickHouse/pull/114324) ([Groene AI](https://github.com/groeneai)).
* Fix buffer overflows and a server abort on malformed responses from external servers: an Azure Blob Storage endpoint that returns more data than was requested or omits the `ETag` header, and a `MySQL` server that returns an oversized `BIT` value. `Azure` reads, copies and deletes, and `S3` copies made by backups and by `S3Queue` post-processing, are now pinned to the object generation they selected, so an object overwritten in place is reported instead of silently mixing two generations. Also fix the decoding of a `MySQL` `BIT` value shorter than 8 bytes on big-endian hosts. [#115706](https://github.com/ClickHouse/ClickHouse/pull/115706) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed a crash inside the crash handler itself when a fatal signal arrives during startup of `clickhouse-server`, `clickhouse-keeper` or `clickhouse-local`. The handler dereferenced the global context, which does not exist yet at that point, so right after logging the stack trace it took a second fault, hung for about five minutes, and never sent the configured crash report. [#116245](https://github.com/ClickHouse/ClickHouse/pull/116245) ([Groene AI](https://github.com/groeneai)).
* Fixed `CLEAR COLUMN` silently leaving a `MATERIALIZED` column derived from the cleared column at its old value. This happened whenever the mutation had already built a stage before the recompute was appended: another pending mutation coalescing with the `CLEAR` into one pass, which needs no special settings, or an enabled `enable_block_number_column` / `enable_block_offset_column`. The wrong value was permanent; later merges did not repair it. [#117296](https://github.com/ClickHouse/ClickHouse/pull/117296) ([Shaohua Wang](https://github.com/tiandiwonder)).
* Fixed `ILIKE` on a `text` index returning rows the predicate does not match, and skipping rows it does match, when the pattern or the data contains a non-ASCII code point that case-folds onto an ASCII letter. Affected indexes with a `lowerUTF8`/`upperUTF8` preprocessor and patterns whose needle contains `k`. [#117354](https://github.com/ClickHouse/ClickHouse/pull/117354) ([Jimmy Aguilar Mena](https://github.com/Ergus)).
* Fixed wrong results in five cases where a `WHERE` predicate on a join key was pushed to the other side of a `JOIN` whose two keys have different types. Such a key is no longer substituted when the keys' common type is a float, because `-0.0` and `+0.0` are join-equal but differ bit for bit; nor when it is `Dynamic` or `JSON`, whose runtime contents the static type does not describe; nor when the key is unstable within the query or changes the row count; nor in a conjunct that reads a column's representation rather than its value, as `isConstant` and `toColumnTypeName` do, including when such a read or an unstable function is hidden inside a lambda body. Separately, with `enable_analyzer = 1`, a predicate on the wider of two differently typed join keys is now also used as an index condition on the other table of a plain `INNER JOIN`, so it is read through its primary key instead of in full; previously only `ANY INNER JOIN`, `LEFT JOIN` and `RIGHT JOIN` got this. [#117973](https://github.com/ClickHouse/ClickHouse/pull/117973) ([Groene AI](https://github.com/groeneai)). Also fixed a `LOGICAL_ERROR` (`Unexpected return type from _CAST`) when such a predicate was pushed down to a side that `join_use_nulls` widens to `Nullable`. [#120109](https://github.com/ClickHouse/ClickHouse/pull/120109) ([Groene AI](https://github.com/groeneai)).
* Fix rows silently dropped by index analysis for `has(array_of_named_tuples, key)` when the tuple fields are declared in another order and the key is a function of the column. [#118706](https://github.com/ClickHouse/ClickHouse/pull/118706) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fixed ClickHouse Keeper returning `ZNOAUTH` for every request on a node whose ACL list is empty but is stored under a nonzero internal ACL id, which happens for Keeper data converted from a ZooKeeper snapshot or written by a very old Keeper. Such nodes are unrestricted again, as they were before 26.6. Closes [#117603](https://github.com/ClickHouse/ClickHouse/issues/117603). [#118965](https://github.com/ClickHouse/ClickHouse/pull/118965) ([Groene AI](https://github.com/groeneai)).
* Fixed `YYYYMMDDhhmmssToDateTime64` returning incorrect fractional seconds for timestamps before 1970-01-01. [#119240](https://github.com/ClickHouse/ClickHouse/pull/119240) ([Raúl Marín](https://github.com/Algunenano)).
* Fixed a crash when a disk is configured with `metadata_type = web` or `metadata_type = web_index` on top of a non-web object storage. Such a configuration is now rejected with `INVALID_CONFIG_PARAMETER` instead of interpreting an unrelated object storage as a web one. Closes [#119798](https://github.com/ClickHouse/ClickHouse/issues/119798). [#119818](https://github.com/ClickHouse/ClickHouse/pull/119818) ([Groene AI](https://github.com/groeneai)).
* `Iceberg` tables recovered from stored metadata no longer enable background compaction or old-file cleanup unless those settings are explicitly stored in the table definition. [#119977](https://github.com/ClickHouse/ClickHouse/pull/119977) ([János Benjamin Antal](https://github.com/antaljanosbenjamin)).
* Fixed a `NATS` table whose settings all come from a named collection (`ENGINE = NATS(collection)` with no `SETTINGS` clause) being written to its metadata file with a dangling `SETTINGS` keyword. The stored definition could not be parsed again, so the table failed to load and aborted the load of its whole database, making unrelated tables in it inaccessible. Closes [#119120](https://github.com/ClickHouse/ClickHouse/issues/119120). [#120025](https://github.com/ClickHouse/ClickHouse/pull/120025) ([Groene AI](https://github.com/groeneai)).
* Fixed non-idempotent formatting of a function named `SOME`: the name was printed unquoted, so the server read its own output back as the `SOME` array quantifier. `formatQuery('SELECT 1 < SOME(a, b -> 1)')` returned a query that re-parses to `arrayExists`, and a user-defined function whose body compared against `` `some`(...) `` was persisted without the quotes and then failed to load after a restart. [#120096](https://github.com/ClickHouse/ClickHouse/pull/120096) ([Groene AI](https://github.com/groeneai)).
* Fix reading a column that has two streams whose names differ only by escaping, for example a `Tuple` element named `size0` inside an `Array`, or a typed `JSON` path named like a substream of a sibling path. Such columns returned wrong values, failed with `CANNOT_READ_ALL_DATA` or another exception, and made the table unmergeable. [#115670](https://github.com/ClickHouse/ClickHouse/pull/115670) ([Pavel Kruglov](https://github.com/Avogar)).
* Fix `least`, `greatest`, `bitShiftRight`, `midpoint`, and `avg2` returning wrong results when a JIT-compiled expression has an `Int128` result. With the default `compile_expressions = 1`, a negative `Int128` result could be treated as unsigned after a few executions. [#118363](https://github.com/ClickHouse/ClickHouse/pull/118363) ([Groene AI](https://github.com/groeneai)).
* Fix `ttl_only_drop_parts` preventing expired columns from ever being cleared. A column `TTL` requires rewriting the part, so with this setting enabled an expired column could be kept forever instead of being cleared. Column-`TTL` rewrites are now scheduled separately and still run when `ttl_only_drop_parts` is enabled. [#118428](https://github.com/ClickHouse/ClickHouse/pull/118428) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Fix `mergeTreeTextIndex` bypassing row policies: reading the text index is now denied whenever a row policy applies to the table, regardless of which columns the policy uses. [#119032](https://github.com/ClickHouse/ClickHouse/pull/119032) ([Elmi Ahmadov](https://github.com/ahmadov)).
* Fix `force_primary_key` incorrectly rejecting some queries with `INDEX_NOT_USED` when `optimize_extract_common_expressions` (enabled by default) simplifies the filter to a trivial primary-key condition wrapped in an implicit cast. [#119083](https://github.com/ClickHouse/ClickHouse/pull/119083) ([kasimtj](https://github.com/kasimtj)).
* Fix `groupNumericIndexedVector` returning a value that is too large when an index repeats in the input, and returning different results depending on `max_threads`. Also fix `numericIndexedVectorPointwiseMultiply` and `numericIndexedVectorPointwiseDivide` dropping zero-valued indices, and `numericIndexedVectorPointwiseDivide` by a vector of all ones keeping the value of an index the divisor is missing instead of zeroing it. A `groupNumericIndexedVectorState` already stored in a table is not repaired by the upgrade and has to be recomputed. [#119564](https://github.com/ClickHouse/ClickHouse/pull/119564) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* `isNull` and `IS NULL` now return `1` for every `NULL` row, including when the column's NULL mask holds a byte other than `0` or `1`, which the `Native` format permits and which `if` can produce from its condition column. Previously such a row could contribute its raw byte, so `sum(isNull(e))` returned `30` where `20` is correct. `if(cond, x, NULL)` with a `Nullable` `x` no longer returns `NULL` for a row whose condition byte was neither `0` nor `1`. If an older server stored a value computed from `isNull` on such a column (sorting key, skip index, partition key, projection, `MATERIALIZED` or `DEFAULT` column), rebuild it. [#119785](https://github.com/ClickHouse/ClickHouse/pull/119785) ([Groene AI](https://github.com/groeneai)).
* Preserve explicit time zones in `timeSeriesRange` `DateTime64` results. [#119858](https://github.com/ClickHouse/ClickHouse/pull/119858) ([Minh Vu](https://github.com/fallintoplace)).
#### Build/Testing/Packaging Improvement
* Added a CMake file for compiling ClickHouse with the `nvcc` compiler. Related: [#116807](https://github.com/ClickHouse/ClickHouse/issues/116807). [#117734](https://github.com/ClickHouse/ClickHouse/pull/117734) ([Konstantin Vedernikov](https://github.com/scanhex12)). Added the `cudf` contrib library. [#117869](https://github.com/ClickHouse/ClickHouse/pull/117869) ([Konstantin Vedernikov](https://github.com/scanhex12)).
* Added a build option to select 4 KiB or 16 KiB jemalloc page size on AArch64 instead of the default 64 KiB. [#115424](https://github.com/ClickHouse/ClickHouse/pull/115424) ([Azat Khuzhin](https://github.com/azat)).
* Fixed several portability issues on `illumos`, including missing `termios.h`, register-macro conflicts, and floating-point environment casts. [#117363](https://github.com/ClickHouse/ClickHouse/pull/117363) ([Joshua Carp](https://github.com/jmcarp)).
* ClickHouse is now built as a position independent executable on Linux amd64 and aarch64 with glibc, including the release builds, so the text segment is subject to ASLR. Addresses in the bare stack trace of a fatal log are now file offsets relative to the object that contains them, annotated with that object for frames outside the main executable, so they can be resolved with `addr2line -e