[Feature] Allow adapters to override unspecified values in unit tests
- Dominant language
- Rust
- Stars
- 13.8k
- Forks
- 2.6k
- Avg merge
- 21h 31m
- Merged PRs (30d)
- 56
Description
### Is this your first time submitting a feature request?
- [X] I have read the [expectations for open source contributors](https://docs.getdbt.com/docs/contributing/oss-expectations)
- [X] I have searched the existing issues, and I could not find an existing issue for this feature
- [X] I am requesting a straightforward extension of existing dbt functionality, rather than a Big Idea better suited to a discussion
### Describe the feature
The [current unit testing implementation](https://github.com/dbt-labs/dbt-adapters/blob/782a32b530e25afe34af6896392d9fb081dce9d1/dbt/include/global_project/macros/unit_test_sql/get_fixture_sql.sql#L22) fills in `null`s for unspecified values. This is however problematic for databases which have non-nullable datatypes, like Clickhouse, as a cast to `null` will always trigger an error.
Therefore the adapter should be given the option to override the unspecified value depending on the datatype.
The lack of this feature currently blocks unit tests on Clickhouse adapter.
### Describe alternatives you've considered
- Overriding `safe_cast()` macro could be an option. However, a safe cast is supposed to render values in doubt to `null`, which would not work well with non-nullable datatypes. Tampering with the macro just for the purpose of making it work for unit tests would interfere with other usages of `safe_cast()`
- An adapter could override the `get_fixture_sql()` macro. But it's not really intended to be overwritten by an adapter and it would be hard to maintain
### Who will this benefit?
Any database that has not-nullable datatypes, like Clickhouse.
### Are you interested in contributing this feature?
Sure.
### Anything else?
Relates to this [issue](https://github.com/dbt-labs/dbt-core/issues/10418).
Contributor guide
Assessment
This issue has not been assessed yet.