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

Commit 6fd0fbd

Browse files
committed
instantiate MACRO_DEBUGGING global for dbt
1 parent ce52e8b commit 6fd0fbd

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

data_diff/dbt_parser.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from argparse import Namespace
12
from collections import defaultdict
23
import json
34
import os
@@ -22,6 +23,13 @@ def import_dbt_dependencies():
2223
raise RuntimeError("Could not import 'dbt' package. You can install it using: pip install 'data-diff[dbt]'.")
2324

2425
# dbt 1.5+ specific stuff to power selection of models
26+
try:
27+
# ProfileRenderer.render_data() fails without instantiating global flag MACRO_DEBUGGING in dbt-core 1.5
28+
from dbt.flags import set_flags
29+
set_flags(Namespace(MACRO_DEBUGGING=False))
30+
except:
31+
pass
32+
2533
try:
2634
from dbt.cli.main import dbtRunner
2735
except ImportError:
@@ -190,7 +198,7 @@ def get_connection_creds(self) -> Tuple[Dict[str, str], str]:
190198
profiles, dbt_profile_var, f"No profile '{dbt_profile_var}' found in '{profiles_path}'."
191199
)
192200
# values can contain env_vars
193-
rendered_profile = self.ProfileRenderer().render_data(profile)
201+
rendered_profile = self.ProfileRenderer({'flags':{'DBT_MACRO_DEBUGGING': 0}}).render_data(profile)
194202
profile_target = get_from_dict_with_raise(
195203
rendered_profile, "target", f"No target found in profile '{dbt_profile_var}' in '{profiles_path}'."
196204
)

0 commit comments

Comments
 (0)