-
Notifications
You must be signed in to change notification settings - Fork 358
Feat(sqlmesh_dbt): Implement --model and --resource-type #5443
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,7 +4,45 @@ | |
| logger = logging.getLogger(__name__) | ||
|
|
||
|
|
||
| def to_sqlmesh(dbt_select: t.Collection[str], dbt_exclude: t.Collection[str]) -> t.Optional[str]: | ||
| def consolidate( | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I thought about that but I wanted to keep the surface of
So they get consolidated early to reduce the number of parameters being passed around and then the lower layers then just call You can see this in |
||
| select: t.List[str], | ||
| exclude: t.List[str], | ||
| models: t.List[str], | ||
| resource_type: t.Optional[str], | ||
| ) -> t.Tuple[t.List[str], t.List[str]]: | ||
| """ | ||
| Given a bunch of dbt CLI arguments that may or may not be defined: | ||
| --select, --exclude, --models, --resource-type | ||
|
|
||
| Combine them into a single set of --select/--exclude node selectors, throwing an error if mutually exclusive combinations are provided | ||
| Note that the returned value is still in dbt format, pass it to to_sqlmesh() to create a selector for the sqlmesh selector engine | ||
| """ | ||
| if models and select: | ||
| raise ValueError('"models" and "select" are mutually exclusive arguments') | ||
|
|
||
| if models and resource_type: | ||
| raise ValueError('"models" and "resource_type" are mutually exclusive arguments') | ||
|
|
||
| if models: | ||
| # --models implies resource_type:model | ||
| resource_type = "model" | ||
|
|
||
| if resource_type: | ||
| resource_type_selector = f"resource_type:{resource_type}" | ||
| all_selectors = [*select, *models] | ||
| select = ( | ||
| [ | ||
| f"resource_type:{resource_type},{original_selector}" | ||
| for original_selector in all_selectors | ||
| ] | ||
| if all_selectors | ||
| else [resource_type_selector] | ||
| ) | ||
|
|
||
| return select, exclude | ||
|
|
||
|
|
||
| def to_sqlmesh(dbt_select: t.List[str], dbt_exclude: t.List[str]) -> t.Optional[str]: | ||
| """ | ||
| Given selectors defined in the format of the dbt cli --select and --exclude arguments, convert them into a selector expression that | ||
| the SQLMesh selector engine can understand. | ||
|
|
||
There was a problem hiding this comment.
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
allanddefaultbe in the sqlmesh context? I suppose this is a question for later on when multipleresource typessupport is added, but will these two mirror dbt as well?There was a problem hiding this comment.
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