Migrate from Cube
What to export from Cube, how Cube cubes, views, measures, segments and access policies map to Malloy, and how to rebuild them with the modeling agent, for Cube developers and analytics engineers
A Cube data model moves into Credible through the modeling agent. The agent reads the exported model files as reference material and drafts the Malloy model from them, checking its proposals against your data. Expect to review the translations more closely than for Looker or Power BI, which have dedicated skills.
Comparing the two products first? See Credible vs. Cube.
What to Export
- The data model files: the YAML or JavaScript files under your Cube project's model folder, with cubes and views.
- Generated models: if cubes are generated with JavaScript or Jinja, also export the compiled result, for example the response from Cube's REST API metadata endpoint (
/v1/meta). The source files alone may not show every member. - Usage: the queries and dashboards people rely on, to set the scope.
How Cube Concepts Map to Malloy
| Cube | Malloy | Notes |
|---|---|---|
Cube with sql_table | source: over connection.table('schema.table') | |
Cube with sql | A query-based source, or a table built upstream | |
View (join_path, includes) | source: with joins that exposes a chosen set of fields | |
joins with relationship: many_to_one / one_to_one | join_one: | |
relationship: one_to_many | join_many: | |
{CUBE}.column | A plain column reference | |
| Dimension | dimension: | |
primary_key: true | primary_key: on the source | |
| Time dimension | A date or timestamp field, truncated with .day, .month, .year | |
Measure type: count | count() | |
type: count_distinct | count(field) | count(field) is distinct in Malloy |
type: sum, avg, min, max | sum(), avg(), min(), max() | |
type: number | A measure built from other measures | |
Measure filters | measure { where: condition } | Filtered aggregate |
rolling_window measure | A calculate: window function in a query | |
| Segment | A Boolean dimension used in where:, or a named view | |
title, description | #(doc) tag | |
format | Render tags such as # currency, # percent | |
public: false | internal: or private: | Choose by why it was hidden |
access_policy, queryRewrite | #(access_filter) or #(authorize) | Review by hand |
pre_aggregations | Nothing to convert | See Materialization and Performance if a source needs to be persisted |
Steps
- Set up a local modeling directory with
cred init(Cred CLI). Put the model files in a subfolder such ascube/and add it to.credignore. - Ask the agent to build the model, naming the folder and the domain: "Build a model of our orders domain using the Cube model in
cube/as prior art." - Review the proposed sources, joins and fields.
- Compare the key numbers against Cube with the same filters, as described in Prove Parity. Compare against raw data rather than a pre-aggregation, which may be stale.
- Publish, then rebuild the dashboards people use as reports or data apps.
What Needs Manual Review
- Dynamic models. Cubes generated in JavaScript or Jinja, or with context variables in their SQL. Check the generated output, not only the template.
- Access policies and
queryRewrite. Member-level and row-level rules written in code don't translate mechanically. Re-create them with access rules. - Multi-tenant setups. Per-tenant schemas or data sources selected at query time need a deliberate design in Credible.
- Rolling windows. Check that each one returns the same values at the time grains people use.
- Dashboards built on Cube. Not converted.