dbt-labs / dbt-core

dbt enables data analysts and engineers to transform their data using the same practices that software engineers use to build applications.

Home Page:https://getdbt.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Feature] Allow adapters to override unspecified values in unit tests

steffen030 opened this issue · comments

Is this your first time submitting a feature request?

  • I have read the expectations for open source contributors
  • I have searched the existing issues, and I could not find an existing issue for this feature
  • 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 fills in nulls 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.