Migrate from Snowflake Semantic Views

What to export from Snowflake, how semantic view tables, relationships, facts, dimensions and metrics map to Malloy, and how to rebuild them with the modeling agent, for data engineers who maintain semantic views in Snowflake

Snowflake semantic views, or older Cortex Analyst semantic model YAML, move into Credible through the modeling agent. The agent reads the exported definitions 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. Snowflake Cortex.

What to Export

  • Semantic views: the DDL of each view, from SELECT GET_DDL('SEMANTIC_VIEW', '<database>.<schema>.<view>'). SHOW SEMANTIC VIEWS lists them, and DESCRIBE SEMANTIC VIEW shows a view's parts.
  • Cortex Analyst YAML: if you still use semantic model files on a stage, download them.
  • Verified queries: the question and SQL pairs stored with the view or model. They are useful parity checks.

How Snowflake Concepts Map to Malloy

SnowflakeMalloyNotes
TABLES entry (logical table)source: over connection.table('db.schema.table')
PRIMARY KEYprimary_key:
RELATIONSHIPS (a (col) REFERENCES b (col))join_one: from a to b
FACTSdimension:A row-level value that measures aggregate
DIMENSIONSdimension:
METRICSmeasure:
SUM(CASE WHEN ... THEN x END)sum(x) { where: condition }Filtered aggregate
CASE WHEN ... ENDpick ... when ... else
COMMENT#(doc) tag
WITH SYNONYMSIncluded in the #(doc) textMalloy has no synonym field
PRIVATE fact or metricprivate:Usable by other fields, not queryable directly
Verified queriesParity checks, and named view: definitions for recurring questions

Steps

  1. Set up a local modeling directory with cred init (Cred CLI). Save the DDL or YAML in a subfolder such as snowflake/ and add it to .credignore.
  2. Ask the agent to build the model, naming the folder and the domain: "Build a model of our sales domain using the semantic view DDL in snowflake/ as prior art."
  3. Review the proposed sources, joins and fields.
  4. Run the verified queries in Snowflake, run the same questions against the Malloy model, and compare, as described in Prove Parity.
  5. Publish.

What Needs Manual Review

  • Two formats. An account can have native semantic views, Cortex Analyst YAML, or both. Make sure the agent has every definition in use.
  • Facts and metrics. Keep facts as row-level dimensions so measures can still aggregate them at any grain.
  • Access control. Snowflake role grants, row access policies and masking policies don't travel with the semantic view definition. Re-create the restrictions you need with access rules.
  • Tools built on the semantic view. Cortex Analyst and anything else that queries the view need to be pointed at the published model instead.

Next Steps

On this page