Repository: dbt-labs/dbt-core

Issue:
Cannot set store_failures as test modifier for unique, not_null
### Describe the bug

Cannot set `store_failures` config on `unique` and `not_null` tests:
```yml
  - name: my_model
    columns: 
      - name: id
        tests:
          - not_null:
              store_failures: true # does not take effect
```

These built-in tests use an optimized codepath for test construction at parse time.

We either missed this in the original PR, or it got lost in the git merge/rebases. It's a super simple fix.

While here, I realized that I _think_ we're not doing `unrendered_config` quite right. That's a separate issue to look into. (edit: opened #3576)


Discussion:

Resolving patch:
diff --git a/core/dbt/parser/schemas.py b/core/dbt/parser/schemas.py
--- a/core/dbt/parser/schemas.py
+++ b/core/dbt/parser/schemas.py
@@ -388,6 +388,9 @@ def render_test_update(self, node, config, builder):
             if builder.fail_calc is not None:
                 node.unrendered_config['fail_calc'] = builder.fail_calc
                 node.config['fail_calc'] = builder.fail_calc
+            if builder.store_failures is not None:
+                node.unrendered_config['store_failures'] = builder.store_failures
+                node.config['store_failures'] = builder.store_failures
             # source node tests are processed at patch_source time
             if isinstance(builder.target, UnpatchedSourceDefinition):
                 sources = [builder.target.fqn[-2], builder.target.fqn[-1]]


Test patch:
diff --git a/test/integration/067_store_test_failures_tests/models/schema.yml b/test/integration/067_store_test_failures_tests/models/schema.yml
--- a/test/integration/067_store_test_failures_tests/models/schema.yml
+++ b/test/integration/067_store_test_failures_tests/models/schema.yml
@@ -13,7 +13,8 @@ models:
     columns:
       - name: id
         tests:
-          - unique
+          - unique:
+              store_failures: true
           - not_null
       - name: first_name
         tests:
diff --git a/test/integration/067_store_test_failures_tests/test_store_test_failures.py b/test/integration/067_store_test_failures_tests/test_store_test_failures.py
--- a/test/integration/067_store_test_failures_tests/test_store_test_failures.py
+++ b/test/integration/067_store_test_failures_tests/test_store_test_failures.py
@@ -28,13 +28,23 @@ def project_config(self):
     
     def column_type_overrides(self):
         return {}
+        
+    def run_tests_store_one_failure(self):
+        test_audit_schema = self.unique_schema() + "_dbt_test__audit"
+
+        self.run_dbt(["seed"])
+        self.run_dbt(["run"])
+        self.run_dbt(["test"], expect_pass=False)
+
+        # one test is configured with store_failures: true, make sure it worked
+        self.assertTablesEqual("unique_problematic_model_id", "expected_unique_problematic_model_id", test_audit_schema)
 
     def run_tests_store_failures_and_assert(self):
         test_audit_schema = self.unique_schema() + "_dbt_test__audit"
 
         self.run_dbt(["seed"])
         self.run_dbt(["run"])
-        # make sure this works idempotently
+        # make sure this works idempotently for all tests
         self.run_dbt(["test", "--store-failures"], expect_pass=False)
         results = self.run_dbt(["test", "--store-failures"], expect_pass=False)
 
@@ -71,6 +81,7 @@ def column_type_overrides(self):
     
     @use_profile('postgres')
     def test__postgres__store_and_assert(self):
+        self.run_tests_store_one_failure()
         self.run_tests_store_failures_and_assert()
 
 class RedshiftTestStoreTestFailures(TestStoreTestFailures):