Repository navigation
fix(schema-compiler): report self and circular member references at compile time (#4) - #12206
bhargavmehta01 wants to merge 3 commits into
Conversation
6db9c76 to
a077364
Compare
…ompile time (cube-js#4) Signed-off-by: Bhargav Mehta <bhargav.mehta01@gmail.com>
a077364 to
9cbba5d
Compare
|
Rebased on latest master (9cbba5d), no conflicts, and the new circular-member-references unit tests pass locally. The CI workflows for this fork PR are waiting on maintainer approval. @ovr @waralexrom could you approve the workflow runs and take a look when you get a chance? Thanks! |
|
Audit update: GitHub reports no merge conflicts and no review threads are open. The change remains scoped to same-cube member-reference cycles with focused compiler tests; no unrelated changes were made. Build/review workflows need maintainer approval before their results can establish review readiness. No fresh full-monorepo validation was performed in this audit. |
…er-circular-member-references
|
Updated the existing branch with current master in dc8af35. All 6 circular-member-reference regressions pass on the updated source, including YAML, self references, multi-member cycles, and non-cyclic models. Validation used isolated transpilation/Jest with published Cube 1.8.26 dependencies; a full monorepo build/typecheck still needs upstream CI approval. |
…er-circular-member-references
|
Updated the existing branch with current master ( |
Check List
Issue Reference this PR resolves
Fixes #4
Description of Changes Made
A member whose
sqlreferences itself, such asor that reaches itself through other members of the same cube (
a -> b -> a), can never be resolved. The originalRangeError: Maximum call stack size exceededno longer happens, since Tesseract now stops atCUBEJS_MAX_MEMBER_RESOLUTION_DEPTH. But the model still compiles cleanly and only fails at query time, with an error that doesn't say the member points back at itself:Raising the limit, as that message suggests, can't help here. This PR adds the self-reference guard the issue asks for in the schema compiler, so the model fails at compile time with the cycle spelled out:
How it works:
prepareMembersalready callscollectUsedCubeReferencesfor each member'ssql. It now also records the same-cube member names frompathReferencesUsed(bare${foo},${CUBE.foo}, and${createdAt.granularity}all resolve there). Nothing extra is evaluated.checkCircularMemberReferencesruns a DFS over that per-cube graph (measures, dimensions, and segments together) and reports each cycle once through the error reporter.Verification
I couldn't run the full monorepo jest setup locally. Instead I applied the equivalent change to the published
@cubejs-backend/schema-compiler@1.8.3build and checked:${foo}and${CUBE.foo}), 2-member and 3-member dimension cycles, a measure cycle, and a YAML self reference all fail at compile time with the messages above.${CUBE},${CUBE.id}, a custom granularity reference, anumbermeasure over${count}, a segment, a cross-cube reference, and a view still compiles, and its query SQL is unchanged.test/unit/fixturescompiles with exactly the same results before and after the change (no new errors).New tests are in
test/unit/circular-member-references.test.ts.