Skip to content

docs: exhaustively document the multi-stage grain directive#11073

Open
AvilaJulio wants to merge 1 commit into
cube-js:masterfrom
AvilaJulio:docs/multi-stage-grain-directive
Open

docs: exhaustively document the multi-stage grain directive#11073
AvilaJulio wants to merge 1 commit into
cube-js:masterfrom
AvilaJulio:docs/multi-stage-grain-directive

Conversation

@AvilaJulio

Copy link
Copy Markdown
Member

Summary

Documents the multi-stage grain directive, which was previously undocumented despite being accepted by the schema validator and exercised by the multi-stage-grain integration test.

Reference (reference/data-modeling/measures.mdx)

  • New ### grain section covering keep_only, exclude, and include, with worked result tables whose numbers are verified against multi-stage-grain.test.ts.
  • Documents grain as the canonical form of group_by / reduce_by / add_group_by (which map to keep_only / exclude / include respectively).
  • <Warning> that a measure uses either a grain block or the legacy parameters — never both. This reflects the Tesseract planner (build_grain_from_legacy / from_measure_definition): when a grain block is present, the legacy directives on that measure are ignored.
  • Disambiguates grain's keys from the same-named keys on the filter directive.

Concepts (docs/data-modeling/measures.mdx)

  • New "Controlling grain" subsection in the multi-stage section.

Recipe (recipes/data-modeling/semi-additive-measures.mdx)

  • New recipe: modeling semi-additive (end-of-period) measures with a multi-stage rank plus grain (include for the leaf grain, keep_only for the window partition).
  • Registered in docs.json.

Notes

  • Tesseract / CUBEJS_TESSERACT_SQL_PLANNER=true is required for grain; called out throughout.
  • No code changes — documentation only.

Expand the "Controlling grain" section of the measures guide with the
per-key mechanics (keep_only / exclude / include) and worked result
tables, verified against the multi-stage-grain integration test.

On the measures reference, keep upstream's grain/legacy sections and add
a note that `grain` requires the Tesseract SQL planner, is valid only on
measures, and is distinct from the similarly-named keys on the `filter`
directive.

Add a new "Semi-additive (end-of-period) measures" recipe demonstrating
grain (include + keep_only) and rank for end-of-period balances, and
register it in the docs navigation.
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