dbt-labs / dbt-labs/dbt-adapters

[Bug] data issue building snapshots with both `--empty` and `hard_deletes: invalidate`

Open
#1,329 0 comments 0 reactions 0 assignees View on GitHub
feature:snapshots triage:product type:bug
Dominant language
Python
Stars
233
Forks
362
Avg merge
3d 22h
Merged PRs (30d)
9

Description

### Is this a new bug?

- [x] I believe this is a new bug
- [x] I have searched the existing issues, and I could not find an existing issue for this bug

### Which packages are affected?

- [x] dbt-adapters
- [ ] dbt-tests-adapter
- [ ] dbt-athena
- [ ] dbt-athena-community
- [ ] dbt-bigquery
- [ ] dbt-postgres
- [ ] dbt-redshift
- [ ] dbt-snowflake
- [ ] dbt-spark

### Current Behavior

Building a snapshot with `hard_deletes: invalidate` using the `--empty` flag closes the validity of all records.

### Expected Behavior

Running dbt with `--empty` flag should not change the data in the target database

### Steps To Reproduce

1. build a snapshot and load some data, adding the `hard_deletes: invalidate` config
2. load the snapshot with the `--empty` flag
3. check the data in the database: all the records have been invalidated (i.e. have `dbt_valid_to` colum set to the current timestamp)

### Relevant log output

```shell

```

### Environment

```markdown
- OS: Ubuntu 24.04 (WSL)
- Python: 3.12.3
- dbt-adapters: 1.9.1
- dbt-bigquery: 1.9.1
```

### Additional Context

Looking in the logs, the `snapshotted_data` CTE does not contain the filter that usually dbt adds to any ref/source

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.