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 VIEWSlists them, andDESCRIBE SEMANTIC VIEWshows 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
| Snowflake | Malloy | Notes |
|---|---|---|
TABLES entry (logical table) | source: over connection.table('db.schema.table') | |
PRIMARY KEY | primary_key: | |
RELATIONSHIPS (a (col) REFERENCES b (col)) | join_one: from a to b | |
FACTS | dimension: | A row-level value that measures aggregate |
DIMENSIONS | dimension: | |
METRICS | measure: | |
SUM(CASE WHEN ... THEN x END) | sum(x) { where: condition } | Filtered aggregate |
CASE WHEN ... END | pick ... when ... else | |
COMMENT | #(doc) tag | |
WITH SYNONYMS | Included in the #(doc) text | Malloy has no synonym field |
PRIVATE fact or metric | private: | Usable by other fields, not queryable directly |
| Verified queries | Parity checks, and named view: definitions for recurring questions |
Steps
- Set up a local modeling directory with
cred init(Cred CLI). Save the DDL or YAML in a subfolder such assnowflake/and add it to.credignore. - 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." - Review the proposed sources, joins and fields.
- Run the verified queries in Snowflake, run the same questions against the Malloy model, and compare, as described in Prove Parity.
- 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.