Skip to content

Commit

Permalink
More robust solution to avoid time-based model conflicts.
Browse files Browse the repository at this point in the history
  • Loading branch information
VersusFacit committed Sep 27, 2024
1 parent 78c49bc commit 02bf9ed
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions tests/functional/iceberg/test_incremental_models.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import pytest
import time

from pathlib import Path

Expand Down Expand Up @@ -57,6 +58,8 @@


class TestIcebergIncrementalStrategies:
append: str = f"append_{hash(time.time())}"

@pytest.fixture(scope="class")
def project_config_update(self):
return {"flags": {"enable_iceberg_materializations": True}}
Expand All @@ -76,7 +79,7 @@ def setup_class(self, project):
def models(self):
return {
"upstream_table.sql": _MODEL_BASIC_TABLE_MODEL,
"append.sql": _MODEL_INCREMENTAL_ICEBERG_APPEND,
f"{self.append}.sql": _MODEL_INCREMENTAL_ICEBERG_APPEND,
"merge.sql": _MODEL_INCREMENTAL_ICEBERG_MERGE,
"delete_insert.sql": _MODEL_INCREMENTAL_ICEBERG_DELETE_INSERT,
}
Expand All @@ -92,7 +95,7 @@ def __check_correct_operations(self, model_name, /, rows_affected, status="SUCCE
assert run_results[0].adapter_response["rows_affected"] == rows_affected
assert run_results[0].adapter_response["code"] == status

if model_name != "append":
if "append" not in model_name:
run_results, stdout = run_dbt_and_capture(
[
"show",
Expand All @@ -118,9 +121,9 @@ def test_incremental_strategies_with_update(self, project, setup_class):
)
)

run_results = run_dbt(["run", "-s", "append", "merge", "delete_insert"])
run_results = run_dbt(["run", "-s", self.append, "merge", "delete_insert"])
assert len(run_results) == 3

self.__check_correct_operations("append", rows_affected=2)
self.__check_correct_operations(self.append, rows_affected=2)
self.__check_correct_operations("merge", rows_affected=1)
self.__check_correct_operations("delete_insert", rows_affected=1)

0 comments on commit 02bf9ed

Please sign in to comment.