Repository: databricks/dbt-databricks

Issue:
dbt compilation error with not_null model constraint
### Describe the bug
We’ve encountered an issue with model constraints that include more than one column that got introduced in 1.10.0, see [(876)](https://github.com/databricks/dbt-databricks/pull/876).

### Steps To Reproduce
When building a model with a model constraint of type `not_null` for two columns `col1` and `col2` it fails with a compilation error:

```
Compilation Error in model example_model (models/example_model.sql)
  set.add() takes exactly one argument (2 given)
  
  > in macro materialization_table_databricks (macros/materializations/table.sql)
  > called by model example_model (models/example_model.sql)
```

### Expected behavior
Building a model with model constraints that include multiple columns should work as it does in previous versions.

### Screenshots and log output
```
Compilation Error in model example_model (models/example_model.sql)
  set.add() takes exactly one argument (2 given)
  
  > in macro materialization_table_databricks (macros/materializations/table.sql)
  > called by model example_model (models/example_model.sql)
```

### System information
**The output of `dbt --version`:**
```
1.10.0
```

**The operating system you're using:**
Ubuntu 22.04.5 LTS

**The output of `python --version`:**
3.11.11

### Additional context
[Link to the code](https://github.com/databricks/dbt-databricks/blob/4b5dcc534c74eba55ca75976277a82b94f5531ee/dbt/adapters/databricks/constraints.py#L206)

`.add` can be used for adding only one item to a set and `.update` can be used for adding multiple items from another set (or any other iterable)

Hints from issue comments:
@benc-db: Thanks for reporting.

Solution patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index bce0f8ca..5598015e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,9 @@
+## dbt-databricks 1.10.2 (TBD)
+
+### Fixes
+
+- Fix bug with multiple not_null constraints defined on the model level ([1008](https://github.com/databricks/dbt-databricks/pull/1008))
+
 ## dbt-databricks 1.10.1 (Apr 29, 2025)
 
 ### Fixes
diff --git a/dbt/adapters/databricks/constraints.py b/dbt/adapters/databricks/constraints.py
index 9cb08523..104dadcb 100644
--- a/dbt/adapters/databricks/constraints.py
+++ b/dbt/adapters/databricks/constraints.py
@@ -203,7 +203,7 @@ def parse_model_constraints(
         if constraint["type"] == ConstraintType.not_null:
             if not constraint.get("columns"):
                 raise DbtValidationError("not_null constraint on model must have 'columns' defined")
-            column_names.add(*constraint["columns"])
+            column_names.update(constraint["columns"])
         else:
             constraints.append(parse_constraint(constraint))
 


Test patch:
diff --git a/tests/unit/test_constraints.py b/tests/unit/test_constraints.py
index a069055b..34a58d2e 100644
--- a/tests/unit/test_constraints.py
+++ b/tests/unit/test_constraints.py
@@ -276,10 +276,14 @@ class TestParseConstraints:
         ):
             parse_model_constraints(constraints)
 
-    def test_parse_model_constraints__not_nulls(self):
+    def test_parse_model_constraints__not_null_single(self):
         constraints = [{"type": "not_null", "columns": ["id"]}]
         assert ({"id"}, []) == parse_model_constraints(constraints)
 
+    def test_parse_model_constraints__not_nulls(self):
+        constraints = [{"type": "not_null", "columns": ["id", "other"]}]
+        assert ({"id", "other"}, []) == parse_model_constraints(constraints)
+
     def test_parse_model_constraints__model_constraints(self):
         columns = [{"type": "primary_key", "columns": ["id"]}]
         assert (