Skip to content

Add compiled_sql to NodeRelation for ephemeral model support#1993

Open
b-per wants to merge 1 commit intomainfrom
bper/support-ephemeral-models-compiled-sql
Open

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

Conversation

@b-per
Copy link
Copy Markdown
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

@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
Copy Markdown

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.

Copy link
Copy Markdown
Contributor

@plypaul plypaul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this change supposed to be in dbt-semantic-interfaces as well? Looks good otherwise.

b-per added a commit to dbt-labs/dbt-semantic-interfaces that referenced this pull request Mar 26, 2026
Adds the optional compiled_sql field to the NodeRelation protocol and
PydanticNodeRelation implementation. This allows ephemeral dbt models
to pass their compiled SQL directly, rather than relying on relation_name.

Companion to dbt-labs/metricflow#1993.
@b-per
Copy link
Copy Markdown
Contributor Author

b-per commented Mar 26, 2026

Yes — opened dbt-labs/dbt-semantic-interfaces#469 for that. The getattr workaround in convert_semantic_model.py already bridges the gap until that lands and is published.

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.
@b-per b-per force-pushed the bper/support-ephemeral-models-compiled-sql branch from 87f574b to eced4ec Compare March 31, 2026 09:05
@b-per
Copy link
Copy Markdown
Contributor Author

b-per commented Mar 31, 2026

@plypaul I updated the PR to be on top of MSI

@b-per b-per requested a review from plypaul March 31, 2026 09:07
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.

2 participants