Skip to content

[Feature] Support Snowflake Semantic View as a materialization #1260

@sfc-gh-yutliu

Description

@sfc-gh-yutliu

Is this your first time submitting a feature request?

  • I have read the expectations for open source contributors
  • I have searched the existing issues, and I could not find an existing issue for this feature
  • I am requesting a straightforward extension of existing dbt functionality, rather than a Big Idea better suited to a discussion

Describe the feature

materialized='semantic_view'

This feature is to introduce Snowflake Semantic View as another type of model materialization.
For more context about Semantic View, see this official doc

What will happen

This features introduces semantic views as a new materialization type within dbt for Snowflake. This feature would enable users to:

  • Create and manage Snowflake semantic views directly from dbt models. This involves defining the semantic view using SQL with TABLES, RELATIONSHIPS, FACTS, DIMENSIONS, and METRICS clauses.
{{
  config(
    materialized='semantic_view',
  )
}}

TABLES(
  {{ source('<source_name>', '<table_name_1>') }},
  {{ ref('<table_or_view>') }},
  ...
)
RELATIONSHIPS(...)
FACTS(...)
DIMENSIONS(...)
METRICS(...)
COMMENT = '...'
COPY GRANTS
  • Reference semantic views in other dbt models. Both existing semantic views in the database and newly created dbt semantic views can be referenced using source or ref macros, respectively.
    • Using semantic views that are already present in the database should already be possible by using source:
select ... from semantic_view(
    {{ source('<source_name>', '<semantic_view>') }}
    METRICS ...
    DIMENSIONS ...
    WHERE ...
);
  • With this feature, we will also be able to refer to a semantic view model as a ref:
{{ config(materialized='table') }}

select ... from semantic_view(
    {{ ref('<semantic_view>') }}
    METRICS ...
    DIMENSIONS ...
    WHERE ...
);
  • Support dbt data and unit testing for models utilizing semantic views. This includes mechanisms for defining comments and COPY GRANTS for semantic views through dbt configurations (e.g., dbt_project.yml, model YAML, or directly in SQL).

Describe alternatives you've considered

No response

Who will this benefit?

Who will this benefit?

This feature will primarily benefit dbt users leveraging Snowflake's semantic layer. It will be useful for:

  • Data and Analytics Engineers: To define and manage consistent semantic layers within dbt projects, enabling easier version control and reducing context switching.
  • BI Developers and Data Analysts: To consume and build reports on trusted data, using standardized business metrics and dimensions defined in dbt semantic views.
  • Organizations with Data Governance Needs: To consistently apply and audit data documentation and access controls for semantic views within the dbt workflow.
  • Teams Building Composable Data Models: To use semantic views as foundational building blocks for other dbt models.
  • Users Requiring Enhanced Testing: To rigorously test the accuracy and integrity of semantic layer definitions, ensuring data quality for critical business metrics.

Are you interested in contributing this feature?

I want to contribute to the corresponding code change, and let the maintainers review the change.

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions