|
1 | 1 | import pytest
|
| 2 | +from dbt.tests.adapter.incremental.fixtures import ( |
| 3 | + _MODELS__A, |
| 4 | + _MODELS__INCREMENTAL_APPEND_NEW_COLUMNS, |
| 5 | + _MODELS__INCREMENTAL_APPEND_NEW_COLUMNS_REMOVE_ONE, |
| 6 | + _MODELS__INCREMENTAL_APPEND_NEW_COLUMNS_REMOVE_ONE_TARGET, |
| 7 | + _MODELS__INCREMENTAL_APPEND_NEW_COLUMNS_TARGET, |
| 8 | + _MODELS__INCREMENTAL_FAIL, |
| 9 | + _MODELS__INCREMENTAL_IGNORE_TARGET, |
| 10 | + _MODELS__INCREMENTAL_SYNC_ALL_COLUMNS, |
| 11 | + _MODELS__INCREMENTAL_SYNC_ALL_COLUMNS_TARGET, |
| 12 | + _MODELS__INCREMENTAL_SYNC_REMOVE_ONLY, |
| 13 | + _MODELS__INCREMENTAL_SYNC_REMOVE_ONLY_TARGET, |
| 14 | +) |
2 | 15 | from dbt.tests.adapter.incremental.test_incremental_on_schema_change import (
|
3 | 16 | BaseIncrementalOnSchemaChange,
|
4 | 17 | )
|
5 | 18 | from dbt.tests.adapter.incremental.test_incremental_predicates import BaseIncrementalPredicates
|
6 | 19 | from dbt.tests.adapter.incremental.test_incremental_unique_id import BaseIncrementalUniqueKey
|
7 | 20 |
|
| 21 | +_MODELS__INCREMENTAL_IGNORE = """ |
| 22 | +{{ |
| 23 | + config( |
| 24 | + materialized='incremental', |
| 25 | + unique_key='id', |
| 26 | + on_schema_change='ignore' |
| 27 | + ) |
| 28 | +}} |
| 29 | +
|
| 30 | +WITH source_data AS (SELECT * FROM {{ ref('model_a') }} ) |
| 31 | +
|
| 32 | +{% if is_incremental() %} |
| 33 | +
|
| 34 | +SELECT |
| 35 | + id, |
| 36 | + field1, |
| 37 | + field2, |
| 38 | + field3, |
| 39 | + field4 |
| 40 | +FROM source_data |
| 41 | +WHERE id NOT IN (SELECT id from {{ this }} ) |
| 42 | +
|
| 43 | +{% else %} |
| 44 | +
|
| 45 | +SELECT TOP 3 id, field1, field2 FROM source_data |
| 46 | +
|
| 47 | +{% endif %} |
| 48 | +""" |
| 49 | + |
8 | 50 |
|
9 | 51 | class TestBaseIncrementalUniqueKeySQLServer(BaseIncrementalUniqueKey):
|
10 | 52 | pass
|
11 | 53 |
|
12 | 54 |
|
13 | 55 | class TestIncrementalOnSchemaChangeSQLServer(BaseIncrementalOnSchemaChange):
|
14 |
| - pass |
| 56 | + @pytest.fixture(scope="class") |
| 57 | + def models(self): |
| 58 | + return { |
| 59 | + "incremental_sync_remove_only.sql": _MODELS__INCREMENTAL_SYNC_REMOVE_ONLY, |
| 60 | + "incremental_ignore.sql": _MODELS__INCREMENTAL_IGNORE, |
| 61 | + "incremental_sync_remove_only_target.sql": _MODELS__INCREMENTAL_SYNC_REMOVE_ONLY_TARGET, # noqa: E501 |
| 62 | + "incremental_ignore_target.sql": _MODELS__INCREMENTAL_IGNORE_TARGET, |
| 63 | + "incremental_fail.sql": _MODELS__INCREMENTAL_FAIL, |
| 64 | + "incremental_sync_all_columns.sql": _MODELS__INCREMENTAL_SYNC_ALL_COLUMNS, |
| 65 | + "incremental_append_new_columns_remove_one.sql": _MODELS__INCREMENTAL_APPEND_NEW_COLUMNS_REMOVE_ONE, # noqa: E501 |
| 66 | + "model_a.sql": _MODELS__A, |
| 67 | + "incremental_append_new_columns_target.sql": _MODELS__INCREMENTAL_APPEND_NEW_COLUMNS_TARGET, # noqa: E501 |
| 68 | + "incremental_append_new_columns.sql": _MODELS__INCREMENTAL_APPEND_NEW_COLUMNS, |
| 69 | + "incremental_sync_all_columns_target.sql": _MODELS__INCREMENTAL_SYNC_ALL_COLUMNS_TARGET, # noqa: E501 |
| 70 | + "incremental_append_new_columns_remove_one_target.sql": _MODELS__INCREMENTAL_APPEND_NEW_COLUMNS_REMOVE_ONE_TARGET, # noqa: E501 |
| 71 | + } |
15 | 72 |
|
16 | 73 |
|
17 | 74 | class TestIncrementalPredicatesDeleteInsertSQLServer(BaseIncrementalPredicates):
|
|
0 commit comments