Repository navigation
Conversation
The sketch-bench ClickHouse configs now run baseline_mv beside baseline: exact mergeable states in materialized views, no sketches. There is one AggregatingMergeTree view per (metric, value, statistic, interval T). Its key is the T-second bucket plus the union of the queries' groupings and their child_of parents (every label for per-series statistics). The states are sumState, countState, quantilesExactInclusiveState over the queries' levels, argMaxState per series for instant vectors, and per-series first/last sample, min/max ts and count for rate/increase. Those feed the same extrapolatedRate SQL. Bucket b holds (b - T, b], and an `edge` flag keeps samples at exactly b apart. A closed window [E - W, E] therefore merges the buckets in (E - W, E] plus the edge rows of bucket E - W. A query whose window is not a multiple of T raises, so instant vectors are only served at T = 1 s. The init SQL creates the views after their tables and before any data arrives. The test runs every MV query next to its raw SQL in clickhouse-local. Results match exactly, except sums, which agree within 1e-9 relative. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AnJ7LocWxguh3q4QWkCYae
Each sketch-bench table now gets one config per arm. The baseline config (init.sql) creates only the tables. The baseline_mv config (init_mv.sql) creates the tables and their views. Both files drop the views first, so none left by an earlier baseline_mv run keeps feeding on the recreated tables. Both configs list both arms' SQL files, so saved results label every query by its baseline text. experiment_run_clickhouse.py monitored ingest under the baseline mode's client config and output dir. A baseline_mv-only run has neither, so ingest now uses baseline when the run has it, and otherwise the run's first mode. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AnJ7LocWxguh3q4QWkCYae
A multigroup query's window is now ASAPQuery's (E - W, E], so its baseline_mv SQL merges just the buckets in (E - W, E] and skips the edge rows that hold a closed window's left boundary. Classic PromQL queries keep the closed window and its edge rows. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AnJ7LocWxguh3q4QWkCYae
…a query convert() planned views for every query, and plan_views raises when a window is not a multiple of the interval (e.g. an instant vector, which reads [T - 1s, T], at T > 1 s). So such a table failed to convert even for the baseline arm, which needs no views. Now a table with such a query gets only the baseline arm: init.sql, the raw SQL and the baseline config, plus a note on stderr naming the queries. Dropping just those queries from the MV arm would shift its query indices against the baseline SQL that labels both arms' results. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AnJ7LocWxguh3q4QWkCYae
…MV SQL The views' `bucket` column is a DateTime (whole seconds), so integer bounds already filter it exactly. They are now toDateTime(<bound>) anyway, to match the column type, as the raw SQL's ts bounds now are. The key-pruning regression test, merged from feat/e2e-sql-from-table, now passes the views to load_script (this branch's signature). It also runs each query's MV SQL over views with 1-row granules and checks raw and MV against the expected counts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AnJ7LocWxguh3q4QWkCYae
Brings in origin/main (#837, #828) and the switch to the table's ASAPQuery SQL. Conflicts resolved by keeping both sides: the module docstring keeps this branch's per-arm outputs with the new asapquery.sql line; the tests keep PlanViewsTest and FlooredEndDatetimeTest; experiment_run_clickhouse and its test import both _ingest_mode and #828's prebuilt-output helpers. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AnJ7LocWxguh3q4QWkCYae
Contributor
Code reviewStacks on #844. Core MV logic checks out (closed and left-open windows,
Tests: missing a regression test that baseline |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on the sketch-bench SQL PR (base branch
feat/e2e-sql-from-table).Summary
Adds the
baseline_mvarm: ClickHouse with materialized views and no sketches, only exact, mergeable states. Each view's bucket width is the query's repeat interval T.One view per (table, value column, statistic, T), an
AggregatingMergeTreekeyed by bucket and the union of the groupings that read it, plus theirchild_ofparents. Per-series and instant queries keep every label. Coarser groupingsGROUP BYa subset and merge (roll-up). For example, template 16's whole CUBE reads one(region, service, endpoint)view.States:
sumState,countStatequantilesExactInclusiveStateover the view's levelsuniqExactStateargMaxState(value, ts)extrapolatedRateORDER BY … LIMIT kWindows: bucket b holds
(b−T, b], and anedgeflag keeps samples at exactly b apart. Classic's closed[E−W, E]merges the buckets in(E−W, E]plus bucketE−W's edge rows. Multigroup's left-open(E−W, E]merges just the buckets. A window that isn't a multiple of T raises. Instant queries need T = 1 s.Per-arm init SQL, so the baseline arm never pays for the views:
init.sql(tables only) andinit_mv.sql(tables, then views; the views must exist before data arrives). Both drop old views first.experiment_run_clickhouse.pynow uses the run's first mode for ingest monitoring whenbaselineisn't in the run, so abaseline_mv-only run works.Testing
toStartOfIntervalbuckets, makes 84–132 subtests fail.init_mv.sqlexecute for classic (4 views), multigroup (3 views:http_user_id_cardinality_60s,http_latency_quantile_60s,flows_src_ip_cardinality_60s) and all-metrics8 (56 views).tests/test_experiment_run_clickhouse.py. black/flake8 clean.🤖 Generated with Claude Code
https://claude.ai/code/session_01AnJ7LocWxguh3q4QWkCYae