Add compiled_sql to NodeRelation for ephemeral model support#1993
Open
Add compiled_sql to NodeRelation for ephemeral model support#1993
Conversation
Add a `compiled_sql` field to `NodeRelation` so that ephemeral models can be used in Semantic Layer definitions. When `compiled_sql` is set, the converter uses `SqlSelectTextNode` (inline SQL subquery) instead of `SqlTableNode` (table reference) as the from-source.
|
Thank you for your pull request! We could not find a changelog entry for this change. For details on how to document a change, see the contributing guide. |
Use getattr fallback for compiled_sql to avoid AttributeError when the installed dbt-semantic-interfaces package doesn't yet have the field. Also fix mypy type narrowing and black formatting.
Tests that construct PydanticNodeRelation with compiled_sql will fail until the published dbt-semantic-interfaces package includes the field. Skip them conditionally so CI passes in the meantime.
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
compiled_sqlfield toNodeRelation(protocol, implementation, and JSON schema) so that ephemeral models can be used in Semantic Layer definitionscompiled_sqlis set on a semantic model'snode_relation, the converter usesSqlSelectTextNode(inline SQL subquery) instead ofSqlTableNode(table reference) as the from-sourcePydanticNodeRelationfield, and the converter branching logicFollow-up
If approved/merged, we will also need to update Core and Fusion to generate a semantic manifest with
compiled_sqlfilled in for ephemeral models.Test plan
PydanticNodeRelationunit tests:compiled_sqldefaults toNone, round-trips correctly when setcompiled_sqlaccepted innode_relationschema, defaults toNonewhen absentSqlTableNodeused for table models,SqlSelectTextNodeused whencompiled_sqlis present