Skip to content

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:

Terminal window
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:

Terminal window
alias mondrian-schema='java -cp /path/to/saiku-<version>.jar mondrian.schema.yaml.SchemaCli'

Commands

to-yaml — convert XML to YAML

Terminal window
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:

Terminal window
mondrian-schema to-yaml demo/FoodMart.mondrian.xml -o demo/FoodMart.yaml

Example — preview without saving:

Terminal window
mondrian-schema to-yaml demo/FoodMart.mondrian.xml | head -40

to-xml — convert YAML to XML

Terminal window
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:

Terminal window
mondrian-schema to-xml demo/FoodMart.yaml -o FoodMart-generated.xml

Example — pipe to a diff to verify round-trip fidelity:

Terminal window
mondrian-schema to-xml demo/FoodMart.yaml | diff demo/FoodMart.mondrian.xml -

lint — validate a schema file

Terminal window
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 an
element 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:

Terminal window
mondrian-schema lint demo/FoodMart.yaml

Example — lint an XML schema:

Terminal window
mondrian-schema lint demo/FoodMart.mondrian.xml

Exit codes

CodeMeaning
0Success — no errors
1Bad arguments or missing input file
2Parse or validation failure — diagnostic written to stderr

These codes are suitable for use in CI pipelines and pre-save hooks.


Typical workflows

  1. Convert your existing XML schema to YAML:

    Terminal window
    mondrian-schema to-yaml my-schema.xml -o my-schema.yaml
  2. Lint the YAML to confirm it is valid:

    Terminal window
    mondrian-schema lint my-schema.yaml
  3. Review and annotate my-schema.yaml with comments, then upload it to Saiku via the Schemas page.


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.


  • 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.