Snowflake-Labs/dbt_semantic_view
Python
Captured source
source ↗Snowflake-Labs/dbt_semantic_view
Description: The DBT package to support Snowflake Semantic View as a new materialization.
Language: Python
License: Apache-2.0
Stars: 67
Forks: 16
Open issues: 14
Created: 2025-09-10T21:34:26Z
Pushed: 2026-05-18T06:15:29Z
Default branch: main
Fork: no
Archived: no
README:
Snowflake Semantic View dbt Package
Professional dbt macros and integration tests for building, dropping, and renaming Snowflake Semantic Views. This package lets you materialize Semantic Views via dbt and reference them from downstream models.
Compatibility
> Full SQL API coverage — This package automatically supports the complete Snowflake CREATE SEMANTIC VIEW SQL syntax. When Snowflake introduces new semantic view capabilities, the package picks them up without requiring any code change or package upgrade. Simply update your model definition to use the new syntax and run dbt build. > > For the full syntax reference, see CREATE SEMANTIC VIEW.
At a glance
- Materialization:
semantic_view - Warehouse: Snowflake
- dbt Compatibility: dbt 1.x
Quickstart
Follow these steps on macOS/Linux with Python 3 installed. No prior dbt installation is required.
1) Clone and enter the repo
git clone https://github.com/Snowflake-Labs/dbt_semantic_view.git cd dbt_semantic_view/
2) Create an isolated Python environment and install dependencies
python3 -m venv .venv source .venv/bin/activate pip install -U pip pip install dbt-snowflake
3) Configure Snowflake credentials (env vars)
Set the following environment variables for the integration profile. For username/password auth use SNOWFLAKE_TEST_AUTHENTICATOR=snowflake.
export SNOWFLAKE_TEST_ACCOUNT= export SNOWFLAKE_TEST_USER= export SNOWFLAKE_TEST_PASSWORD= export SNOWFLAKE_TEST_AUTHENTICATOR= # e.g. snowflake | externalbrowser export SNOWFLAKE_TEST_ROLE= export SNOWFLAKE_TEST_DATABASE= export SNOWFLAKE_TEST_WAREHOUSE= export SNOWFLAKE_TEST_SCHEMA=
4) Run integration tests
cd integration_tests/ dbt deps --target snowflake dbt build --target snowflake
Usage in your dbt project
Add to packages.yml:
packages: - package: Snowflake-Labs/dbt_semantic_view verion:
To find the current version, see the dbt_semantic_view package page.
> Note: This package is a direct passthrough to Snowflake's SQL layer. You don't need to update the package version to access new Snowflake semantic view features. When Snowflake adds new SQL capabilities (for example, AI_VERIFIED_QUERIES), they will be available immediately via the package without any package update.
Create a model using the Semantic View materialization:
{{ config(materialized='semantic_view') }}
TABLES(
{{ source('', '') }},
{{ ref('') }}
)
[ RELATIONSHIPS ( relationshipDef [ , ... ] ) ]
[ FACTS ( semanticExpression [ , ... ] ) ]
[ DIMENSIONS ( semanticExpression [ , ... ] ) ]
[ METRICS ( semanticExpression [ , ... ] ) ]
...for the complete list of support semantic view elements please refer to: https://docs.snowflake.com/en/sql-reference/sql/create-semantic-view#syntax
Reference a Semantic View from another model:
{{ config(materialized='table') }}
select *
from semantic_view(
{{ ref('') }}
[ { METRICS | FACTS } ]
[ DIMENSIONS ]
[ WHERE ]
)Note on documentation persistence (persist_docs)
At this time, dbt-driven documentation persistence for Semantic Views (persist_docs) is not supported by this package. Enabling persist_docs and adding model or column descriptions will not affect Semantic Views.
Inline COMMENT syntax within the Semantic View DDL is supported and will be applied by Snowflake. For example:
CREATE OR REPLACE SEMANTIC VIEW TABLES ( ... COMMENT = '...' ) [ FACTS ( ... COMMENT = '...' ) ] [ DIMENSIONS ( ... COMMENT = '...' ) ] [ METRICS ( ... COMMENT = '...' ) ] [ COMMENT = '...' ]
We plan to revisit persist_docs support as upstream capabilities evolve.
Development
- Python 3.9+ recommended
- Use a venv:
python3 -m venv .venv && source .venv/bin/activate - Install tooling as needed:
pip install dbt-snowflake
Contributing
We welcome issues and PRs! Please:
- Open an issue to discuss significant changes
- Keep edits focused and include tests where possible
- Follow dbt and Python best practices
License
Apache License 2.0. See LICENSE for details.
Excerpt shown — open the source for the full document.
Notability
notability 4.0/10New Snowflake dbt view, 66 stars