Skip to content

Commit

Permalink
Merge pull request #260 from b-per/fix/259-issue-generate_schema_name
Browse files Browse the repository at this point in the history
Update test macro to wok with custom `generate_schema_name()`
  • Loading branch information
prdpsvs authored Nov 15, 2024
2 parents 4a34961 + b96edd6 commit beedf08
Showing 1 changed file with 4 additions and 3 deletions.
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

0 comments on commit beedf08

Please sign in to comment.