Skip to content

Add persist_docs support for semantic views - #7

Open
RyutoYoda wants to merge 1 commit into
Snowflake-Labs:mainfrom
RyutoYoda:main
Open

Add persist_docs support for semantic views#7
RyutoYoda wants to merge 1 commit into
Snowflake-Labs:mainfrom
RyutoYoda:main

Conversation

@RyutoYoda

Copy link
Copy Markdown

Summary

Implements relation-level persist_docs functionality for semantic views, addressing the "persist_docs not supported" limitation mentioned in the README and resolving the TODO comment in the materialization.

  • ✅ Automatically adds model descriptions from schema.yml as COMMENT clauses to Semantic View DDL
  • ✅ Detects and avoids conflicts with existing inline COMMENT syntax
  • ✅ Follows the existing copy_grants pattern for consistency
  • ✅ Includes comprehensive test coverage for enabled and disabled scenarios

Usage Example

# schema.yml
models:
  - name: my_semantic_view
    description: "Customer metrics for analysis"

# model config
{{ config(
    materialized='semantic_view',
    persist_docs={'relation': true}
) }}

Results in DDL with: COMMENT='Customer metrics for analysis'

Test Plan

  • Added test model with persist_docs enabled
  • Added positive test verifying comment is added when enabled
  • Added negative test verifying comment is NOT added when disabled
  • Verified existing inline COMMENT syntax is preserved
  • Tested on actual Snowflake environment

Changes

  • Updated macros/relations/semantic_view/create.sql with new append_comment_if_missing macro
  • Modified macros/materializations/semantic_view.sql to remove TODO comment
  • Enhanced README with persist_docs documentation and usage examples
  • Added integration test model and test cases

Implements relation-level persist_docs functionality that automatically
adds model descriptions from schema.yml as COMMENT clauses to Semantic View DDL.

Key features:
- Supports persist_docs.relation configuration
- Detects and avoids conflicts with existing inline COMMENT syntax
- Follows existing copy_grants pattern for consistency
- Includes comprehensive test coverage for both enabled and disabled scenarios

Resolves the TODO in semantic_view materialization and addresses the
"persist_docs not supported" limitation documented in README.
@Daniel-Wiszowaty

Copy link
Copy Markdown

Hey @sfc-gh-yutliu could we push this? 🙏🏻

@ahossain-lithic

Copy link
Copy Markdown

This would be great to have!

@RyutoYoda

Copy link
Copy Markdown
Author

Hey @sfc-gh-yutliu 👋 Just checking in — any chance this could get a review when you have a moment? Happy to make any changes if needed. Thanks!

@LizzyHunter

Copy link
Copy Markdown

This is not only nice to have but a feature that can make the difference between keeping on using dbt / metricflow semantic layer VS fully adopting Snowflake solutions and downstream AI capabilities. Any chance this can be pushed? 🙏

@sfc-gh-sarur

Copy link
Copy Markdown
Collaborator

@RyutoYoda please resolve the conflicts in this PR before merging, thanks

@jheath5

jheath5 commented Aug 27, 2026

Copy link
Copy Markdown

@sfc-gh-sarur @RyutoYoda anything to do to get this merged? Not familiar on how to contribute/finish for this, but as @LizzyHunter said this will increase adoption of Snowflake semantic views for teams like mine that use dbt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants