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

warn when using recent dbt-core version #517

Merged
merged 2 commits into from
Apr 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions data_diff/dbt_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def import_dbt():
PROJECT_FILE = "dbt_project.yml"
PROFILES_FILE = "profiles.yml"
LOWER_DBT_V = "1.0.0"
UPPER_DBT_V = "1.4.6"
UPPER_DBT_V = "1.4.7"


# https://github.com/dbt-labs/dbt-core/blob/c952d44ec5c2506995fbad75320acbae49125d3d/core/dbt/cli/resolvers.py#L6
Expand Down Expand Up @@ -76,10 +76,12 @@ def get_models(self):
if dbt_version < parse_version("1.3.0"):
self.profiles_dir = legacy_profiles_dir()

if dbt_version < parse_version(LOWER_DBT_V) or dbt_version >= parse_version(UPPER_DBT_V):
if dbt_version < parse_version(LOWER_DBT_V):
raise Exception(
f"Found dbt: v{dbt_version} Expected the dbt project's version to be >= {LOWER_DBT_V} and < {UPPER_DBT_V}"
f"Found dbt: v{dbt_version} Expected the dbt project's version to be >= {LOWER_DBT_V}"
)
elif dbt_version >= parse_version(UPPER_DBT_V):
logger.warning(f"{dbt_version} is a recent version of dbt and may not be fully tested with data-diff! \nPlease report any issues to https://github.com/datafold/data-diff/issues")

success_models = [x.unique_id for x in run_results_obj.results if x.status.name == "success"]
models = [self.manifest_obj.nodes.get(x) for x in success_models]
Expand Down
16 changes: 0 additions & 16 deletions tests/test_dbt.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,22 +89,6 @@ def test_get_models_bad_lower_dbt_version(self, mock_open):
mock_self.parse_manifest.assert_not_called()
self.assertIn("version to be", ex.exception.args[0])

@patch("builtins.open", new_callable=mock_open, read_data="{}")
def test_get_models_bad_upper_dbt_version(self, mock_open):
mock_self = Mock()
mock_self.project_dir = Path()
mock_run_results = Mock()
mock_self.parse_run_results.return_value = mock_run_results
mock_run_results.metadata.dbt_version = "1.5.1"

with self.assertRaises(Exception) as ex:
DbtParser.get_models(mock_self)

mock_open.assert_called_once_with(Path(RUN_RESULTS_PATH))
mock_self.parse_run_results.assert_called_once_with(run_results={})
mock_self.parse_manifest.assert_not_called()
self.assertIn("version to be", ex.exception.args[0])

@patch("builtins.open", new_callable=mock_open, read_data="{}")
def test_get_models_no_success(self, mock_open):
mock_self = Mock()
Expand Down