Skip to content

Fix(dbt_cli): Make multiple --exclude's actually work#5233

Merged
erindru merged 1 commit intomainfrom
erin/dbt-improve-selectors
Aug 27, 2025
Merged

Fix(dbt_cli): Make multiple --exclude's actually work#5233
erindru merged 1 commit intomainfrom
erin/dbt-improve-selectors

Conversation

@erindru
Copy link
Collaborator

@erindru erindru commented Aug 27, 2025

Prior to this, on jaffle_shop_duckdb, the following would occur:

$ sqlmesh_dbt list --select 'main.stg_orders+' --exclude 'main.customers' --exclude 'main.orders'
├── main.orders
├── main.customers
└── main.stg_orders

That is, the exclusions didnt work.

This is the expected result as per dbt:

$ dbt list --select 'stg_orders+' --exclude 'customers' --exclude 'orders' --exclude 'resource_type:test'
jaffle_shop.staging.stg_orders

The cause was the selector not being generated correctly when there were multiple --exclude's. I realised that if I treat them like --select (union | them together) and then wrap the result in ^(...) and intersect & that with --select, I get the expected outcome.

So after this PR, the result matches dbt:

$ sqlmesh_dbt list --select 'main.stg_orders+' --exclude 'main.customers' --exclude 'main.orders'
Models in project:
└── main.stg_orders

@erindru erindru merged commit 91428c7 into main Aug 27, 2025
36 checks passed
@erindru erindru deleted the erin/dbt-improve-selectors branch August 27, 2025 06:04
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