|
38 | 38 | {%- endfor -%} |
39 | 39 | {%- set dest_cols_csv = dest_columns | join(', ') -%} |
40 | 40 | {%- set source_cols_csv = common_columns | join(', ') -%} |
41 | | - |
42 | | - {%- if adapter.compare_dbr_version(16, 3) >= 0 -%} |
43 | | - {{ get_insert_replace_using_sql(source_relation, target_relation, source_cols_csv) }} |
44 | | - {%- else -%} |
45 | | - {#-- Use traditional INSERT OVERWRITE for older DBR versions --#} |
46 | | - insert overwrite table {{ target_relation }} |
47 | | - {{ partition_cols(label="partition") }} |
48 | | - select {{ source_cols_csv }} from {{ source_relation }} |
49 | | - {%- endif -%} |
50 | | -{% endmacro %} |
51 | | - |
52 | | -{% macro get_insert_replace_using_sql(source_relation, target_relation, source_cols_csv) %} |
53 | | - {%- set partition_by = config.get('partition_by') -%} |
54 | | - {%- if partition_by -%} |
55 | | - {%- if partition_by is string -%} |
56 | | - {%- set partition_by = [partition_by] -%} |
57 | | - {%- endif -%} |
58 | | - {%- set partition_cols_csv = partition_by | join(', ') -%} |
59 | | - insert into table {{ target_relation }} |
60 | | - replace using ({{ partition_cols_csv }}) |
61 | | - select {{ source_cols_csv }} from {{ source_relation }} |
62 | | - {%- else -%} |
63 | | - {#-- Fallback to regular insert if no partitions defined --#} |
64 | | - insert overwrite table {{ target_relation }} |
65 | | - select {{ source_cols_csv }} from {{ source_relation }} |
66 | | - {%- endif -%} |
| 41 | + insert overwrite table {{ target_relation }} |
| 42 | + {{ partition_cols(label="partition") }} |
| 43 | + select {{source_cols_csv}} from {{ source_relation }} |
67 | 44 | {% endmacro %} |
68 | 45 |
|
69 | 46 | {% macro get_replace_where_sql(args_dict) -%} |
|
0 commit comments