File tree Expand file tree Collapse file tree 2 files changed +29
-3
lines changed
dbt/include/sqlserver/macros/adapters Expand file tree Collapse file tree 2 files changed +29
-3
lines changed Original file line number Diff line number Diff line change 1
1
{% macro sqlserver__create_schema(relation) - %}
2
- {% auth = config .get (" auth " ) %}
2
+ {% auth = config .get (" schema_authorization " ) %}
3
3
{% call statement(' create_schema' ) - %}
4
4
USE [{{ relation .database }}];
5
- IF NOT EXISTS (SELECT * FROM sys .schemas WHERE name = ' {{ relation.without_identifier(). schema }}' )
5
+ IF NOT EXISTS (SELECT * FROM sys .schemas WHERE name = ' {{ relation.schema }}' )
6
6
BEGIN
7
- EXEC(' CREATE SCHEMA [{{ relation.without_identifier(). schema }}] {%- if auth - %} AUTHORIZATION: [{{auth }}]' )
7
+ EXEC(' CREATE SCHEMA [{{ relation.schema }}] {% if schema_authorization %} AUTHORIZATION: [{{ schema_authorization }}] {% endif %} ' )
8
8
END
9
9
{% endcall %}
10
10
{% endmacro %}
Original file line number Diff line number Diff line change
1
+ import pytest
2
+ from dbt .tests .util import run_dbt
3
+
4
+
5
+ class TestSchemaCreation :
6
+ @pytest .fixture (scope = "class" )
7
+ def project_config_update (self ):
8
+ return {"name" : "schema_tests" }
9
+
10
+ @pytest .fixture (scope = "class" )
11
+ def models (self ):
12
+ return {
13
+ "dummy.sql" : "select 1 as id" ,
14
+ "dummy_with_auth.sql" : """
15
+ {{ config(schema_authorization=env_var('DBT_TEST_USER_1')) }}
16
+ select 1 as id
17
+ """ ,
18
+ }
19
+
20
+ def test_schema_creation (self , project ):
21
+ res = run_dbt (["run" , "-s" , "dummy" ])
22
+ assert len (res ) == 1
23
+
24
+ def test_schema_creation_with_auth (self , project ):
25
+ res = run_dbt (["run" , "-s" , "dummy_with_auth" ])
26
+ assert len (res ) == 1
You can’t perform that action at this time.
0 commit comments