diff --git a/.changes/unreleased/Fixes-20231013-120628.yaml b/.changes/unreleased/Fixes-20231013-120628.yaml new file mode 100644 index 000000000..a448944ad --- /dev/null +++ b/.changes/unreleased/Fixes-20231013-120628.yaml @@ -0,0 +1,7 @@ +kind: Fixes +body: Overwrite existing rows on existing seed tables. For unmanaged databases (no location specified), the current seed command in + dbt-spark appends to existing seeded tables instead overwriting. +time: 2023-10-13T12:06:28.078483-06:00 +custom: + Author: mv1742 + Issue: "112" diff --git a/dbt/include/spark/macros/materializations/seed.sql b/dbt/include/spark/macros/materializations/seed.sql index 196479cb0..d239295be 100644 --- a/dbt/include/spark/macros/materializations/seed.sql +++ b/dbt/include/spark/macros/materializations/seed.sql @@ -27,7 +27,7 @@ {% endfor %} {% set sql %} - insert into {{ this.render() }} values + insert {% if loop.index0 == 0 -%} overwrite {% else -%} into {% endif -%} {{ this.render() }} values {% for row in chunk -%} ({%- for col_name in agate_table.column_names -%} {%- set inferred_type = adapter.convert_type(agate_table, loop.index0) -%}