-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create schema for external tables when it is not there. (#167)
- Loading branch information
Showing
6 changed files
with
35 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{% macro create_external_schema(source_node) %} | ||
{{ adapter.dispatch('create_external_schema', 'dbt_external_tables')(source_node) }} | ||
{% endmacro %} | ||
|
||
{% macro default__create_external_schema(source_node) %} | ||
{% set ddl %} | ||
create schema if not exists {{ source_node.schema }} | ||
{% endset %} | ||
|
||
{{return(ddl)}} | ||
{% endmacro %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{% macro sqlserver__create_external_schema(source_node) %} | ||
{# https://learn.microsoft.com/en-us/sql/t-sql/statements/create-schema-transact-sql?view=sql-server-ver16 #} | ||
|
||
{% set ddl %} | ||
IF NOT EXISTS (SELECT * FROM sys.schemas WHERE name = '{{ source_node.schema }}') | ||
BEGIN | ||
EXEC('CREATE SCHEMA [{{ source_node.schema }}]') | ||
END | ||
{% endset %} | ||
|
||
{{return(ddl)}} | ||
|
||
{% endmacro %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters