I have multiple sources with the same table structure, on which various datatests need to be done.
I want to DRY up the definition of my source tests by using yaml anchors e.g.
sources:
- name: source1
schema: schema1
tables: &tables
- name: table1
columns:
- &pk-column
name: column1
data_tests:
- not_null
- unique
- name: table2
columns:
- *pk-column
- name: column2
data_tests:
- relationships:
arguments:
to: source('source1','table1')
field: column1
- name: source2
schema: schema2
tables: *tables
That all works beautifully except that schema2.table2.column2 is tested against schema1.table1.column1 instead of schema2.table1.column1.
Is there any way to define the to argument without providing an explicit source name i.e. so that the schema of table1 is assumed to be the same as the schema of the table2 being tested?
The source macro insists on two arguments, {{source.schema}} does not return anything and {{this.schema}} returns the target schema of the test result.