Skip to content

Commit 9dc0365

Browse files
authored
Fix non-deterministic test from result set ordering (#1040)
2 parents cf2fc02 + b5f90a5 commit 9dc0365

1 file changed

Lines changed: 10 additions & 8 deletions

File tree

tests/functional/adapter/incremental/test_incremental_constraints.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -210,10 +210,11 @@ def test_add_foreign_key_constraint(self, project):
210210
util.run_dbt(["run"])
211211
referential_constraints = project.run_sql(referential_constraint_sql, fetch="all")
212212
assert len(referential_constraints) == 2
213-
assert referential_constraints[0][0] == "fk_to_parent"
214-
assert referential_constraints[0][1] == "pk_parent"
215-
assert referential_constraints[1][0] == "fk_to_parent_2"
216-
assert referential_constraints[1][1] == "pk_parent_2"
213+
214+
# Convert results to a set of tuples for order-independent comparison
215+
constraint_pairs = {(row[0], row[1]) for row in referential_constraints}
216+
expected_pairs = {("fk_to_parent", "pk_parent"), ("fk_to_parent_2", "pk_parent_2")}
217+
assert constraint_pairs == expected_pairs
217218

218219

219220
@pytest.mark.skip_profile("databricks_cluster")
@@ -240,10 +241,11 @@ def test_remove_foreign_key_constraint(self, project):
240241
# Verify the constraint exists
241242
referential_constraints = project.run_sql(referential_constraint_sql, fetch="all")
242243
assert len(referential_constraints) == 2
243-
assert referential_constraints[0][0] == "fk_to_parent"
244-
assert referential_constraints[0][1] == "pk_parent"
245-
assert referential_constraints[1][0] == "fk_to_parent_2"
246-
assert referential_constraints[1][1] == "pk_parent_2"
244+
245+
# Convert results to a set of tuples for order-independent comparison
246+
constraint_pairs = {(row[0], row[1]) for row in referential_constraints}
247+
expected_pairs = {("fk_to_parent", "pk_parent"), ("fk_to_parent_2", "pk_parent_2")}
248+
assert constraint_pairs == expected_pairs
247249

248250
# Remove foreign key constraint and verify
249251
util.write_file(fixtures.constraint_schema_without_fk_constraint, "models", "schema.yml")

0 commit comments

Comments
 (0)