Skip to content

Commit

Permalink
it
Browse files Browse the repository at this point in the history
  • Loading branch information
case-k-git committed Mar 6, 2024
1 parent f224fbd commit 6cba6ac
Showing 1 changed file with 14 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,20 @@

{% macro get_insert_into_sql(source_relation, target_relation) %}

{%- set source_columns = adapter.get_columns_in_relation(source_relation) -%}
{%- set common_columns = [] -%}
{%- for dest_col in dest_columns -%}
{%- for source_col in source_columns -%}
{%- if dest_col.name == source_col.name -%}
{%- if common_columns.append(dest_col) -%}{%- endif -%}
{%- endif -%}
{%- endfor -%}
{%- endfor -%}
{%- set dest_cols_csv = common_columns | map(attribute='quoted') | join(', ') -%}
insert into table {{ target_relation }} ({{ dest_cols_csv }})
-- {%- set source_columns = adapter.get_columns_in_relation(source_relation) -%}
-- {%- set common_columns = [] -%}
-- {%- for dest_col in dest_columns -%}
-- {%- for source_col in source_columns -%}
-- {%- if dest_col.name == source_col.name -%}
-- {%- if common_columns.append(dest_col) -%}{%- endif -%}
-- {%- endif -%}
-- {%- endfor -%}
-- {%- endfor -%}
-- {%- set dest_cols_csv = common_columns | map(attribute='quoted') | join(', ') -%}
-- insert into table {{ target_relation }} ({{ dest_cols_csv }})
{%- set dest_columns = adapter.get_columns_in_relation(target_relation) -%}
{%- set dest_cols_csv = dest_columns | map(attribute='quoted') | join(', ') -%}
insert into table {{ target_relation }}
select {{dest_cols_csv}} from {{ source_relation }}

{% endmacro %}
Expand Down

0 comments on commit 6cba6ac

Please sign in to comment.