Skip to content

Test image: adaptive aggregator rewrite backport and distributed read of object storage (do not merge) - #2889

Draft
arthurpassos wants to merge 15 commits into
antalya-26.8from
feature/antalya-26.8/adaptive-aggregator-and-distributed-read
Draft

arthurpassos wants to merge 15 commits into
antalya-26.8from
feature/antalya-26.8/adaptive-aggregator-and-distributed-read

Conversation

@arthurpassos

Copy link
Copy Markdown
Collaborator

Test pull request to get a CI image for the vig-test dev cluster. It is not meant to be merged as it is: if the benchmark confirms the results, it will be split into two pull requests that each target antalya-26.8.

It contains two changes:

  1. A backport of the upstream adaptive aggregator rewrite Faster Adaptive Aggregator ClickHouse/ClickHouse#123531 to 26.8, together with the changes it builds on: Nullable keys in the adaptive aggregator Use the adaptive aggregator for GROUP BY over Nullable keys whose hash method packs the null map into the key ClickHouse/ClickHouse#124868, and the removal of the sharded aggregator Remove the sharded aggregator in favor of the adaptive aggregator ClickHouse/ClickHouse#116532 (enable_sharding_aggregator becomes an obsolete setting). On one node, q12 of the Iceberg benchmark (100M rows, 7 Nullable(String) keys) goes from 10.8 s to 4.9 s with less memory and no spill. The query plan serialization version goes from 10 to 11.
  2. The serialization and the bucketed distributed read of ReadFromObjectStorageStep, which were compiled out of this build (CLICKHOUSE_CLOUD), so make_distributed_plan can run a GROUP BY over an Iceberg table with a shuffle aggregation across nodes. It is experimental and off by default.

Not done in this pull request: the Iceberg snapshot is not pinned across workers, there are no tests for the new serialization, and the workload spilling integration of the upstream change is left out.

Related: https://github.com/Altinity/iceberg-bench/blob/main/BENCHMARK.md

Changelog category (leave one):

  • Performance Improvement

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

Backport the faster adaptive GROUP BY aggregator (enable_adaptive_aggregator) from upstream: it now supports Nullable keys and spills staged records per bucket. Make the read of Iceberg and other object storage tables usable in a distributed query plan (make_distributed_plan, experimental).

Documentation entry for user-facing changes

...

CI/CD Options

Exclude tests:

  • Fast test
  • Integration Tests
  • Stateless tests
  • Stateful tests
  • Unit tests
  • Performance tests
  • Aarch64 tests
  • All with ASAN
  • All with TSAN
  • All with MSAN
  • All with UBSAN
  • All with Coverage
  • All Regression
  • Disable CI Cache

Regression jobs to run:

  • Fast suites (mostly <1h)
  • Aggregate Functions (2h)
  • Alter (1.5h)
  • Benchmark (30m)
  • CAS (content-addressed storage; Antalya only)
  • ClickHouse Keeper (1h)
  • Iceberg (2h)
  • LDAP (1h)
  • OAuth (5m)
  • Parquet (1.5h)
  • RBAC (1.5h)
  • SSL Server (1h)
  • S3 (2h)
  • S3 Export (2h)
  • Swarms (30m)
  • Tiered Storage (2h)

Backport `Faster Adaptive Aggregator` (ClickHouse#123531) with the changes it builds on:
- the `Nullable` key support of the adaptive aggregator (ClickHouse#124868);
- the removal of the sharded aggregator in favor of the adaptive one (ClickHouse#116532);
  `enable_sharding_aggregator` becomes an obsolete setting.

The core aggregation files keep the 26.8 side, and only the adaptive aggregator part of the change is applied:
- add the per-table aggregator tracker helpers (`switchToOwnTracker`, `aggregatorTracker`) and `Aggregator::spill`;
- add `keep_table_buffer` to the bucket conversions and the finalized-rank (`uniqExact`, `uniqExactIf`) bucket Top-K conversion;
- add `RowStorePointers`, `IColumn::fillFromRowStorePtrs` and `ColumnNullable::fillFromRowStorePtrs`, which the staged arguments use;
- drop what 26.8 has no counterpart for: the workload spilling integration, `min_bytes_before_external_group_by`, the `all_places_are_non_null` batches;
- the query plan serialization version goes from 10 to 11 for the `adaptive_aggregator_disable_thaw` plan setting;
- remove the tests of features 26.8 does not have (funnel functions, workload spilling) and the hash join row store part of
  `05332_adaptive_aggregator_argument_gather`.

On one node, q12 of the Iceberg benchmark (100M rows, 7 `Nullable(String)` keys) goes from 10.8 s to 4.9 s, with less peak memory and no spill.
The serialization and the distributed read of `ReadFromObjectStorageStep` were compiled out of this build (`CLICKHOUSE_CLOUD`), so
`make_distributed_plan` refused every plan with an exchange over an object storage table (for example a `GROUP BY` over an Iceberg table).

- serialize the step as the table name, the columns, the row level filter, the prewhere and the block and stream sizes, and rebuild it on the worker
  with `IStorage::read`, applying the prewhere as the pruning filter;
- split the files into buckets by the hash of their identifier: the task of a bucket reads only its files (`bucket_id` task parameter);
- register the step, and let the planner distribute the read when the table is big enough (`totalRows`).

(cherry picked from commit ab07b64da17d1f3c857b2ebd46ceb440ff703f07)
…entries of this change

The squashed backport carried stale entries of an older layout of the `26.8.27.20001.altinityantalya` block. Restore the history of
`antalya-26.8` and add `adaptive_aggregator_disable_thaw` and the obsolete `enable_sharding_aggregator` to the newest Antalya block.
@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

Workflow [PR], commit [0d36945]

- Drop the bucket-local Top-K when the aggregation goes in order, as the upstream change does: the in-order pipeline has no two-level
  conversion to run it in (`05385_aggregation_bucket_top_k_in_order`).
- The `clickhouse-local` of this build does not print the error of a failed query with `--ignore-error`, so
  `05415_adaptive_aggregator_staged_spill_free_space` and `05448_adaptive_aggregator_staged_spill_append_free_space` read no error from it.
  Run the failing query without the option. The check that no staged record was written before the error of `05415` needs the query to go on
  after the error, so it is dropped.
… have

`05334_row_store_bulk_fixed_columns` sets `min_rows_ratio_for_hash_join_row_store`, a setting of the hash join row store that was not backported.
- `gtest_aggregator_adaptive_merge`: `Aggregator::Params` has no `min_bytes_before_external_group_by` in this build.
- `gtest_growing_count_top_k`: `PackedStringRefHash` does not exist here, so the test declares the default string-view hash itself.

CI build failure: the `unit_tests_dbms` target of the `Build ClickHouse` job (PR 2889).
The push of 37a903c did not start the `PR` workflow.

Signed-off-by: Arthur Passos <arthur.ti@outlook.com>
…ya-26.8/adaptive-aggregator-and-distributed-read

# Conflicts:
#	src/Common/FailPoint.cpp
The profile event `JoinBuildRowStoreMicroseconds` belongs to the hash join row store, which this build does not have, so the sanitizer build failed to link `clickhouse` with an undefined symbol. The adaptive aggregator only uses `RowDataStore::gatherFieldToRows`.

Signed-off-by: Arthur Passos <arthur.ti@outlook.com>
…ggregate_merge_work`

The variadic `uniqExact` of this build has no preparation step of the parallel merge: it came with ClickHouse#117153, which was not backported.
CI: `AggregateMergeWork.VariadicAndTupleArguments` of `Unit tests (asan_ubsan)`, pull request 2889.

Signed-off-by: Arthur Passos <arthur.ti@outlook.com>
arthurpassos and others added 5 commits November 23, 2026 13:47
…` when the pipeline is built

The sets of an `IN` in the PREWHERE are placeholders until `QueryPlan::makeSets` resolves them,
and `buildSetsForDAGExcludingGlobalIn` dereferenced the null set when `deserialize` applied the filter,
so a distributed-plan task with such a filter killed the server (signal 11).
Throw an exception instead of dereferencing a null set.

Signed-off-by: Arthur Passos <arthur.ti@outlook.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
…NAL`

A worker has no query, so `SelectQueryInfo::isFinal` dereferenced the missing AST when `optimizePrewhere`
looked at a filter over a deserialized read that had no PREWHERE, and the server crashed (signal 11).

Signed-off-by: Arthur Passos <arthur.ti@outlook.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
…ya-26.8/adaptive-aggregator-and-distributed-read

Signed-off-by: Arthur Passos <arthur.ti@outlook.com>
Co-authored-by: Cursor <cursoragent@cursor.com>

# Conflicts:
#	src/Interpreters/AdaptiveAggregationKernels.cpp
…he adaptive aggregator

The merge of `antalya-26.8` added the argument. The merge drain passes places that are never null, and the staged records of the producer can have null places for misses.
The edit was left out of the merge commit `1009d3ee1f7`, which failed to build.

Signed-off-by: Arthur Passos <arthur.ti@outlook.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
I, Arthur Passos <arthur.ti@outlook.com>, hereby add my Signed-off-by to this commit: 8c97b9f
I, Arthur Passos <arthur.ti@outlook.com>, hereby add my Signed-off-by to this commit: 8fda08b
I, Arthur Passos <arthur.ti@outlook.com>, hereby add my Signed-off-by to this commit: 1d7574f
I, Arthur Passos <arthur.ti@outlook.com>, hereby add my Signed-off-by to this commit: d196859
I, Arthur Passos <arthur.ti@outlook.com>, hereby add my Signed-off-by to this commit: 18a6f2f
I, Arthur Passos <arthur.ti@outlook.com>, hereby add my Signed-off-by to this commit: 37a903c

Signed-off-by: Arthur Passos <arthur.ti@outlook.com>
Co-authored-by: Cursor <cursoragent@cursor.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants