@@ -70,6 +70,7 @@ def dbt_diff(
70
70
json_output : bool = False ,
71
71
state : Optional [str ] = None ,
72
72
log_status_handler : Optional [LogStatusHandler ] = None ,
73
+ where_flag : Optional [str ] = None ,
73
74
) -> None :
74
75
print_version_info ()
75
76
diff_threads = []
@@ -109,7 +110,7 @@ def dbt_diff(
109
110
if log_status_handler :
110
111
log_status_handler .set_prefix (f"Diffing { model .alias } \n " )
111
112
112
- diff_vars = _get_diff_vars (dbt_parser , config , model )
113
+ diff_vars = _get_diff_vars (dbt_parser , config , model , where_flag )
113
114
114
115
# we won't always have a prod path when using state
115
116
# when the model DNE in prod manifest, skip the model diff
@@ -158,6 +159,7 @@ def _get_diff_vars(
158
159
dbt_parser : "DbtParser" ,
159
160
config : TDatadiffConfig ,
160
161
model ,
162
+ where_flag : Optional [str ] = None ,
161
163
) -> TDiffVars :
162
164
dev_database = model .database
163
165
dev_schema = model .schema_
@@ -187,7 +189,8 @@ def _get_diff_vars(
187
189
primary_keys = primary_keys ,
188
190
connection = dbt_parser .connection ,
189
191
threads = dbt_parser .threads ,
190
- where_filter = datadiff_model_config .where_filter ,
192
+ # --where takes precedence over any model level config
193
+ where_filter = where_flag or datadiff_model_config .where_filter ,
191
194
include_columns = datadiff_model_config .include_columns ,
192
195
exclude_columns = datadiff_model_config .exclude_columns ,
193
196
)
0 commit comments