fix(schema-compiler): multi_stage leaf measure missing FROM clause#10550
fix(schema-compiler): multi_stage leaf measure missing FROM clause#10550TheRoot-1 wants to merge 1 commit intocube-js:masterfrom
Conversation
When a multi_stage measure's sql references a raw column with no measure dependencies, fromMeasures is null so fromSubQuery is never built, leaving fromSql null. The existing error check then throws "lacks FROM clause". Add a fallback: when fromSql is null but withQuery.measures is non-empty, build a subquery directly from the cube's own table instead of failing. Fixes: cube-js#10549 Related: cube-js#9241
|
Context on how this surfaces: this edge case came up when auto-generating Cube schemas from another modeling tool. The converter produced The intended Cube pattern is a chain where the leaf is a regular measure and |
|
Converting to draft — some findings since opening: Tesseract has the same bug. The Rust planner flags leaf measures via This may not be an intended use case. Every Leaving as draft until the team weighs in on the preferred approach — see #10549 for the full discussion. |
Summary
renderWithQuerywhen amulti_stagemeasure'ssqlhas no{}measure dependencies (leaf node in the dependency graph)memberFromis null for leaves, causingfromSubQuery→fromSqlto be null, which triggers the error check:"Multi stage member '...' lacks FROM clause in sub query"fromSubQuerywas never built and the withQuery has measures, build a subquery directly from the cube's own tableFixes: #10549
Related: #9241
Test plan
base-query.test.tscovering:summeasure does not throwavgtype works as well assumerror-reporter.test.ts)