Skip to content

Add compiled_sql to NodeRelation for ephemeral model support#1993

Open
b-per wants to merge 5 commits intomainfrom
bper/support-ephemeral-models-compiled-sql
Open

Add compiled_sql to NodeRelation for ephemeral model support#1993
b-per wants to merge 5 commits intomainfrom
bper/support-ephemeral-models-compiled-sql

Conversation

@b-per
Copy link
Contributor

@b-per b-per commented Mar 13, 2026

Summary

  • Adds a compiled_sql field to NodeRelation (protocol, implementation, and JSON schema) so that ephemeral models can be used in Semantic Layer definitions
  • When compiled_sql is set on a semantic model's node_relation, the converter uses SqlSelectTextNode (inline SQL subquery) instead of SqlTableNode (table reference) as the from-source
  • Includes tests for parsing, the PydanticNodeRelation field, and the converter branching logic

Follow-up

If approved/merged, we will also need to update Core and Fusion to generate a semantic manifest with compiled_sql filled in for ephemeral models.

Test plan

  • PydanticNodeRelation unit tests: compiled_sql defaults to None, round-trips correctly when set
  • YAML parsing tests: compiled_sql accepted in node_relation schema, defaults to None when absent
  • Converter branching tests: SqlTableNode used for table models, SqlSelectTextNode used when compiled_sql is present

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.
@b-per b-per requested a review from a team as a code owner March 13, 2026 13:03
@cla-bot cla-bot bot added the cla:yes label Mar 13, 2026
@github-actions
Copy link

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.

b-per added 4 commits March 13, 2026 14:49
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant