From f47191f60143f89fc4a80e9b957af11abc57cf9e Mon Sep 17 00:00:00 2001 From: "V. Ganesh" Date: Fri, 15 Jul 2022 16:34:04 +0530 Subject: [PATCH] dbt run for incremental models fail on second run Internal Issue Ticket: https://jira.cloudera.com/projects/DBT/issues/DBT-130 (#42) Test plan: Use the Impala demo project https://github.com/cloudera/dbt-impala-example Generate the first set of fake data, and then run the models using dbt run. Next generate the second set of fake data, and then run the models using dbt run. The second run should terminate without any error, updating the the incremental model. Synopsis: For model definitions that define partition_by clause with a string, the adapter wrongly generates the insert overwrite statement, resulting in an error being thrown by impala. An example model configuration that will generate error (before applying this PR): {{ config( materialized='incremental', partition_by='report_date' ) }} An example model configuration that will not generate error (before applying this PR): {{ config( materialized='incremental', partition_by=['report_date'] ) }} The current PR addresses the issue of defining model config either as a string or array of string. --- dbt/include/impala/macros/insertoverwrite.sql | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/dbt/include/impala/macros/insertoverwrite.sql b/dbt/include/impala/macros/insertoverwrite.sql index b016663..272f728 100644 --- a/dbt/include/impala/macros/insertoverwrite.sql +++ b/dbt/include/impala/macros/insertoverwrite.sql @@ -17,7 +17,11 @@ {%- set partition_cols = config.get('partition_by', validator=validation.any[list]) -%} {% if partition_cols is not none %} - {%- set partition_col = partition_cols[0] -%} + {% if partition_cols is string %} + {%- set partition_col = partition_cols -%} + {% else %} + {%- set partition_col = partition_cols[0] -%} + {% endif %} {%- set dest_cols_csv = get_quoted_csv_exclude(dest_columns | map(attribute="name"), "") -%} {%- set dest_cols_csv_exclude = get_quoted_csv_exclude(dest_columns | map(attribute="name"), partition_col) -%}