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

Testviews should be created in an expected schema and not dbo #130

Closed
dsjoho opened this issue Feb 27, 2024 · 1 comment
Closed

Testviews should be created in an expected schema and not dbo #130

dsjoho opened this issue Feb 27, 2024 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@dsjoho
Copy link

dsjoho commented Feb 27, 2024

In the macro fabric__get_test_sql in macros/materializations/tests/helpers.sql, the schema for the temporary testview is hardcoded as
dbo.testview_{{ range(1300, 19000) | random}}.
See

{% set testview %}
dbo.testview_{{ range(1300, 19000) | random }}
{% endset %}

This breaks in the situation where dbt does not have access to the dbo schema, or the preferred schema is something else.

I suggest that this should instead utilize the generate_schema_name macro with a custom schema name.
Possibly with a custom_name to allow redirecting it, or just letting it fall through to place the testview in the default schema.

Maybe something like

    {% set testview %}
      {{ generate_schema_name('tests_schema' }}.testview_{{ range(1300, 19000) | random }}
    {% endset %}

Or the sensible way of not providing any custom schema name in which case we just get whatever the target profile uses.

@prdpsvs prdpsvs added the bug Something isn't working label Feb 27, 2024
@prdpsvs prdpsvs self-assigned this Feb 27, 2024
@prdpsvs
Copy link
Collaborator

prdpsvs commented Mar 17, 2024

@dsjoho , I am going to take your suggestion and replace dbo with generate_schema_name macro.

Can you share the steps to invoke fabric__get_test_sql from dbt project? I will run some tests and support something close to this post - https://stackoverflow.com/questions/73563223/dbt-conditionally-set-schema-config

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants