dbt-labs / dbt-labs/dbt-autofix
[FEAT] more gracefully handle YAML anchors especially when override values are provided?
- Dominant language
- Python
- Stars
- 88
- Forks
- 19
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 13
Description
this may be too large of a can or worms but let me at least describe the user experience that I observed
consider an `schema.yml` in which:
- multiple instances of a test that takes custom arguments are used for various models in the file.
- a test define later uses YAML overrides to slightly modify the inputs as needed
Below is a contrived example of how a user might use overrides (before the test `arguments:` JSON schema change landed).
Below that is what dbt-autofix does with the example
```yml
models:
- name: customers
description: >
This table has basic information about a customer, as well as some derived facts based on a customer's orders
tests:
- dbt_utils.unique_combination_of_columns: &unique_combination_of_columns
combination_of_columns:
- customer_id
- most_recent_order
- name: orders
description: This table has basic information about orders, as well as some derived facts based on payments
tests:
- dbt_utils.unique_combination_of_columns:
<<: *unique_combination_of_columns
combination_of_columns:
- customer_id
- order_date
```
```yml
models:
- name: customers
description: >
This table has basic information about a customer, as well as some derived facts based on a customer's orders
tests:
- dbt_utils.unique_combination_of_columns: &unique_combination_of_columns
arguments: &id001
combination_of_columns:
- customer_id
- order_date
- name: orders
description: This table has basic information about orders, as well as some derived facts based on payments
tests:
- dbt_utils.unique_combination_of_columns:
<<: *unique_combination_of_columns
arguments: *id001
```
Contributor guide
Assessment
This issue has not been assessed yet.