Skip to content

Add utility macros for column-level comments from schema.yml - #10

Open
RyutoYoda wants to merge 3 commits into
Snowflake-Labs:mainfrom
RyutoYoda:add-column-comment-macros
Open

Add utility macros for column-level comments from schema.yml#10
RyutoYoda wants to merge 3 commits into
Snowflake-Labs:mainfrom
RyutoYoda:add-column-comment-macros

Conversation

@RyutoYoda

@RyutoYoda RyutoYoda commented Oct 24, 2025

Copy link
Copy Markdown

Summary

  • Adds get_column_comment() and get_model_comment() utility macros
  • Automatically extracts descriptions from schema.yml and applies them as COMMENT clauses
  • Provides optional column-level documentation for semantic view elements (dimensions, facts, metrics)
  • Fully backward compatible - existing code unchanged

Test plan

  • Implement macros in /macros/utils/get_column_comment.sql
  • Add documentation to README.md with usage examples
  • Verify no existing functionality is affected
  • Test with actual schema.yml descriptions in integration tests

Benefits

  • Reduces manual comment writing for semantic views
  • Leverages existing schema.yml documentation
  • Optional feature - can be adopted incrementally

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.
Introduces get_column_comment() and get_model_comment() macros that automatically extract descriptions from schema.yml and apply them as COMMENT clauses in semantic views. This provides an optional way to add column-level documentation to semantic view elements (dimensions, facts, metrics) without manual comment writing.
Escape single quotes in column and model descriptions to prevent SQL syntax errors when descriptions contain apostrophes (e.g., "Customer's age").
@Daniel-Wiszowaty

Copy link
Copy Markdown

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

@damienchambon

Copy link
Copy Markdown

Hello, yes that would come in really handy for us!

@nikoshet

Copy link
Copy Markdown

☝️

@LizzyHunter

Copy link
Copy Markdown

+1

1 similar comment
@rsmireles

Copy link
Copy Markdown

+1

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