From b4323aac373e42443551cbbba3f0a737f92b2a30 Mon Sep 17 00:00:00 2001 From: Igor Bolshakov Date: Sun, 18 Aug 2024 10:41:34 +0300 Subject: [PATCH] feat: allow adding an empty seed without rows --- .../clickhouse/macros/materializations/seed.sql | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/dbt/include/clickhouse/macros/materializations/seed.sql b/dbt/include/clickhouse/macros/materializations/seed.sql index f05a5ac4..4f105d72 100644 --- a/dbt/include/clickhouse/macros/materializations/seed.sql +++ b/dbt/include/clickhouse/macros/materializations/seed.sql @@ -2,14 +2,16 @@ {% set cols_sql = get_seed_column_quoted_csv(model, agate_table.column_names) %} {% set data_sql = adapter.get_csv_data(agate_table) %} - {% set sql -%} - insert into {{ this.render() }} ({{ cols_sql }}) - {{ adapter.get_model_query_settings(model) }} - format CSV - {{ data_sql }} - {%- endset %} + {% if data_sql %} + {% set sql -%} + insert into {{ this.render() }} ({{ cols_sql }}) + {{ adapter.get_model_query_settings(model) }} + format CSV + {{ data_sql }} + {%- endset %} - {% do adapter.add_query(sql, bindings=agate_table, abridge_sql_log=True) %} + {% do adapter.add_query(sql, bindings=agate_table, abridge_sql_log=True) %} + {% endif %} {% endmacro %} {% macro clickhouse__create_csv_table(model, agate_table) %}