Skip to content
This repository was archived by the owner on May 17, 2024. It is now read-only.

Commit 8772c47

Browse files
authored
Merge pull request #620 from datafold/DX-759
add --dbt support for --where/-w
2 parents 40a785d + d42c4ba commit 8772c47

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

data_diff/__main__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,7 @@ def main(conf, run, **kw):
291291
dbt_selection=kw["select"],
292292
json_output=kw["json_output"],
293293
state=state,
294+
where_flag=kw["where"],
294295
)
295296
else:
296297
return _data_diff(

data_diff/dbt.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ def dbt_diff(
6767
dbt_selection: Optional[str] = None,
6868
json_output: bool = False,
6969
state: Optional[str] = None,
70+
where_flag: Optional[str] = None,
7071
) -> None:
7172
print_version_info()
7273
diff_threads = []
@@ -103,7 +104,7 @@ def dbt_diff(
103104
dbt_parser.set_connection()
104105

105106
for model in models:
106-
diff_vars = _get_diff_vars(dbt_parser, config, model)
107+
diff_vars = _get_diff_vars(dbt_parser, config, model, where_flag)
107108

108109
# we won't always have a prod path when using state
109110
# when the model DNE in prod manifest, skip the model diff
@@ -150,6 +151,7 @@ def _get_diff_vars(
150151
dbt_parser: "DbtParser",
151152
config: TDatadiffConfig,
152153
model,
154+
where_flag: Optional[str] = None,
153155
) -> TDiffVars:
154156
dev_database = model.database
155157
dev_schema = model.schema_
@@ -179,7 +181,8 @@ def _get_diff_vars(
179181
primary_keys=primary_keys,
180182
connection=dbt_parser.connection,
181183
threads=dbt_parser.threads,
182-
where_filter=datadiff_model_config.where_filter,
184+
# --where takes precedence over any model level config
185+
where_filter=where_flag or datadiff_model_config.where_filter,
183186
include_columns=datadiff_model_config.include_columns,
184187
exclude_columns=datadiff_model_config.exclude_columns,
185188
)

0 commit comments

Comments
 (0)