From bf30b66bab0e96dd4d100f45c2818daa5dde456d Mon Sep 17 00:00:00 2001 From: tnk-ysk <61967017+tnk-ysk@users.noreply.github.com> Date: Thu, 9 Nov 2023 01:26:14 +0900 Subject: [PATCH] Fix inline comments (--) on the last line of an incremental model (partition replacement) (#991) * Fix inline comments on the last line * Add changes * Add test for comment --------- Co-authored-by: Mike Alfare <13974384+mikealfare@users.noreply.github.com> --- .changes/unreleased/Fixes-20231105-125740.yaml | 6 ++++++ .../incremental_strategy/insert_overwrite.sql | 2 +- .../adapter/incremental/incremental_strategy_fixtures.py | 1 + 3 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 .changes/unreleased/Fixes-20231105-125740.yaml diff --git a/.changes/unreleased/Fixes-20231105-125740.yaml b/.changes/unreleased/Fixes-20231105-125740.yaml new file mode 100644 index 000000000..928fbb302 --- /dev/null +++ b/.changes/unreleased/Fixes-20231105-125740.yaml @@ -0,0 +1,6 @@ +kind: Fixes +body: Fix inline comments (--) on the last line of an incremental model +time: 2023-11-05T12:57:40.289399+09:00 +custom: + Author: tnk-ysk + Issue: "896" diff --git a/dbt/include/bigquery/macros/materializations/incremental_strategy/insert_overwrite.sql b/dbt/include/bigquery/macros/materializations/incremental_strategy/insert_overwrite.sql index 4c22fd376..3ba67931e 100644 --- a/dbt/include/bigquery/macros/materializations/incremental_strategy/insert_overwrite.sql +++ b/dbt/include/bigquery/macros/materializations/incremental_strategy/insert_overwrite.sql @@ -70,7 +70,7 @@ {{ wrap_with_time_ingestion_partitioning_sql(partition_by, sql, True) }} {%- else -%} {{sql}} - {%- endif -%} + {%- endif %} ) {%- endset -%} diff --git a/tests/functional/adapter/incremental/incremental_strategy_fixtures.py b/tests/functional/adapter/incremental/incremental_strategy_fixtures.py index 8dd470ffb..a8f0004c5 100644 --- a/tests/functional/adapter/incremental/incremental_strategy_fixtures.py +++ b/tests/functional/adapter/incremental/incremental_strategy_fixtures.py @@ -306,6 +306,7 @@ {% if is_incremental() %} where date_day in ({{ config.get("partitions") | join(",") }}) {% endif %} +-- Test comment to prevent recurrence of https://github.com/dbt-labs/dbt-bigquery/issues/896 """.lstrip() overwrite_range_sql = """