-
Notifications
You must be signed in to change notification settings - Fork 128
Expand file tree
/
Copy pathcreate_or_replace.sql
More file actions
64 lines (55 loc) · 2.21 KB
/
create_or_replace.sql
File metadata and controls
64 lines (55 loc) · 2.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
{% macro create_or_replace(temporary, relation, sql_query) %}
{{
return(
adapter.dispatch("create_or_replace", "elementary")(
temporary, relation, sql_query
)
)
}}
{% endmacro %}
{# Snowflake and Bigquery #}
{% macro default__create_or_replace(temporary, relation, sql_query) %}
{% do elementary.edr_create_table_as(temporary, relation, sql_query) %}
{% endmacro %}
{% macro redshift__create_or_replace(temporary, relation, sql_query) %}
{% do elementary.edr_create_table_as(
temporary, relation, sql_query, drop_first=true, should_commit=true
) %}
{% endmacro %}
{% macro postgres__create_or_replace(temporary, relation, sql_query) %}
{% do elementary.run_query("BEGIN") %}
{% do elementary.edr_create_table_as(
temporary, relation, sql_query, drop_first=true
) %}
{% do elementary.run_query("COMMIT") %}
{% endmacro %}
{% macro spark__create_or_replace(temporary, relation, sql_query) %}
{% do elementary.edr_create_table_as(
temporary, relation, sql_query, drop_first=true, should_commit=true
) %}
{% endmacro %}
{% macro fabricspark__create_or_replace(temporary, relation, sql_query) %}
{{ return(elementary.spark__create_or_replace(temporary, relation, sql_query)) }}
{% endmacro %}
{% macro athena__create_or_replace(temporary, relation, sql_query) %}
{% do elementary.edr_create_table_as(
temporary, relation, sql_query, drop_first=true
) %}
{% endmacro %}
{% macro trino__create_or_replace(temporary, relation, sql_query) %}
{% do elementary.edr_create_table_as(
temporary, relation, sql_query, drop_first=true
) %}
{% endmacro %}
{% macro clickhouse__create_or_replace(temporary, relation, sql_query) %}
{% do elementary.edr_create_table_as(
temporary, relation, sql_query, drop_first=true
) %}
{% endmacro %}
{# DuckDB uses CREATE OR REPLACE TABLE, so drop_first is not needed.
should_commit=true ensures the table survives the ROLLBACK issued by test connections. #}
{% macro duckdb__create_or_replace(temporary, relation, sql_query) %}
{% do elementary.edr_create_table_as(
temporary, relation, sql_query, should_commit=true
) %}
{% endmacro %}