docs(mdl-schema): align with Cube types (PR #1574 follow-up)#2281
Conversation
…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>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
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
📒 Files selected for processing (1)
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>
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>
The published JSON schema at
core/wren-mdl/mdl.schema.jsonstill 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 RustManifest/Cubetypes so external editors and validators don't flag the documentedcubes:YAML as invalid.Changes (single file:
core/wren-mdl/mdl.schema.json)metrics→cubes(top-level field rename, reshape). Oldmetricused singulardimension/measure+timeGrain.datePartsUPPERCASE enum; the newcubeshape uses pluralmeasures/dimensions/timeDimensionsand addshierarchies.$defs:measure,cubeDimension,timeDimension— three simple{ name, expression, type }types (the old metric reusedcolumnwith many irrelevant fields likerelationship,isCalculated,columnLevelAccessControl).layoutVersionadded at top level. Rust serializes this on every manifest produced bywren context build; the schema was missing it, so any real builtmdl.jsonwas already failing strict validation againstadditionalProperties: false.dataSourceregex → 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: postgresround-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 workingmetrics:user to migrate. External editors / validators pinned to the schema's$idURL pick up the new shape automatically.Validation
Six checks all green:
wren-core-pytest_cube.py-shaped cube manifest passeswren context buildoutput for a v3 project with a cube validates (this is what caught the missing-layoutVersionand lowercase-dataSourcegaps in the original plan)metrics:-shaped manifest is correctly rejecteddataSourcevalues accepted in both UPPERCASE and lowercasedataSource(e.g.FAKE_DB) still rejectedNo internal consumer reads the schema (
grep mdl.schema.jsonacross*.rs/*.py/*.ts/*.tomlreturns zero hits), so no Rust / Python / TS regression is possible.Not in this PR (follow-up issues)
(WIP)annotations onrefSql,baseObject,enumDefinitions,cached,refreshTimeare still there — separate staleness audit.mdl.schema.v1.json) — separate breaking-change discussion.🤖 Generated with Claude Code
Summary by CodeRabbit