Skip to content

Feat(dbt_cli): Add --select and --exclude options #5200

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

erindru
Copy link
Collaborator

@erindru erindru commented Aug 21, 2025

Adds the --select and --exclude arguments to the sqlmesh_dbt run and sqlmesh_dbt list commands (the list command is mainly for testing expressions).

This is implemented in terms of generating a complex selection targeting the SQLMesh selector engine rather than attempting to re-implement a new selector engine from scratch.

  • dbt set unions eg model_a model_b are translated to |
  • dbt set intersections eg model_a,model_b are translated to &
  • --exclude is implemented in terms of using negation ^ on each expression and then doing a set intersection with whatever was supplied for --select

The selectors are still matched against model names, which differ between dbt and sqlmesh.

For example, on jaffle shop, the following selector works in dbt:
dbt list --select customers (selects the jaffle_shop.customers model)

However, on the SQLMesh selector engine it will return nothing, it needs to be:
sqlmesh_dbt list --select main.customers

I intend to address this in a follow-up PR if the groundwork laid in this PR is considered a suitable direction

@erindru erindru marked this pull request as draft August 21, 2025 22:12
@erindru erindru force-pushed the erin/dbt-selectors branch from 0f90cd8 to 5995209 Compare August 22, 2025 02:58
@erindru erindru marked this pull request as ready for review August 22, 2025 03:39
@erindru erindru force-pushed the erin/dbt-selectors branch from 5995209 to bf9dad5 Compare August 22, 2025 03:51
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.

2 participants