1212from dbt .config .renderer import ProfileRenderer
1313
1414from data_diff .errors import (
15- DbtBigQueryOauthOnlyError ,
16- DbtConnectionNotImplementedError ,
17- DbtCoreNoRunnerError ,
18- DbtNoSuccessfulModelsInRunError ,
19- DbtProfileNotFoundError ,
20- DbtProjectVarsNotFoundError ,
21- DbtRedshiftPasswordOnlyError ,
22- DbtRunResultsVersionError ,
23- DbtSelectNoMatchingModelsError ,
24- DbtSelectUnexpectedError ,
25- DbtSelectVersionTooLowError ,
26- DbtSnowflakeSetConnectionError ,
15+ DataDiffDbtBigQueryOauthOnlyError ,
16+ DataDiffDbtConnectionNotImplementedError ,
17+ DataDiffDbtCoreNoRunnerError ,
18+ DataDiffDbtNoSuccessfulModelsInRunError ,
19+ DataDiffDbtProfileNotFoundError ,
20+ DataDiffDbtProjectVarsNotFoundError ,
21+ DataDiffDbtRedshiftPasswordOnlyError ,
22+ DataDiffDbtRunResultsVersionError ,
23+ DataDiffDbtSelectNoMatchingModelsError ,
24+ DataDiffDbtSelectUnexpectedError ,
25+ DataDiffDbtSelectVersionTooLowError ,
26+ DataDiffDbtSnowflakeSetConnectionError ,
2727)
2828
2929from .utils import getLogger , get_from_dict_with_raise
@@ -108,7 +108,7 @@ def __init__(self, profiles_dir_override: str, project_dir_override: str) -> Non
108108
109109 def get_datadiff_variables (self ) -> dict :
110110 doc_url = "https://docs.datafold.com/development_testing/open_source#configure-your-dbt-project"
111- exception = DbtProjectVarsNotFoundError (
111+ exception = DataDiffDbtProjectVarsNotFoundError (
112112 f"vars: data_diff: section not found in dbt_project.yml.\n \n To solve this, please configure your dbt project: \n { doc_url } \n "
113113 )
114114 vars_dict = get_from_dict_with_raise (self .project_dict , "vars" , exception )
@@ -137,11 +137,11 @@ def get_models(self, dbt_selection: Optional[str] = None):
137137 return self .get_dbt_selection_models (dbt_selection )
138138 # edge case if running data-diff from a separate env than dbt (likely local development)
139139 else :
140- raise DbtCoreNoRunnerError (
140+ raise DataDiffDbtCoreNoRunnerError (
141141 "data-diff is using a dbt-core version < 1.5, update the environment's dbt-core version via pip install 'dbt-core>=1.5' in order to use `--select`"
142142 )
143143 else :
144- raise DbtSelectVersionTooLowError (
144+ raise DataDiffDbtSelectVersionTooLowError (
145145 f"The `--select` feature requires dbt >= 1.5, but your project's manifest.json is from dbt v{ dbt_version } . Please follow these steps to use the `--select` feature: \n 1. Update your dbt-core version via pip install 'dbt-core>=1.5'. Details: https://docs.getdbt.com/docs/core/pip-install#change-dbt-core-versions \n 2. Execute any `dbt` command (`run`, `compile`, `build`) to create a new manifest.json."
146146 )
147147 else :
@@ -178,10 +178,10 @@ def get_dbt_selection_models(self, dbt_selection: str) -> List[str]:
178178 return models
179179
180180 if not results .result :
181- raise DbtSelectNoMatchingModelsError (f"No dbt models found for `--select { dbt_selection } `" )
181+ raise DataDiffDbtSelectNoMatchingModelsError (f"No dbt models found for `--select { dbt_selection } `" )
182182
183183 logger .debug (str (results ))
184- raise DbtSelectUnexpectedError ("Encountered an unexpected error while finding `--select` models" )
184+ raise DataDiffDbtSelectUnexpectedError ("Encountered an unexpected error while finding `--select` models" )
185185
186186 def get_run_results_models (self ):
187187 with open (self .project_dir / RUN_RESULTS_PATH ) as run_results :
@@ -195,7 +195,7 @@ def get_run_results_models(self):
195195 self .profiles_dir = legacy_profiles_dir ()
196196
197197 if dbt_version < parse_version (LOWER_DBT_V ):
198- raise DbtRunResultsVersionError (
198+ raise DataDiffDbtRunResultsVersionError (
199199 f"Found dbt: v{ dbt_version } Expected the dbt project's version to be >= { LOWER_DBT_V } "
200200 )
201201 if dbt_version >= parse_version (UPPER_DBT_V ):
@@ -206,7 +206,7 @@ def get_run_results_models(self):
206206 success_models = [x .unique_id for x in run_results_obj .results if x .status .name == "success" ]
207207 models = [self .manifest_obj .nodes .get (x ) for x in success_models ]
208208 if not models :
209- raise DbtNoSuccessfulModelsInRunError ("Expected > 0 successful models runs from the last dbt command." )
209+ raise DataDiffDbtNoSuccessfulModelsInRunError ("Expected > 0 successful models runs from the last dbt command." )
210210
211211 print (f"Running with data-diff={ __version__ } \n " )
212212 return models
@@ -235,31 +235,31 @@ def get_connection_creds(self) -> Tuple[Dict[str, str], str]:
235235 profile = get_from_dict_with_raise (
236236 profiles ,
237237 dbt_profile_var ,
238- DbtProfileNotFoundError (f"No profile '{ dbt_profile_var } ' found in '{ profiles_path } '." ),
238+ DataDiffDbtProfileNotFoundError (f"No profile '{ dbt_profile_var } ' found in '{ profiles_path } '." ),
239239 )
240240 # values can contain env_vars
241241 rendered_profile = ProfileRenderer ().render_data (profile )
242242 profile_target = get_from_dict_with_raise (
243243 rendered_profile ,
244244 "target" ,
245- DbtProfileNotFoundError (f"No target found in profile '{ dbt_profile_var } ' in '{ profiles_path } '." ),
245+ DataDiffDbtProfileNotFoundError (f"No target found in profile '{ dbt_profile_var } ' in '{ profiles_path } '." ),
246246 )
247247 outputs = get_from_dict_with_raise (
248248 rendered_profile ,
249249 "outputs" ,
250- DbtProfileNotFoundError (f"No outputs found in profile '{ dbt_profile_var } ' in '{ profiles_path } '." ),
250+ DataDiffDbtProfileNotFoundError (f"No outputs found in profile '{ dbt_profile_var } ' in '{ profiles_path } '." ),
251251 )
252252 credentials = get_from_dict_with_raise (
253253 outputs ,
254254 profile_target ,
255- DbtProfileNotFoundError (
255+ DataDiffDbtProfileNotFoundError (
256256 f"No credentials found for target '{ profile_target } ' in profile '{ dbt_profile_var } ' in '{ profiles_path } '."
257257 ),
258258 )
259259 conn_type = get_from_dict_with_raise (
260260 credentials ,
261261 "type" ,
262- DbtProfileNotFoundError (
262+ DataDiffDbtProfileNotFoundError (
263263 f"No type found for target '{ profile_target } ' in profile '{ dbt_profile_var } ' in '{ profiles_path } '."
264264 ),
265265 )
@@ -287,7 +287,7 @@ def set_connection(self):
287287
288288 if credentials .get ("private_key_path" ) is not None :
289289 if credentials .get ("password" ) is not None :
290- raise DbtSnowflakeSetConnectionError ("Cannot use password and key at the same time" )
290+ raise DataDiffDbtSnowflakeSetConnectionError ("Cannot use password and key at the same time" )
291291 conn_info ["key" ] = credentials .get ("private_key_path" )
292292 conn_info ["private_key_passphrase" ] = credentials .get ("private_key_passphrase" )
293293 elif credentials .get ("authenticator" ) is not None :
@@ -296,13 +296,13 @@ def set_connection(self):
296296 elif credentials .get ("password" ) is not None :
297297 conn_info ["password" ] = credentials .get ("password" )
298298 else :
299- raise DbtSnowflakeSetConnectionError ("Snowflake: unsupported auth method" )
299+ raise DataDiffDbtSnowflakeSetConnectionError ("Snowflake: unsupported auth method" )
300300 elif conn_type == "bigquery" :
301301 method = credentials .get ("method" )
302302 # there are many connection types https://docs.getdbt.com/reference/warehouse-setups/bigquery-setup#oauth-via-gcloud
303303 # this assumes that the user is auth'd via `gcloud auth application-default login`
304304 if method is None or method != "oauth" :
305- raise DbtBigQueryOauthOnlyError ("Oauth is the current method supported for Big Query." )
305+ raise DataDiffDbtBigQueryOauthOnlyError ("Oauth is the current method supported for Big Query." )
306306 conn_info = {
307307 "driver" : conn_type ,
308308 "project" : credentials .get ("project" ),
@@ -318,7 +318,7 @@ def set_connection(self):
318318 if (credentials .get ("pass" ) is None and credentials .get ("password" ) is None ) or credentials .get (
319319 "method"
320320 ) == "iam" :
321- raise DbtRedshiftPasswordOnlyError ("Only password authentication is currently supported for Redshift." )
321+ raise DataDiffDbtRedshiftPasswordOnlyError ("Only password authentication is currently supported for Redshift." )
322322 conn_info = {
323323 "driver" : conn_type ,
324324 "host" : credentials .get ("host" ),
@@ -349,7 +349,7 @@ def set_connection(self):
349349 }
350350 self .threads = credentials .get ("threads" )
351351 else :
352- raise DbtConnectionNotImplementedError (f"Provider { conn_type } is not yet supported for dbt diffs" )
352+ raise DataDiffDbtConnectionNotImplementedError (f"Provider { conn_type } is not yet supported for dbt diffs" )
353353
354354 self .connection = conn_info
355355
0 commit comments