Skip to content

docs(mdl-schema): align with Cube types (PR #1574 follow-up)#2281

Merged
goldmedal merged 2 commits into
feat/wasm-cubefrom
feat/mdl-schema-cube-align
May 15, 2026
Merged

docs(mdl-schema): align with Cube types (PR #1574 follow-up)#2281
goldmedal merged 2 commits into
feat/wasm-cubefrom
feat/mdl-schema-cube-align

Conversation

@goldmedal
Copy link
Copy Markdown
Collaborator

@goldmedal goldmedal commented May 14, 2026

The published JSON schema at core/wren-mdl/mdl.schema.json still described the pre-PR #1574 "metric" shape. Now that the whole cube line (PRs #1574, #2264, #2265, #2276, #2277, #2278, #2280) has landed, this aligns the schema with the current Rust Manifest / Cube types so external editors and validators don't flag the documented cubes: YAML as invalid.

Changes (single file: core/wren-mdl/mdl.schema.json)

  • metricscubes (top-level field rename, reshape). Old metric used singular dimension/measure + timeGrain.dateParts UPPERCASE enum; the new cube shape uses plural measures/dimensions/timeDimensions and adds hierarchies.
  • New $defs: measure, cubeDimension, timeDimension — three simple { name, expression, type } types (the old metric reused column with many irrelevant fields like relationship, isCalculated, columnLevelAccessControl).
  • layoutVersion added at top level. Rust serializes this on every manifest produced by wren context build; the schema was missing it, so any real built mdl.json was already failing strict validation against additionalProperties: false.
  • dataSource regex → enum. Adds 4 missing values (DATAFUSION, DORIS, DATABRICKS, SPARK) and lists both UPPERCASE and lowercase forms so it matches Rust serde aliases (which the wren CLI's snake_case YAML output relies on — data_source: postgres round-trips to "dataSource": "postgres", lowercase).

Migration

This is a hard rename. metrics: has been silently dropped by Rust serde since PR #1574, so there's no working metrics: user to migrate. External editors / validators pinned to the schema's $id URL pick up the new shape automatically.

Validation

Six checks all green:

  1. JSON syntax + Draft 2020-12 meta-schema
  2. A wren-core-py test_cube.py-shaped cube manifest passes
  3. End-to-end: the real wren context build output for a v3 project with a cube validates (this is what caught the missing-layoutVersion and lowercase-dataSource gaps in the original plan)
  4. Old metrics:-shaped manifest is correctly rejected
  5. All 20 dataSource values accepted in both UPPERCASE and lowercase
  6. Bogus dataSource (e.g. FAKE_DB) still rejected

No internal consumer reads the schema (grep mdl.schema.json across *.rs / *.py / *.ts / *.toml returns zero hits), so no Rust / Python / TS regression is possible.

Not in this PR (follow-up issues)

  • (WIP) annotations on refSql, baseObject, enumDefinitions, cached, refreshTime are still there — separate staleness audit.
  • Versioned schema URL (mdl.schema.v1.json) — separate breaking-change discussion.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Added support for cube pre-aggregations with customizable measures, dimensions, time dimensions, and hierarchies
    • Introduced layoutVersion field to track manifest versions
    • Enhanced dataSource validation with explicit enum-based configuration for improved reliability

Review Change Stack

…low-up)

The published JSON schema at core/wren-mdl/mdl.schema.json still described
the pre-PR #1574 "metric" shape. Now that the whole cube line (PRs #1574,
#2264, #2265, #2276, #2277, #2278, #2280) has landed, align the schema with
the current Rust `Manifest` / `Cube` types so external editors and validators
don't flag the documented `cubes:` YAML as invalid.

Changes (single file):

  * metrics → cubes (top-level field). Old `metric` used singular
    dimension/measure plus timeGrain.dateParts UPPERCASE enum; the new
    `cube` shape uses plural measures/dimensions/timeDimensions and adds
    hierarchies.
  * New $defs: measure, cubeDimension, timeDimension. All three are simple
    { name, expression, type } types — the old metric reused `column` with
    many irrelevant fields like relationship, isCalculated, columnLevelAccessControl.
  * layoutVersion added at top level (Rust serializes this on every
    manifest via wren context build; the schema was missing it, so any
    real built mdl.json was already failing strict validation against
    additionalProperties: false).
  * dataSource regex → enum. Adds 4 missing values (DATAFUSION, DORIS,
    DATABRICKS, SPARK) and lists both UPPERCASE and lowercase forms so it
    matches Rust serde aliases (which the wren CLI's snake_case YAML
    output relies on).

This is a hard rename: serde silently drops `metrics:` since PR #1574, so
there's no working `metrics:` user to migrate.

No Rust / Python / TS code touched — schema-only doc change. Verified
internal consumers (no `.rs`/`.py`/`.ts` file references mdl.schema.json
besides its own \$id).

Validation pipeline used to verify:
  * JSON syntax + Draft 2020-12 meta-schema
  * A wren-core-py test_cube.py-shaped cube manifest passes
  * The end-to-end `wren context build` output for a v3 project with a
    cube validates (catches the missing layoutVersion / lowercase
    dataSource issues that the original plan didn't anticipate)
  * Old `metrics:` shape is now correctly rejected
  * Bogus dataSource value is still rejected

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@github-actions github-actions Bot added the core label May 14, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 14, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: ed469a4c-edcd-4bb1-936b-e0c968646b34

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • ✅ Review completed - (🔄 Check again to review again)
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/mdl-schema-cube-align

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@core/wren-mdl/mdl.schema.json`:
- Around line 452-461: The schema for the "hierarchies" property currently
allows empty arrays for each hierarchy name; update the "hierarchies" object's
additionalProperties schema (the array under "hierarchies") to include
"minItems: 1" so each hierarchy array must contain at least one string; locate
the "hierarchies" definition in mdl.schema.json and add "minItems": 1 alongside
the existing "type": "array" to enforce non-empty hierarchy paths.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 9fb4f646-83ef-44f1-a4aa-60c40c4cc5aa

📥 Commits

Reviewing files that changed from the base of the PR and between c0e9260 and 1b235b5.

📒 Files selected for processing (1)
  • core/wren-mdl/mdl.schema.json

Comment thread core/wren-mdl/mdl.schema.json
`hierarchies.<name>: []` previously passed the schema but is a useless
drill-down path. Add minItems: 1 so a hierarchy must declare at least
one level — caught at edit time instead of producing a no-op manifest.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@goldmedal goldmedal merged commit a11179b into feat/wasm-cube May 15, 2026
4 checks passed
@goldmedal goldmedal deleted the feat/mdl-schema-cube-align branch May 15, 2026 00:20
goldmedal added a commit that referenced this pull request May 15, 2026
PR #2281 renamed the top-level `metrics` array to `cubes` and the JSON
schema is `additionalProperties: false`, so a stray `metrics: []` fails
schema validation (the Rust deserializer silently ignores unknown
fields, which is why nothing broke at runtime). Sweep every MDL example
in docs, examples/, README, AGENT_GUIDE, and test fixtures to match the
current schema. CodeRabbit on PR #2282.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant