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

Ability to write mock_model_relation to custom schema #75

Open
jack-cook-repo opened this issue May 2, 2023 · 1 comment
Open

Ability to write mock_model_relation to custom schema #75

jack-cook-repo opened this issue May 2, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@jack-cook-repo
Copy link

Describe the feature

(Caveat: not sure if this functionality already exists!)

I would like to be able to write the mock_model_relation to a separate schema to the model.

Currently, the model_dmt_{timestamp} models are showing up in our production dataset (alongside model) which are being surfaced in our BI tool. I'd like to put these into a separate schema. Happy to use the custom_schema_name with the generate_schema_name macro if this is possible.

I've done this with the seed files in dbt_project.yml using the seeds/dmt/schema config in my own project.

Describe alternatives you've considered

Tried a few things:

  • Overriding the default___get_model_to_mock macro to replace model with ref("dmt_schema", model.name)
  • Overriding the schemas for models/dbt_datamocktool in dbt_project.yml (doesn't seem to work as it's picking up the schema from the model itself which is defined in my project)
  • Overriding generate_schema_name to check for any models with dmt in the name (again I think this has the same issue as above as it's picking up the schema before adding dmt + suffix)
    My final option here is to have a Python script run after each run of dmt to delete the tables.

Additional context

Working on BigQuery

Are you interested in contributing this feature?

Happy to make the change given some pointers.

@jack-cook-repo jack-cook-repo added the enhancement New feature or request label May 2, 2023
@mjirv
Copy link
Owner

mjirv commented Jun 4, 2023

Hmm, these should be getting created as temporary tables so that this kind of clutter doesn't happen.

{% macro default___get_model_to_mock(model, suffix) %}
    {{ return(make_temp_relation(model.incorporate(type='table'), suffix=suffix)) }}
{% endmacro %}

Can you confirm what dbt, dbt-bigquery, and datamocktool versions you're on?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants