diff --git a/.changes/unreleased/Fixes-20230109-105325.yaml b/.changes/unreleased/Fixes-20230109-105325.yaml new file mode 100644 index 000000000..2a16883fc --- /dev/null +++ b/.changes/unreleased/Fixes-20230109-105325.yaml @@ -0,0 +1,7 @@ +kind: Fixes +body: stop eliminating trailing whitespace in incremental merge sql +time: 2023-01-09T10:53:25.837837-08:00 +custom: + Author: colin-rogers-dbt + Issue: "457" + PR: "458" diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 0c7d51fa8..140557beb 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -182,11 +182,10 @@ jobs: uses: actions/setup-python@v4.3.0 with: python-version: ${{ matrix.python-version }} - - name: Install python dependencies run: | python -m pip install --user --upgrade pip - python -m pip install --upgrade wheel + python -m pip install --upgrade wheel setuptools twine check-wheel-contents python -m pip --version - uses: actions/download-artifact@v2 with: diff --git a/dbt/include/bigquery/macros/materializations/incremental_strategy/merge.sql b/dbt/include/bigquery/macros/materializations/incremental_strategy/merge.sql index 5efb079b6..57c88dbc8 100644 --- a/dbt/include/bigquery/macros/materializations/incremental_strategy/merge.sql +++ b/dbt/include/bigquery/macros/materializations/incremental_strategy/merge.sql @@ -16,7 +16,7 @@ {{ wrap_with_time_ingestion_partitioning_sql(build_partition_time_exp(partition_by), sql, True) }} {%- else -%} {{sql}} - {%- endif -%} + {%- endif %} ) {%- endif -%} {%- endset -%} diff --git a/setup.py b/setup.py index 07f501ce6..52defb47d 100644 --- a/setup.py +++ b/setup.py @@ -81,6 +81,7 @@ def _dbt_core_version(plugin_version: str) -> str: "googleapis-common-protos~=1.6", "google-cloud-storage~=2.4", "google-cloud-dataproc~=5.0", + "agate>=1.6.3,<1.7", ], zip_safe=False, classifiers=[ diff --git a/tests/functional/test_incremental_materialization.py b/tests/functional/test_incremental_materialization.py new file mode 100644 index 000000000..6932363b3 --- /dev/null +++ b/tests/functional/test_incremental_materialization.py @@ -0,0 +1,44 @@ +import pytest +import os +from dbt.tests.util import ( + run_dbt +) + +# This is a short term hack, we need to go back +# and make adapter implementations of: +# https://github.com/dbt-labs/dbt-core/pull/6330 + +_INCREMENTAL_MODEL = """ +{{ + config( + materialized="incremental", + ) +}} + +{% if not is_incremental() %} + + select 10 as id, cast('2020-01-01 01:00:00' as datetime) as date_hour union all + select 30 as id, cast('2020-01-01 02:00:00' as datetime) as date_hour + +{% else %} + + select 20 as id, cast('2020-01-01 01:00:00' as datetime) as date_hour union all + select 40 as id, cast('2020-01-01 02:00:00' as datetime) as date_hour + +{% endif %} +-- Test Comment To Prevent Reccurence of https://github.com/dbt-labs/dbt-core/issues/6485 +""" + +class BaseIncrementalModelConfig: + @pytest.fixture(scope="class") + def models(self): + return { + "test_incremental.sql": _INCREMENTAL_MODEL + } + +class TestIncrementalModel(BaseIncrementalModelConfig): + def test_incremental_model_succeeds(self, project): + results = run_dbt(["run"]) + assert len(results) == 1 + results = run_dbt(["run"]) + assert len(results) == 1 \ No newline at end of file