Skip to content

Antalya 26.6: add UniqApacheHLL - #2398

Open
UnamedRus wants to merge 24 commits into
antalya-26.6from
feature/antalya-26.6/uniq-apache-hll
Open

UnamedRus wants to merge 24 commits into
antalya-26.6from
feature/antalya-26.6/uniq-apache-hll

Conversation

@UnamedRus

@UnamedRus UnamedRus commented Sep 17, 2026 •

Copy link
Copy Markdown
Collaborator

Changelog category (leave one):

  • New Feature

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

Aggregate function, which states are compatible with apache data sketches HLL implementation

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)

@github-actions

github-actions Bot commented Sep 17, 2026 •

Copy link
Copy Markdown

Workflow [PR], commit [1bfd0e1]

UnamedRus and others added 2 commits September 17, 2026 15:15
Backport of ClickHouse/ClickHouse@a067567, re-created
here rather than cherry-picked so that it carries a sign-off.

The submodule tracked `apache/datasketches-cpp` directly, pinned to `76edd74f`
(2024-05-16), an upstream development commit. It moves onto a `ClickHouse/`-prefixed
branch of our fork, the way `docs/development/contrib` asks:

    ClickHouse/datasketches-cpp, branch ClickHouse/5.2.0
      de8553ba  5.2.0, the newest upstream release (2025-01-15)
      23bd9b07  backport of apache/datasketches-cpp#512

apache/datasketches-cpp#512 is the HyperLogLog union fix. No upstream release carries
it, so it is cherry-picked onto the `5.2.0` tag there. `uniqApacheHLL`, added next,
needs it: without it a merged HLL sketch reports a wrong estimate and serializes a
state that other DataSketches implementations read differently.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Signed-off-by: UnamedRus <dtitmoav@gmail.com>
…tion

Ported from `vk/uniq-apache-hll` (github.com/UnamedRus/ClickHouse), which develops the
function against `master`.

`uniqApacheHLL` counts distinct values into an Apache DataSketches HLL sketch, and its
`-State` serializes that sketch in the DataSketches format, so states can be exchanged
with Java, Python and C++ services through the standard `-State`/`-Merge` combinators.
Only the argument types those libraries hash the same way are accepted - integers of at
most 64 bits, Enum8/16, BFloat16, Float32/64, String, FixedString, UUID, IPv4, IPv6,
Date, Date32, DateTime and DateTime64 - so no state can be built here that an external
consumer cannot reproduce.

Two deviations from the branch this is taken from, both forced by the age of this base:

  - the state overrides `merge`, not `mergeImpl`. `IAggregateFunction::merge` is still
    the pure virtual here; the split into a non-virtual `merge` plus a `mergeImpl`
    override came later.
  - `introduced_in` says 26.6 rather than 26.9, this being the release it ships in.

NOT BUILT OR TESTED on this base - only ported and checked by inspection against the
26.6 headers. CI is the first real build.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Signed-off-by: UnamedRus <dtitmoav@gmail.com>
@UnamedRus
UnamedRus force-pushed the feature/antalya-26.6/uniq-apache-hll branch from 3c1bcdb to 8cd0586 Compare September 17, 2026 12:16
@alsugiliazova alsugiliazova mentioned this pull request Sep 24, 2026
9 of 30 tasks
@svb-alt
svb-alt requested a review from zvonand September 28, 2026 16:19
@DimensionWieldr

This comment was marked as outdated.

@zvonand zvonand changed the title Feature/antalya 26.6/uniq apache hll Antalya 26.6: add UniqApacheHLL Sep 29, 2026
Reuse `assertUnary`, consolidate state handling, and shorten repetitive
comments and documentation. Merge overlapping HLL tests while retaining
interoperability, cross-resolution, corruption, and dependency coverage.

Use the canonical `Enum` documentation type to avoid a logical-error
exception when reading `system.functions`.

Validation: rebuilt ClickHouse and passed all four remaining PR tests
with the pinned DataSketches revision; no tests skipped.

Related: #2398
@zvonand

zvonand commented Sep 30, 2026

Copy link
Copy Markdown
Member

@blau-ai

@zvonand

zvonand commented Sep 30, 2026

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-30T08:50:26.470323Z 9c9c7fb Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@blau-ai

blau-ai commented Sep 30, 2026

Copy link
Copy Markdown
Collaborator

CI triage — @zvonand

Verdict: Only one class of failure is caused by this PR, and it's the expected one — the regression suite noticing the new function isn't covered yet. Everything else is pre-existing / flaky / infra. Nothing points to a bug in the uniqApacheHLL implementation: the PR's own tests (04327, 05026, 05055, 05136) all passed, and every functional/build/unit/integration job for the core code is green.

Head SHA analyzed: 9c9c751 (9c9c7fbb49f510a5ecd72c41c14ab5952d1d4d58).


🔴 PR-caused (1 root cause — action needed, but not in this repo)

Regression … aggregate_functions_1 — fails on every variant (release + aarch64, plain / cas / cas_s3_cache). All share one message:

Aggregate function 'uniqApacheHLL' was added, but not tested.
/aggregate functions/part 1/function_list/untested function uniqApacheHLL → Fail

This is the Altinity clickhouse-regression function_list guard: it asserts that every aggregate function reported by system.functions is present in the suite's known/tested list. Adding uniqApacheHLL (registered at AggregateFunctionUniqApacheHLL.cpp:128) trips it by design.

Fix: add uniqApacheHLL to the aggregate-function list (and, ideally, a small coverage test) in the clickhouse-regression repo — not in this PR. This is a separate repository I don't have write access to, so a human needs to open that PR. Once the function is listed there, all aggregate_functions_1 variants go green. No change is required to the ClickHouse code in this PR.


🟡 Not PR-caused — pre-existing / flaky / infra (safe to re-run or ignore)

Stateless tests — all failures are unrelated to aggregate functions and are confirmed transient by CI's own auto-rerun:

Suite Test CI rerun verdict
amd_msan WasmEdge 2/4 03572_export_merge_tree_part_limits_and_table_functions All reruns passed — not reproducible
amd_debug distributed s3 03572_export_merge_tree_part_limits_and_table_functions All reruns passed — not reproducible
amd_tsan cas s3 1/2 03913_…statistics, 03164_materialize_skip_index_on_merge, 03100_lwu_23_apply_patches, 04049_tuple_inside_nullable_…, 02346_text_index_partially_materialized All reruns passed — not reproducible
amd_tsan cas s3 1/2 04661_refreshable_mv_cancel_during_planning flaky (1/5 reruns failed)
arm_asan_ubsan azure 02354_vector_search_rescoring_distance_in_select_list fails 3/3 — small BFloat16 distance rounding diff (0.203125 vs 0.1875); vector-search FP precision on ARM, no overlap with this PR

Stress test (amd_asan_ubsan, cas s3 storage) — Cannot start clickhouse-server / Check failed. Server-startup/infra failure in the cas-s3 stress variant; all other 15 stress variants (incl. amd_asan_ubsan plain) are green → infra/flaky, not code.

Integration tests (arm_binary, distributed plan, 3/4) — ERROR: Failed to pre-pull Docker images needed by the test batch. Pure infra; the other 3/4 shards passed. Safe to re-run.

Grype Scan (keeper + server-alpine) — CVE-2026-85091 (High) flagged in the base image. Decisive tell: the keeper image contains none of this PR's aggregate-function code yet fails identically → it's a base-image CVE, pre-existing across the branch, not introduced here.

Other regression suites — cas_alter_attach_3, cas_lightweight_delete_4, cas_s3_cache_lightweight_delete_4, cas_selects, s3_azure_1, settings, swarms. These cover SELECT FINAL concurrency, lightweight delete, ALTER ATTACH, S3/Azure, an iceberg setting default (iceberg_manifest_min_count_to_compact AssertionError), swarms, etc. — feature areas with zero code overlap with a single new aggregate function. Spot-checked reports show generic AssertionErrors / timeouts / errored features typical of the branch's regression baseline. Pre-existing noise on antalya-26.6, not caused by this PR.


TL;DR

  • PR-related: aggregate_functions_1 regression only — expected; fix by registering uniqApacheHLL in the clickhouse-regression suite (separate repo, needs a human).
  • Everything else (other regression suites, stateless, stress, integration pre-pull, Grype): pre-existing / flaky / infra — re-run the flaky ones; the Grype CVE and the regression-baseline failures are branch-wide, not from this PR.
  • The uniqApacheHLL code itself looks healthy: its dedicated tests and all core build/functional/unit jobs are green.

🤖 Automated CI triage by @blau-ai. Evidence: praktika result_pr.json + testflows reports for 9c9c751. I can't build/run ClickHouse locally, so these are read from CI artifacts.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9c9c7fbb49

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/AggregateFunctions/AggregateFunctionUniqApacheHLL.h Outdated
Comment thread src/AggregateFunctions/AggregateFunctionUniqApacheHLL.h
…ation

- Construct `hll_union` with the requested `lg_k` instead of flooring it at 7,
  so `uniqApacheHLLMerge(4..6)` produces sketches with the requested `lg_k`.
  `hll_union` accepts `lg_max_k` in [4, 21].
- Serialize an untouched state as the library's compact empty sketch instead
  of a zero-length vector, so external DataSketches consumers can read it.

Related: #2398 (comment)
Related: #2398 (comment)
@DimensionWieldr

Copy link
Copy Markdown
Collaborator

AI audit note: This review comment was generated by AI.

Audit update for PR #2398 (uniqApacheHLL, Apache DataSketches HLL aggregate):

Confirmed defects:

Medium: Fast test and any ENABLE_LIBRARIES=0 build fail to link

  • Impact: clickhouse does not link when DataSketches is disabled. Fast test configures with -DENABLE_LIBRARIES=0, which turns off ENABLE_DATASKETCHES / USE_DATASKETCHES.
  • Anchor: src/AggregateFunctions/registerAggregateFunctions.cpp / registerAggregateFunctions; src/AggregateFunctions/AggregateFunctionUniqApacheHLL.cpp / registerAggregateFunctionUniqApacheHLL
  • Trigger: Configure with -DENABLE_LIBRARIES=0 and link the server.
  • Why defect: The call is unconditional, but the definition is compiled only under #if USE_DATASKETCHES. uniqTheta avoids this by registering inside registerAggregateFunctionUniq, which always exists. There is no #else stub here.
  • Fix direction (short): Provide an empty registerAggregateFunctionUniqApacheHLL when USE_DATASKETCHES is off.
  • Regression test direction (short): Build with -DENABLE_LIBRARIES=0 (the Fast test CMake line in ci/jobs/fast_test.py).

Medium: Empty String values are counted only when the column's character buffer is already allocated

  • Impact: Distinct count for '' changes with block layout. A block of only empty strings contributes nothing. A block that also contains a non-empty string counts '' as a distinct value. Apache DataSketches update(std::string) never records an empty string, so exchanged states disagree.
  • Anchor: AggregateFunctionUniqApacheHLL::add → HllSketchData::insertData → hll_sketch::update(const void *, size_t)
  • Trigger: Compare uniqApacheHLL on a String column of only '' with one that also contains a non-empty value (small enough to stay in coupon mode, so the count is exact).
  • Why defect: insertData forwards a zero length. update(const void *) returns only when the pointer is null, and still hashes a non-null zero-length pointer into a coupon (value is at least 1, so the coupon is not empty). ColumnString::getDataAt yields a null pointer only while chars has never been allocated (c_start == nullptr). Any non-empty value in that column allocates the buffer, so the empty row's pointer becomes non-null.
  • Fix direction (short): Skip size == 0 in insertData so an empty string is never recorded, matching hll_sketch::update(const std::string &).
  • Regression test direction (short): SELECT uniqApacheHLL(s) for [''] and for ['', 'a'] must return the same treatment of '', including when those rows arrive in separate blocks.

Coverage summary:

  • Scope reviewed: factory registration and parameter checks, type dispatch, HllSketchData insert/merge/serialize/deserialize, empty-state and lg_k < 7 fixes, DataSketches 5.2.0 HLL union backport (23bd9b07), and the four stateless tests.
  • Categories failed: optional-library link, empty-string hashing.
  • Categories passed: parameter bounds, rejected types, corrupt-state translation to CORRUPTED_DATA, empty-sketch serialization, merge resolution in [4, 21], HLL union KxQ rebuild (submodule patch), per-state ownership under normal aggregation (no shared mutable sketch).
  • Assumptions/limits: static review only; integer hashing was checked against the documented 8-byte zero-extension contract, not against update(uint32_t) sign-extension; std::llround above 2^63-1 and big-endian UUID byte order were not treated as confirmed defects.

CarlosFelipeOR added a commit to Altinity/clickhouse-regression that referenced this pull request Oct 1, 2026
uniqApacheHLL is an Antalya-only aggregate function (Altinity/ClickHouse#2398)
whose state is compatible with Apache DataSketches HLL. The suite reuses the
any checks for supported types and adds checks for rejected types, HLL
estimation mode, lg_k and HLL type parameters, empty strings, and reading an
external DataSketches state. Skipped on non-Antalya builds and before 26.6.

Snapshots are x86_64 only; aarch64 follows.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Signed-off-by: CarlosFelipeOR <carlosfelipeor@gmail.com>
@CarlosFelipeOR

Copy link
Copy Markdown
Collaborator

I added uniqApacheHLL coverage to the clickhouse-regression aggregate_functions suite (57cff3f, 25030e1). This also clears the function_list failure in the regression job. One check fails on this PR's build: uniqApacheHLL throws on an all-NULL argument instead of returning 0.

SELECT uniq(NULL), uniqTheta(NULL);  -- 0  0
SELECT uniqApacheHLL(NULL);          -- Code: 43. Illegal type Nullable(Nothing) of argument for aggregate function uniqApacheHLL

The failing checks are /aggregate functions/part 1/uniqApacheHLL/NULL for all rows and /aggregate functions/part 3/state/uniqApacheHLLState/NULL for all rows.

AI analysis: for an all-NULL argument, the factory still calls the creator with Nullable(Nothing) before the Null combinator replaces it with nothing (AggregateFunctionNull.cpp:113). uniq and uniqTheta accept any type at that step. createAggregateFunctionUniqApacheHLL throws instead. Returning an instance for argument_type.onlyNull() before the final throw should fix it.

zvonand and others added 2 commits October 1, 2026 11:12
For `Nullable(Nothing)` the factory creates the nested function before the
`Null` combinator replaces it with `nothing`, so `uniqApacheHLL(NULL)` threw
`ILLEGAL_TYPE_OF_ARGUMENT` instead of returning 0 like `uniq` and `uniqTheta`.

Merge `05026_uniq_apache_hll_interop` into `04327_uniq_apache_hll` and add the
all-NULL cases there. `05136_uniq_apache_hll_corrupted_state.sh` stays a shell
test because `CORRUPTED_DATA` is always logged with a stack trace to stderr.

#2398 (comment)
claude and others added 5 commits October 5, 2026 11:55
Once a union existed, every inserted row created a sketch, merged it into the
union and freed it. Keep inserting into the update sketch and fold it into the
union only when the state is merged, read or serialized. Merging a state that
holds both sketches now takes both without modifying it.

Include `<bit>`, `<new>` and `<exception>` for `std::byteswap`,
`std::bad_alloc` and `std::exception`.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Jim6F2cKTTpxvY82Kq8a28
… states

A fractional or negative `lg_k` was silently truncated or wrapped; it now fails
with `BAD_ARGUMENTS`. Merging an empty state no longer allocates a union.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Jim6F2cKTTpxvY82Kq8a28
…lg_k`

Return to the conversion the other `uniq*` functions use. Non-finite, out of
range and non-numeric values already fail with `CANNOT_CONVERT_TYPE`, and a
negative integer wraps and is rejected by the `[4, 21]` range check with
`ARGUMENT_OUT_OF_BOUND`. Only an in-range fraction such as `12.5` is truncated.

Drop the `12.5` test and expect `ARGUMENT_OUT_OF_BOUND` for `-1`.

Related: #2398

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…gistration

`registerAggregateFunctions.cpp` only got `USE_DATASKETCHES` transitively through
`IColumn.h`. If that include chain changed, `#if USE_DATASKETCHES` would become
false without any build error and `uniqApacheHLL` and `uniqTheta` would stop
being registered.

Related: #2398

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…le bounds check

Moves the submodule from `23bd9b07` to `4e917778`, the tip of
`ClickHouse/datasketches-cpp` branch `ClickHouse/5.2.0`. The new commit checks the
buffer size before `compact_theta_sketch_parser::parse` reads the `num_entries`
and `theta` fields, which an AST fuzzer found to read out of bounds on truncated
`uniqTheta` states: ClickHouse#119595

It does not touch the HLL code used by `uniqApacheHLL`.

Related: #2398

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@zvonand

zvonand commented Oct 5, 2026

Copy link
Copy Markdown
Member

@DimensionWieldr aggregate suite is still failing. could you pls take a look?

UnamedRus and others added 10 commits October 5, 2026 18:21
In `merge`, take `rhs.sk_update` and `rhs.sk_union` first and fold this state's own
pending `sk_update` into the union last. When `rhs` has a lower resolution than
the declared `lg_k`, the union is then created at that resolution directly,
instead of being built at `lg_k` and downsampled by `hll_union::update`. The
merged result is the same either way.

Related: #2398

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…border values

`04327_uniq_apache_hll` pins byte-exact states only for `UInt64`, `UUID`, `IPv6` and
`DateTime64(3)`. Everything else is checked by cardinality alone, so a change in how
`Float64`, `IPv4`, `Date` or `String` values are hashed would break interoperability
with other DataSketches implementations without failing any test.

The new test feeds each supported type its border values, such as the minimum and
maximum of every integer width, values at and above the sign bit of the unsigned
types, `-0`, `NaN`, infinities and denormals, `FixedString` padding, negative `Date32`
and `DateTime64`, and compares the serialized state with the bytes written by the
Apache DataSketches C++ library. It also pins the empty sketch for several `lg_k` and
storage types, the list, set and dense modes, and that types share the hash of their
underlying value.

Integers are widened by value to 64 bits, as Java `update(long)` and Python
`update(int)` do. The C++ overloads for narrow unsigned types sign-extend instead, so
a `UInt32` of `4294967295` hashes differently from `Int32` `-1`; the test pins that.

The expected output was generated by the C++ library and cross-checked against two
fixtures already in `04327_uniq_apache_hll`. It has not been run against a server.

Related: #2398

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The Apache DataSketches implementations skip empty strings: Java `update(String)`
and `update(byte[])`, the C++ `update(std::string)` (and so Python `update(str)`),
and Spark's `hll_sketch_agg`, which also ignores `NULL`. `uniqApacheHLL` counted
`''` as a value, so a sketch of data that contains empty strings differed from one
built outside ClickHouse by one value. Skip them in `add`, which also makes the
state of empty strings only the empty sketch.

`NULL` values were already ignored by the `Null` combinator. Because the function
has `returns_default_when_only_null`, that combinator writes its flag byte for
every state, even one built from `NULL` values only, so the state of a `Nullable`
argument is `0x01` followed by the ordinary sketch. Document it and pin it, together
with import of an external sketch into a `Nullable` state type and merging of
`Nullable` states, in a new test.

Related: #2398

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…etches sketch

`uniqApacheHLL` has `returns_default_when_only_null`, so the generic `Null` combinator
wrote its flag byte (always `1`) before the sketch of every `Nullable` argument. The state
of `Nullable` columns, the common case, was then not a DataSketches sketch, and an
external consumer would have had to skip the byte, or an importer to add it.

Give the function its own null adapter, `AggregateFunctionNullUnary<false, false>`, as
`sumCount` and `intervalLengthSum` do. `NULL` rows are still skipped, and the state is the
same bytes as for a non-`Nullable` argument, the empty sketch when there were no values.

The `If` combinator builds its own null adapter without asking the nested function, so
`uniqApacheHLLStateIf` over a `Nullable` argument still writes the flag byte, as the other
functions with this property do.

Change the test to expect bare sketches, to compare `Nullable` and plain states, and to
import an external sketch into a `Nullable` state type without a prefix byte.

Not built or run.

Related: #2398

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…he plain state

The previous commit made the bytes of that state a bare DataSketches sketch, but its
type still named the `Nullable` argument, so `AggregateFunction(uniqApacheHLL, Nullable(T))`
and `AggregateFunction(uniqApacheHLL, T)` could not be mixed: no `UNION ALL`, no
`INSERT ... SELECT` into the other column type, and `haveSameStateRepresentation` was false.

Replace the generic `AggregateFunctionNullUnary<false, false>` with a `Nullable` variant of
the function itself, selected through `getOwnNullAdapter`. It skips `NULL` rows through the
null map, overrides `getStateType` and `getNormalizedStateType` to return those of the plain
function, whose state layout is identical, and ignores nullability of the arguments in
`haveSameStateRepresentationImpl`, so a column declared with a `Nullable` argument stays
interchangeable. `LowCardinality` needs no handling: the factory and the aggregator strip it
before the function sees types or columns.

The generic adapter is left alone; it is shared by `sumCount` and `intervalLengthSum`,
whose state types would change.

New test `05139` pins the state type, mixing with `UNION ALL`, `CAST` and `INSERT` in both
directions, and `LowCardinality(Nullable(String))` arguments.

Not built or run.

Related: #2398

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…appers

The wrapper that the `Null` combinator puts around a function for `Nullable` arguments
writes a flag byte before the state and gives it a type that names the `Nullable`
argument. For `uniqApacheHLL` neither is needed, since the state of no values is the empty
sketch, and both stop a state built from a `Nullable` column from being read by another
DataSketches implementation or mixed with the state of a plain column.

Add `IAggregateFunction::stateIsIndependentOfNullability`, `false` by default, next to
`getOwnNullAdapter` and `getArgumentsThatCanBeOnlyNull`. When it returns `true` the `Null`
combinator and the `If` combinator over `Nullable` arguments use the existing no-flag
wrappers, `AggregateFunctionNullUnary<false, false>` and the variadic and `If` equivalents,
and such a wrapper reports the state type of the nested function. `AggregateFunctionIf`
forwards the question to its nested function. The wrappers ask the nested function when
the type is requested, so nothing is added to their constructors, and every function that
does not override the method behaves as before.

This replaces the `Nullable` variant of `uniqApacheHLL` from the previous commit, which
covered only the `Null` combinator, with the generic mechanism, which also covers
`uniqApacheHLLStateIf` and `uniqApacheHLLMergeIf` over `Nullable` arguments. `uniqApacheHLL`
keeps `haveSameStateRepresentationImpl` ignoring nullability, so a column declared with a
`Nullable` argument stays interchangeable.

The test now also covers the state type and bytes of `StateIf` and `MergeIf` with a
`Nullable` argument and a `Nullable` condition.

Not built or run.

Related: #2398

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…inity/ClickHouse into review-pr2398

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…rst CI run

The first CI run built and ran the tests for the first time. Only these two failed.

`05139_uniq_apache_hll_nullable_state_type`: `uniqApacheHLLStateIf` has the type
`AggregateFunction(uniqApacheHLL, UInt64)`, not `AggregateFunction(uniqApacheHLLIf, UInt64, UInt8)`
as the reference guessed. It is the same for a `Nullable` argument, a plain one and a
`Nullable` condition, which is what the test is meant to show.

`05137_uniq_apache_hll_hash_borders`: the `Float64` and `Float32` states took the largest
values and the denormals as text, and the server parses text with its fast path, which is not
correctly rounded: `5e-324` was lost and `3.4028235e38` was not the largest `Float32`. Build the
values from their exact bit patterns instead, with `reinterpretAsFloat64` and `reinterpretAsFloat32`.
The expected states are unchanged, since they were computed from those bit patterns.

CI report: https://altinity-build-artifacts.s3.amazonaws.com/json.html?PR=2398&sha=e99077e33925c82fab2ed4da8ae16ad2519b9882&name_0=PR
Related: #2398

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
I, UnamedRus <dtitmoav@gmail.com>, hereby add my Signed-off-by to this commit: 71ed5a7
I, UnamedRus <dtitmoav@gmail.com>, hereby add my Signed-off-by to this commit: 2033e7b
I, UnamedRus <dtitmoav@gmail.com>, hereby add my Signed-off-by to this commit: a30cd57
I, UnamedRus <dtitmoav@gmail.com>, hereby add my Signed-off-by to this commit: 30ad260
I, UnamedRus <dtitmoav@gmail.com>, hereby add my Signed-off-by to this commit: 8d49460
I, UnamedRus <dtitmoav@gmail.com>, hereby add my Signed-off-by to this commit: 31e9e7a
I, UnamedRus <dtitmoav@gmail.com>, hereby add my Signed-off-by to this commit: 254c630
I, UnamedRus <dtitmoav@gmail.com>, hereby add my Signed-off-by to this commit: b403cd0
I, UnamedRus <dtitmoav@gmail.com>, hereby add my Signed-off-by to this commit: 12c65dd
I, UnamedRus <dtitmoav@gmail.com>, hereby add my Signed-off-by to this commit: 2440dbe

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Signed-off-by: UnamedRus <dtitmoav@gmail.com>
@zvonand zvonand added the port-antalya PRs to be ported to all new Antalya releases label Oct 5, 2026
@DimensionWieldr

Copy link
Copy Markdown
Collaborator

@DimensionWieldr aggregate suite is still failing. could you pls take a look?

Yup, I just made some fixes and updated regression release branch. I'll rerun aggregate suite to make sure it's working now.

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

Labels

antalya antalya-26.6 port-antalya PRs to be ported to all new Antalya releases

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants