<@U088WCP3B4P> I have different datasets with GA e...
# ask-elementary-ai
g
@kapa.ai I have different datasets with GA events information for different countries, can I create a single elementary tests file for all of them? They have the same structure, I would like to use a single code somehow identifying the country for each test. The tests are all going to be the same
k
A message from kapa.ai
Based on the knowledge sources, it is not currently possible in open-source Elementary (or dbt in general) to define a single test file that applies the same test logic to multiple datasets (models or tables) in a global or bulk fashion. Each test must be defined per model/table in your YAML files. This is a limitation of how dbt tests are structured: tests are attached to specific models or columns, not to groups of models or sources collectively. Therefore, you would need to duplicate the test definitions for each dataset, even if they have the same structure and the tests are identical [Global tests not supported](https://slack.com/archives/C02CTC89LAX/p1686303441766419), [Bulk test definition limitations](https://slack.com/archives/C02CTC89LAX/p1689113314530069), [dbt test structure](https://slack.com/archives/C02CTC89LAX/p1730166544999759). Some users have worked around this by writing scripts to generate the YAML files programmatically, which can help automate the repetitive task of adding the same test to multiple models [Script suggestion](https://slack.com/archives/C02CTC89LAX/p1730166544999759). If you are using Elementary Cloud, there are features that allow for more global or automated test configuration through the UI, but this is not available in the open-source version [Cloud features](https://slack.com/archives/C02CTC89LAX/p1692800257468189). In summary: - You cannot define a single test file for all datasets in open-source Elementary/dbt. - You must define the test for each dataset/model. - Scripting the YAML generation is a common workaround. - Elementary Cloud may offer more flexibility for global test configuration. Let me know if you’d like guidance on scripting or have questions about the cloud product!
g
@kapa.ai currently, Im definining the sources with the following code:
Copy code
version: 2

sources:
  - name: xxxx
    database: yyyy
    schema: zzzz
    tables:
      - name: table_spain
I would like to add tests for other tables like "table_uk", "table_germany" and etc. and then define the tests, still not possible?
k
A message from kapa.ai
Based on the knowledge sources, it is not possible to define a single set of tests at the source level that will automatically apply to all tables (like "table_spain", "table_uk", "table_germany", etc.) within that source in your YAML file. You must explicitly define the tests for each table individually in your source configuration. This is a limitation of dbt and, by extension, Elementary, since tests must be attached to specific tables or columns in the YAML configuration. For example, you would need to do something like this:
Copy code
yaml version: 2  sources:   - name: xxxx     database: yyyy     schema: zzzz     tables:       - name: table_spain         tests:           - elementary.schema_changes       - name: table_uk         tests:           - elementary.schema_changes       - name: table_germany         tests:           - elementary.schema_changes
There is no built-in way to define the test once and have it automatically apply to all tables under a source. Users often automate this process by generating the YAML files with scripts, but this is outside the native capabilities of dbt and Elementary [see: "not possible" and scripting workaround](https://slack.com/archives/C02CTC89LAX/p1684199838837299), [bulk test definition limitations](https://slack.com/archives/C02CTC89LAX/p1689113314530069). If you have many tables with the same structure and want to avoid manual duplication, scripting the YAML generation is the recommended approach.