Skip to content

Commit

Permalink
Update logic to use generate_schema_name()
Browse files Browse the repository at this point in the history
  • Loading branch information
b-per committed Nov 11, 2024
1 parent 4a34961 commit b96edd6
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 b96edd6

Please sign in to comment.