Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Impl] Allow generic tests to accept arbitrary configs #10197

Closed
1 task done
jtcohen6 opened this issue May 21, 2024 · 1 comment · Fixed by #10245
Closed
1 task done

[Impl] Allow generic tests to accept arbitrary configs #10197

jtcohen6 opened this issue May 21, 2024 · 1 comment · Fixed by #10245
Assignees
Labels
Impact: Adapters user docs [docs.getdbt.com] Needs better documentation

Comments

@jtcohen6
Copy link
Contributor

jtcohen6 commented May 21, 2024

Housekeeping

  • I am a maintainer of dbt-core

Short description

Currently, we only support a specific set of named configurations for generic tests. That list is defined here and accessed here.

The context is that we support two syntaxes for passing configs into generic tests:

# recommended since dbt v0.20
models:
  - name: my_model
    columns:
      - name: colour
        tests:
          - accepted_values:
              values: ['blue', 'red']
              config:
                severity: warn
# legacy (supported for backwards compatibility)
models:
  - name: my_model
    columns:
      - name: colour
        tests:
          - accepted_values:
              values: ['blue', 'red']
              severity: warn                

In this example, values is an argument being passed into accepted_values, whereas severity is a configuration being set for the test.

In the legacy syntax, there is no distinction between "arguments" and "configurations." With the new recommended syntax, there is a distinction, because all configs are nested under config.

The desirable outcome is that:

  • Users can pass whatever configs they want into config: (new syntax), e.g. snowflake_warehouse
  • We continue to use the explicit list of named configs to provide backwards compatibility for the legacy syntax

Acceptance criteria

  1. Users can pass whatever configs they want into config: (new syntax), e.g. snowflake_warehouse
  2. We continue to use the explicit list of named configs to provide backwards compatibility for the legacy syntax

To make it concrete: In the following example, accepted_values_my_model_colour__blue__red should end up with both configurations severity: warn and custom_config: custom_value.

models:
  - name: my_model
    columns:
      - name: colour
        tests:
          - accepted_values:
              values: ['blue', 'red']
              severity: warn
              config:
                custom_config: custom_value

Suggested Tests

In the example above, the test should be parsed to have both configs: custom_config via recommended syntax, and severity via old syntax.

It should be possible to write a unit test for this, but the logic is baked into TestBuilder, which is quite complicated. Refactoring that is out of scope for this particular issue.

The closest existing functional test case is this one.

As such, it might be best to create a new functional test instead.

Impact to Other Teams

Adapters

Will backports be required?

no

Context

Original issue:

@FishtownBuildBot
Copy link
Collaborator

Opened a new issue in dbt-labs/docs.getdbt.com: dbt-labs/docs.getdbt.com#5610

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Impact: Adapters user docs [docs.getdbt.com] Needs better documentation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants