Skip to content

feat(clickhouse): execute safe row-count materializations - #632

Merged
zzylol merged 17 commits into
mainfrom
feat/clickhouse-constant-lowering
Sep 11, 2026
Merged

zzylol merged 17 commits into
mainfrom
feat/clickhouse-constant-lowering

Conversation

@zzylol

@zzylol zzylol commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

SQL row-count plans were rejected by a PromQL-only temporal-count guard, and the source binder could not represent their literal update. This change lowers safe row counts through the shared typed constant projection and the existing physical SUM accumulator, then combines their readout with ordinary ClickHouse exact DAG dependencies.

Before: count(*) could not install a mixed SQL plan; relaxing that guard alone would also expose Planner's erased nullable count(value) semantics. After: the Planner revision includes its reviewed nullable-count guard (#389), count(*) includes NULL-valued rows correctly, and unsupported nullable counts remain rejected. Named value sources must be non-null Float64 because the current ingest boundary cannot preserve arbitrary Int64 values. Producer Project subtrees are rejected until their computation is executed, preventing value * 2 AS value from silently reading the original column.

Verification: all 726 control-plane tests passed. The real ClickHouse/backend process test passed for SUM and count(*) mixed with an external exact branch, including a NULL row, population/time-boundary exclusions, and source-row deletion after materialization to prove state readout. Compiler counterexamples cover nullable count(value), unsupported Int64 source values and erased producer projections. A subsequent item=value/weight=1 regression also passed; keyed summary inputs are rejected until their item projection is supported, preventing the unit weight from replacing the actual item. The selected Count DAG and typed constant projection are recorded in /mydata/clickhouse-o11y-main-results/automatic-count-planning.json.

This PR does not claim count performance benefits or full SQL workload coverage. It stacks on #617 for existing exhaustive Planner/UnivMon compatibility and also includes the already-merged #625 shared projection contract; those dependency diffs disappear when #617 is replayed onto main. Independent bounded source review passed.

@zzylol
zzylol marked this pull request as ready for review September 11, 2026 02:28
@zzylol
zzylol changed the base branch from feat/univmon-runtime to main September 11, 2026 13:09
@zzylol
zzylol merged commit 969fffc into main Sep 11, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant