Repository navigation
feat(tesseract): pre-agg matching without stored calc-group dims; collapse trivial pass-through subqueries; e2e specs for cross-cube rolling measures over rollups - #11346
Conversation
…a shared calc-group switch Adds an integration spec covering rollup pre-aggregation matching for multi-stage case entrypoint measures dispatched by a `type: switch` dimension (calc group) across two joined fact cubes combined in a view: - when each cube declares its own switch dimension, a query combining rolling measures from both cubes pins only one switch with a filter, the other stays unresolved, and no pre-aggregation can match (anti-pattern case, asserted); - when the switch lives on a shared single-row calc-group cube joined `1 = 1` into both fact cubes, a single rolling_window filter resolves every case measure and the query is served from both rollups, verified end to end against Postgres; - rolling window and time-shift arithmetic is pinned with deterministic value assertions on a rollup-free copy of the model. Two currently unsupported paths are documented as skipped tests: querying with a granular time dimension fails with "Alias not found for partition_by dimension" (the calc-group dimension is not projected into the multi-stage window input CTE), and a date-range-only time dimension stops matching the rollups even with allow_non_strict_date_range_match. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QxbxLWpBwunw3FypC8zfnY
|
Claude finished @paveltiunov's task in 42s —— View job Code ReviewReview complete — no blocking issues. 2 low-severity notes.
SummaryPurely additive integration spec — 660 lines, one new file, no production code touched. The test is well-scoped: it documents a real modeling anti-pattern (per-cube switches vs. shared calc-group switch), verifies end-to-end rollup matching against Postgres, and pins two currently-broken planner paths behind Nice touches:
NotesLow — Low — assertion asymmetry in the anti-pattern block (L629-653). The negative case (L634-636) checks both Not blocking
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #11346 +/- ##
===========================================
+ Coverage 59.57% 79.58% +20.00%
===========================================
Files 216 473 +257
Lines 17526 98240 +80714
Branches 3549 3549
===========================================
+ Hits 10441 78181 +67740
- Misses 6574 19548 +12974
Partials 511 511
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…s in Cube Store Adds a birdbox e2e smoke test running the shared calc-group model against a real Cube server with rollups stored and queried in Cube Store (CUBEJS_ROLLUP_ONLY, Tesseract planner), covering single-cube, cross-cube, and full multi-stage rolling-window queries dispatched by a shared switch dimension. Unlike the schema-compiler integration spec (Postgres-backed rollups), this exercises the Cube Store execution path used in production. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QxbxLWpBwunw3FypC8zfnY
|
Claude finished @paveltiunov's task in 48s —— View job Code Review (updated for latest commit)Review complete — no blocking issues. 2 low-severity notes carried over; 1 small nit on the new smoke fixtures.
What's new since the previous reviewSecond commit adds a birdbox-based end-to-end smoke test ( Three tests cover:
Fixture and test are internally consistent: NotesLow — asserting count of used pre-aggs (smoke-shared-calc-group.test.ts:104-106, 124-126). The cross-cube tests check Low (carried) — Low (carried) — anti-pattern assertion asymmetry (pre-aggregations-shared-calc-group.test.ts:629-653). Negative case asserts both rollup names are absent; positive single-cube case only asserts Not blocking
|
Adds a growth-percentage entrypoint (an extra multi-stage layer over the same rolling leaves) and a four-measure query matching the production query shape, to exercise the deep FullKeyAggregate plan that can overflow Cube Store's serialized-plan decode recursion limit. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QxbxLWpBwunw3FypC8zfnY
|
I'll analyze this and get back to you. |
…t decode limit
The four-measure query reproduces the Cube Store failure: the deep
FullKeyAggregate plan overflows the serialized-plan protobuf decode
recursion limit ("Error decoding expr as protobuf: ... recursion limit
reached"). Skipped with a FIXME until Cube Store can decode plans of
this depth; the three-measure query continues to run as a regression
guard for the working path.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QxbxLWpBwunw3FypC8zfnY
|
Claude finished @paveltiunov's task in 45s —— View job Code Review (updated for latest commits)No blocking issues. Verdict: 0 high, 0 medium, 3 low (2 carried). Details — task list, what's new, and notes
What's new since the previous review
Fixture wiring is internally consistent — the new measure name in the view matches the sales cube's export, NotesLow — skipped test is untested code ( Low (carried) — Low (carried) — anti-pattern assertion asymmetry (pre-aggregations-shared-calc-group.test.ts:629-653). The single-cube positive case doesn't assert Not blocking
|
… plan Multi-stage planning wraps every CTE reference into a derived table of the form (SELECT * FROM cte_n AS cte_n) AS alias. Each wrapper is a semantic no-op but costs two plan nodes (projection + subquery alias) per usage in engines that inline CTE bodies at every reference, such as Cube Store / DataFusion; deep multi-stage queries can overflow Cube Store's serialized-plan decode recursion limit because of them. Adds a physical-plan optimizer pass that rewrites (SELECT * FROM <table reference> AS x) AS alias into a direct <table reference> AS alias everywhere in the plan: the top-level select, CTE bodies, join sides, unions and nested subqueries. Only pure pass-through selects are collapsed: SELECT * projection with no filter, grouping, having, ordering, distinct, limit, offset or own CTEs, over a single table reference. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QxbxLWpBwunw3FypC8zfnY
|
Claude finished @paveltiunov's task in 1m 28s —— View job Code Review (updated for latest commit:
|
Asserts that multi-stage SQL no longer contains (SELECT * FROM <table>) wrappers, that collapsed CTE references keep their outer alias, and that executed results are unchanged. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QxbxLWpBwunw3FypC8zfnY
f5f8bb8 to
a3dfe48
Compare
|
I'll analyze this and get back to you. |
|
Claude finished @paveltiunov's task in 59s —— View job Code Review (updated for latest commit:
|
With the trivial-subquery collapse optimizer in the Tesseract physical plan builder, the four-measure query's plan fits under Cube Store's serialized-plan decode recursion limit and executes from the rollups. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QxbxLWpBwunw3FypC8zfnY
|
Claude finished @paveltiunov's task in 43s —— View job Code Review (updated for latest commit:
|
…ollapsed SQL - cargo fmt on trivial_subquery.rs (CI fmt/clippy + lint failures) - OracleQuery alias assertions now accept a bare CTE reference before the alias, since the trivial-subquery collapse renders join sides as `cte_0 "q_0"` instead of `(SELECT ...) "q_0"`; the no-AS-keyword invariant they guard is unchanged - symmetric rollup assertions in the per-cube switch anti-pattern spec Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QxbxLWpBwunw3FypC8zfnY
|
Claude finished @paveltiunov's task in 35s —— View job Code Review (updated for latest commit:
|
|
CI status note: several red checks on
The failures this PR actually caused ( Generated by Claude Code |
…dents Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QxbxLWpBwunw3FypC8zfnY
|
Claude finished @paveltiunov's task in 30s —— View job Code Review (updated for latest commit:
|
…ensions Calc-group (switch) dimensions are virtual enumerations: they carry no stored data, so a rollup gains nothing from materializing them — the build SQL just CROSS JOINs the value list, multiplying rollup size by the number of values while adding zero information. Until now they still had to be listed in every rollup definition purely because the pre-aggregation matcher treated them like ordinary dimensions. - dimension_matcher: a calc-group dimension now always matches (MatchState::Full) regardless of the rollup's stored dimensions. - query processor: calc-group resolution (filter-pinned value rendered as a literal, otherwise a virtual values cross-join) now also applies when the query source is a pre-aggregation, covering exactly the calc groups NOT stored in the rollup. Stored ones keep resolving to the rollup column, so existing rollups behave as before. Literal render references are re-added after the pre-aggregation render-reference reset so they survive it. - specs: new slim-rollup model + test in the shared-calc-group Postgres suite; the per-cube-switch test now asserts rollups match (calc groups no longer block matching); birdbox fixtures drop the switch dimension from both rollups and all Cube Store smoke tests pass. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QxbxLWpBwunw3FypC8zfnY
|
Claude finished @paveltiunov's task in 1m 47s —— View job Code Review (updated for latest commit:
|
Address review feedback: the anti-pattern block asserted only rollup selection after calc groups stopped blocking matching, so the semantic bug it warns about was no longer demonstrated. A new deterministic test on a no-pre-aggs variant of the per-cube switch model shows the unresolved share_metrics switch emitting one row per enumeration value (a duplicate P1 row with a null share change from the YTD branch) instead of the single 0.3 row the shared-switch model returns. The Cube Store smoke tests now assert the exact set of rollup tables used instead of some() containment: usedPreAggregations keys are per-usage (__usage_N suffix), so they are deduped to distinct rollup tables and compared with toEqual, catching any unexpected extra pre-aggregation being served. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QxbxLWpBwunw3FypC8zfnY
|
Claude finished @paveltiunov's task in 43s —— View job Code Review (updated for latest commit:
|
|
CI note: the red This matrix leg is non-required and was originally cancelled by concurrency dedup; every other check on Generated by Claude Code |
…atching - reference/core-data-apis/rest-api/reference.mdx: update the /v1/load response Warning to reflect that all numeric values are now always serialized as JSON strings across every driver (#10949), replacing the old "most drivers" wording, and link to castNumerics. - reference/data-modeling/pre-aggregations.mdx: document that `switch`-type dimensions no longer need to be listed in a rollup's `dimensions` for pre-aggregation matching to succeed (#11346).
…1346) (#11441) * docs: pre-aggregation matching for switch dimensions (follow-up to #11346) * docs: align inDateRange wording with the query-format reference and move the all-or-nothing caveat to multi-fact matching * docs: use CUBE[...] refs in the recipe rollup and drop the colliding base measure * docs: move the inDateRange note to time-dimension matching and explain the CUBE[...] rollup refs * docs: move the multi-cube switch modeling advice to the case measures reference * docs: close the switch matching section on its version caveat, not on prose

Check List
Description of Changes Made (if issue reference is not provided)
Feature: pre-aggregation matching no longer requires calc-group (switch) dimensions to be stored in the rollup (Tesseract). Calc-group dimensions are virtual enumerations — they carry no stored data, and materializing one in a rollup just CROSS JOINs the value list into the build SQL, multiplying rollup size by the number of values while adding zero information. They previously had to be listed in every rollup definition purely because the matcher treated them like ordinary dimensions. Now:
dimension_matcher.rs: a calc-group dimension always matches (MatchState::Full) regardless of the rollup's stored dimensions.query.rs(physical plan builder): calc-group resolution — a filter-pinned value renders as a literal, otherwise the enumeration is cross-joined as a virtual values table — now also applies when the query source is a pre-aggregation, covering exactly the calc groups not stored in the rollup. Stored calc groups keep resolving to the rollup column, so existing rollup definitions behave exactly as before (backward compatible). Literal render references are re-added after the pre-aggregation render-reference reset so they survive it.Fix: physical-plan optimizer collapsing trivial pass-through subqueries (Tesseract). Multi-stage planning wraps every CTE reference into a derived table of the form
(SELECT * FROM cte_n AS cte_n) AS alias. Each wrapper is a semantic no-op, but engines that inline CTE bodies at every reference (Cube Store / DataFusion) pay two extra plan nodes (projection + subquery alias) per usage — deep multi-stage queries over pre-aggregations could overflow Cube Store's serialized-plan protobuf decode recursion limit and fail withError during planning: Error decoding expr as protobuf: ... recursion limit reached. The new pass inphysical_plan/optimizers/trivial_subquery.rsrewrites such wrappers into direct<table> AS aliasreferences across the whole plan (top-level select, CTE bodies, join sides, unions, nested subqueries), collapsing only pure pass-throughs (SELECT *, no filter/group/having/order/distinct/limit/offset/CTEs, single table-reference source). On the repro query below this removes all 23 wrappers, and the previously failing query now executes in Cube Store.Verification: 1076 cubesqlplanner tests (including
--features integration-postgres, which executes generated SQL and compares results) and theintegration-cubestoretest pass; a test asserts the collapsed SQL shape and unchanged execution results.Test coverage added for rolling-window metrics exposed through multi-stage
caseentrypoint measures dispatched by atype: switchdimension (calc group) across two joined fact cubes combined in a view:pre-aggregations-shared-calc-group.test.ts, Postgres rollups): a shared single-row calc-group cube joined1 = 1into both fact cubes lets one filter resolve every case measure — cross-cube query matches both rollups; per-cube switch dimensions also match now that calc groups no longer block matching (asserted); a slim-rollup model verifies rollups that do not store the calc-group dimension still match, render the pinned value as a literal, and execute; deterministic value assertions pin the rolling/time-shift arithmetic.smoke-shared-calc-group.test.ts+ fixture): the same model on a real Cube server with rollups in Cube Store (CUBEJS_ROLLUP_ONLY, Tesseract), with the switch dimension omitted from both rollup definitions. Single-cube, cross-cube, three-measure, and the previously failing four-measure deep query all execute from Cube Store rollups.Remaining gaps documented as skipped
FIXMEtests:Alias not found for partition_by dimension …rolling_window— the calc-group dimension is not projected into the multi-stage window input CTE.allow_non_strict_date_range_match: trueis set and the range is month-aligned.🤖 Generated with Claude Code
https://claude.ai/code/session_01QxbxLWpBwunw3FypC8zfnY