Skip to content

dbt drops audit table when test passes and --store-failures #601

@ngmiduc

Description

@ngmiduc

Current Behavior

Regarding the documentation of data tests in dbt, a test without failure should still replace the current audit table that is used to store failures.

A test's results will always replace previous failures for the same test, even if that test results in no failures

in https://docs.getdbt.com/reference/resource-configs/store_failures

I was running a passing test, but the audit table for data errors was dropped.

Apparently it is an adapter problem and not inside dbt-core.

Expected Behavior

There should be an audit table with empty records for the data test.

Steps To Reproduce

  • write a failing test
  • run dbt test --store-failures
  • test fails
  • check DB and audit table
  • table was created by dbt
  • adapt test and make it pass
  • run dbt test --store-failures
  • test passes
  • dbt drops audit table

I have tested also the dbt-postgres adapter and in postgres an empty table is created.

Relevant log output

log: At the end of the test:

�[0m17:22:49.179084 [debug] [Thread-4 (]: SQL status: OK in 0.000 seconds
�[0m17:22:49.180897 [debug] [Thread-4 (]: Applying DROP to: "db"."audit"."test"
�[0m17:22:49.181169 [debug] [Thread-4 (]: Using sqlserver connection "test.project.test"
�[0m17:22:49.181329 [debug] [Thread-4 (]: On test.project.test: /* {"app": "dbt", "dbt_version": "1.8.9", "profile_name": "profile", "target_name": "dev", "node_id": "test.project.test"} */

      
    USE [db];
    EXEC('DROP table IF EXISTS "audit"."test";');

�[0m17:22:49.261114 [debug] [Thread-4 (]: SQL status: OK in 0.000 seconds
�[0m17:22:49.263185 [debug] [Thread-4 (]: On test.project.test: ROLLBACK
�[0m17:22:49.263520 [debug] [Thread-4 (]: On test.project.test: Close

Environment

- OS: MacOs
- Python: Python 3.12.7


Core:
  - installed: 1.8.9

Plugins:
  - sqlserver: 1.8.7 - Up to date!

Additional Context

  • dbt is executed programmatically in python
  • the test is a singular test

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions