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

Update test macro to wok with custom generate_schema_name() #260

Merged
merged 1 commit into from
Nov 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions dbt/include/synapse/macros/materializations/tests/helpers.sql
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
{% macro synapse__get_test_sql(main_sql, fail_calc, warn_if, error_if, limit) -%}
{% set target_schema = var('synapse_test_schema', generate_schema_name() ) %}

-- Create target schema in synapse db if it does not
IF NOT EXISTS (SELECT * FROM sys.schemas WHERE name = '{{ target.schema }}')
IF NOT EXISTS (SELECT * FROM sys.schemas WHERE name = '{{ target_schema }}')
BEGIN
EXEC('CREATE SCHEMA [{{ target.schema }}]')
EXEC('CREATE SCHEMA [{{ target_schema }}]')
END

{% if main_sql.strip().lower().startswith('with') %}
{% set testview %}
{{ target.schema }}.testview_{{ range(1300, 19000) | random }}
{{ target_schema }}.testview_{{ range(1300, 19000) | random }}
{% endset %}

{% set sql = main_sql.replace("'", "''")%}
Expand Down
Loading