Add ca_extensions macro for Cortex Analyst verified queries - #30
Open
tylerjrichards wants to merge 1 commit into
Open
Add ca_extensions macro for Cortex Analyst verified queries#30tylerjrichards wants to merge 1 commit into
tylerjrichards wants to merge 1 commit into
Conversation
Adds a `ca_extensions` Jinja macro that generates the `WITH EXTENSION (CA=$$...$$)` block for Cortex Analyst enrichments (verified queries, custom instructions, relationships, per-table metadata). Previously users had to hand-write JSON inline, as seen in the existing `semantic_view_with_ca_extension.sql` integration test. The new macro accepts structured Python/Jinja dicts, serialises them with `| tojson`, and only includes keys that have values — keeping the DDL clean. Changes: - macros/ca_extensions.sql: new macro with full parameter docs - integration_tests/models/semantic_view_with_verified_queries.sql: test using the macro with a verified query, custom_instructions - README.md: new "Cortex Analyst enrichments" section with parameter table, field reference, and a complete example .... Generated with [Cortex Code](https://docs.snowflake.com/en/user-guide/cortex-code/cortex-code) Co-Authored-By: Cortex Code <noreply@snowflake.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
It is annoying that our dbt setup doesn't include the ability to use custom instructions and VQRs, this is how the product data team handles this in our materialization. Thought I would go and fix!
Now to the Coco summary:
ca_extensionsJinja macro (macros/ca_extensions.sql) that generates theWITH EXTENSION (CA=$$...$$)block for Cortex Analyst enrichmentsverified_queries,custom_instructions,relationships, and per-tabletablesmetadata — only emits keys that have valuesintegration_tests/models/semantic_view_with_verified_queries.sql) that exercises the macro end-to-endMotivation
The existing
semantic_view_with_ca_extension.sqlintegration test shows that users currently have to hand-write raw JSON strings in thewith extensionclause. That is error-prone and hard to maintain. This macro lets users define verified queries as structured Jinja dicts and relies on| tojsonfor correct serialisation.