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

[CT-908] Allow generic tests to accept arbitrary configs #5532

Closed
jtcohen6 opened this issue Jul 25, 2022 · 4 comments
Closed

[CT-908] Allow generic tests to accept arbitrary configs #5532

jtcohen6 opened this issue Jul 25, 2022 · 4 comments
Assignees
Labels
duplicate This issue or pull request already exists enhancement New feature or request paper_cut A small change that impacts lots of users in their day-to-day
Milestone

Comments

@jtcohen6
Copy link
Contributor

Motivation: dbt-labs/dbt-snowflake#210 (comment)

This is supported:

version: 2
models:
  - name: my_model
    config:
      any_key: any_value

But this isn't:

version: 2
models:
  - name: my_model
    columns:
      - name: id
        tests:
          - unique:
              config:
                any_key: any_value

I think it's because dbt only loads up the test's config property with values from CONFIG_ARGS:

for key in self.CONFIG_ARGS:
value = self.args.pop(key, None)
# 'modifier' config could be either top level arg or in config
if value and "config" in self.args and key in self.args["config"]:
raise_compiler_error(
"Test cannot have the same key at the top-level and in config"
)
if not value and "config" in self.args:
value = self.args["config"].pop(key, None)
if isinstance(value, str):
value = get_rendered(value, render_ctx, native=True)
if value is not None:
self.config[key] = value

Exit criteria: Tests' config property should be able to accept any arbitrary key-value pairs, just like other resource types. Those configs can then be used to set runtime behavior, e.g. in a custom 'test' materialization.

@jtcohen6 jtcohen6 added enhancement New feature or request Team:Language labels Jul 25, 2022
@github-actions github-actions bot changed the title Allow generic tests to accept arbitrary configs [CT-908] Allow generic tests to accept arbitrary configs Jul 25, 2022
@emmyoop
Copy link
Member

emmyoop commented Jul 29, 2022

Will need to change the above for key in self.CONFIG_ARGS: to loop through all the keys in the dict, and if it's CONFIG_ARGS it's adde dot the config and if it's not it's a keyword arg. Then we need to loop through the subdictionay config and save everything as a config.

@github-actions
Copy link
Contributor

This issue has been marked as Stale because it has been open for 180 days with no activity. If you would like the issue to remain open, please comment on the issue or else it will be closed in 7 days.

@github-actions github-actions bot added the stale Issues that have gone stale label Jan 26, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Feb 2, 2023

Although we are closing this issue as stale, it's not gone forever. Issues can be reopened if there is renewed community interest. Just add a comment to notify the maintainers.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Feb 2, 2023
@graciegoheen graciegoheen added paper_cut A small change that impacts lots of users in their day-to-day and removed stale Issues that have gone stale labels May 14, 2024
@graciegoheen graciegoheen reopened this May 14, 2024
@graciegoheen graciegoheen added this to the v1.9 milestone May 14, 2024
@dbeatty10
Copy link
Contributor

I believe this was superseded by #10197 and resolved by #10245. Can re-open if not.

@dbeatty10 dbeatty10 added the duplicate This issue or pull request already exists label Oct 17, 2024
@dbeatty10 dbeatty10 closed this as not planned Won't fix, can't repro, duplicate, stale Oct 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists enhancement New feature or request paper_cut A small change that impacts lots of users in their day-to-day
Projects
None yet
Development

No branches or pull requests

4 participants