Schema CLI
Saiku ships a small schema tool inside the launcher jar. It converts a Mondrian schema between XML and YAML, and lints one before you upload it. Three subcommands, no server needed, fast enough to put in a git hook.
Run it straight from the jar you already have:
java -cp saiku-<version>.jar mondrian.schema.yaml.SchemaCli <command>That’s a mouthful to type more than once, so the examples below assume a shell alias:
alias mondrian-schema='java -cp /path/to/saiku-<version>.jar mondrian.schema.yaml.SchemaCli'Commands
to-yaml — convert XML to YAML
mondrian-schema to-yaml <input.xml> [-o output.yaml]Reads a Mondrian-4 XML schema and writes the equivalent YAML representation. If -o is omitted, the YAML is written to stdout.
Example — convert FoodMart:
mondrian-schema to-yaml demo/FoodMart.mondrian.xml -o demo/FoodMart.yamlExample — preview without saving:
mondrian-schema to-yaml demo/FoodMart.mondrian.xml | head -40to-xml — convert YAML to XML
mondrian-schema to-xml <input.yaml> [-o output.xml]Reads a Mondrian-4 YAML schema and writes the equivalent XML. If -o is omitted, the XML is written to stdout. This is the same conversion the Saiku engine runs automatically at runtime — running it manually is useful for inspecting the output before deploying or for migrating back to an XML-native toolchain.
Example — convert back to XML:
mondrian-schema to-xml demo/FoodMart.yaml -o FoodMart-generated.xmlExample — pipe to a diff to verify round-trip fidelity:
mondrian-schema to-xml demo/FoodMart.yaml | diff demo/FoodMart.mondrian.xml -lint — validate a schema file
mondrian-schema lint <input.{yaml,xml}>Parses and validates a schema file — YAML or XML, it works out
which from the content. A clean file prints ok: <filename> and
exits 0; a broken one prints the parse error to stderr, with the
line and column, and exits 2:
error: XML parse failed: Document parse failed: [Fatal Error] :1:29:Open quote is expected for attribute "name" associated with anelement type "Cube".Lint is a structural check — it confirms the file parses and the schema is well-formed. It can’t tell you whether a column exists in your warehouse; that’s found at first query. A schema that passes lint will load into Mondrian, which is the useful guarantee for a pre-commit hook.
Example — lint a YAML schema:
mondrian-schema lint demo/FoodMart.yamlExample — lint an XML schema:
mondrian-schema lint demo/FoodMart.mondrian.xmlExit codes
| Code | Meaning |
|---|---|
0 | Success — no errors |
1 | Bad arguments or missing input file |
2 | Parse or validation failure — diagnostic written to stderr |
These codes are suitable for use in CI pipelines and pre-save hooks.
Typical workflows
-
Convert your existing XML schema to YAML:
Terminal window mondrian-schema to-yaml my-schema.xml -o my-schema.yaml -
Lint the YAML to confirm it is valid:
Terminal window mondrian-schema lint my-schema.yaml -
Review and annotate
my-schema.yamlwith comments, then upload it to Saiku via the Schemas page.
-
Author or edit your YAML schema locally.
-
Run lint to catch errors before uploading:
Terminal window mondrian-schema lint my-schema.yamlA
0exit code means the schema parsed cleanly. Any errors appear on stderr with a line reference. -
If you need to supply XML to an external tool (e.g. a legacy reporting client), convert on demand:
Terminal window mondrian-schema to-xml my-schema.yaml -o my-schema.xml
Add a lint step to your CI pipeline to catch schema errors before they reach production:
# In .github/workflows/ci.yml or equivalent- name: Lint Mondrian schemas run: | for f in schemas/*.yaml; do java -cp saiku.jar mondrian.schema.yaml.SchemaCli lint "$f" doneThe script exits with code 2 on any parse or validation failure, which will fail the CI job automatically.
Prerequisites
Just Java on your $PATH, and the launcher jar. Both come with
any Saiku install; there’s no repository to clone and nothing to
build.
If you’re a Saiku Cloud customer without a local jar, you don’t need this tool at all — the Schemas page will hand you the same schema as XML, YAML or canvas JSON from the row menu, and validates on save.
Related
- YAML schemas — the full YAML element reference.
- Schemas — upload and manage schemas in the Saiku dashboard.
- Schema designer — generate a schema from a natural-language description.