Skip to content

Feat(sqlmesh_dbt): Implement --model and --resource-type#5443

Merged
erindru merged 1 commit intomainfrom
erin/dbt-model-option
Oct 2, 2025
Merged

Feat(sqlmesh_dbt): Implement --model and --resource-type#5443
erindru merged 1 commit intomainfrom
erin/dbt-model-option

Conversation

@erindru
Copy link
Collaborator

@erindru erindru commented Sep 26, 2025

This PR adds the -m/--model/--models argument to the sqlmesh_dbt CLI.

It does this by implementing support for the resource_type selector method in the SQLMesh selector engine and then if --models is supplied, injecting resource_type:model into the selector expression alongside the user-supplied values.

Note that --models is different to --select:

  • --models just includes model nodes - so excludes seeds, sources and tests
  • --select includes all nodes

@erindru erindru marked this pull request as ready for review September 26, 2025 02:19


def to_sqlmesh(dbt_select: t.Collection[str], dbt_exclude: t.Collection[str]) -> t.Optional[str]:
def consolidate(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why even expose this outside this module? Why not make it a part of a single unified to_sqlmesh interface?

Copy link
Collaborator Author

@erindru erindru Oct 2, 2025

Choose a reason for hiding this comment

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

I thought about that but I wanted to keep the surface of to_sqlmesh() simple and take the minimum required parameters.

combine() still operates in dbt-land and produces consolidated selectors in dbt format. The goal is to not have to always pass down select, exclude, resource_type, models etc parameters through every layer when really all of these parameters can be described in terms of select/exclude.

So they get consolidated early to reduce the number of parameters being passed around and then the lower layers then just call to_sqlmesh() on just select / exclude and dont have to worry about or consider any of the other parameters.

You can see this in DbtOperations._plan_builder which deliberately only needs select/exclude, not all the other options that may be passed.

"exposure",
"snapshot",
"seed",
"default",
Copy link
Contributor

Choose a reason for hiding this comment

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

small question on the last two, what will all and default be in the sqlmesh context? I suppose this is a question for later on when multiple resource types support is added, but will these two mirror dbt as well?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Currently, unimplemented :) but at a guess i'd say they would be aliases for the same thing because SQLMesh includes everything by default

@erindru erindru merged commit 956670c into main Oct 2, 2025
36 checks passed
@erindru erindru deleted the erin/dbt-model-option branch October 2, 2025 03:24
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.

3 participants