Skip to content

Commit d29fdb7

Browse files
committed
fix a test
1 parent 4b4458b commit d29fdb7

File tree

1 file changed

+58
-1
lines changed

1 file changed

+58
-1
lines changed

tests/functional/adapter/test_incremental.py

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,74 @@
11
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+
)
215
from dbt.tests.adapter.incremental.test_incremental_on_schema_change import (
316
BaseIncrementalOnSchemaChange,
417
)
518
from dbt.tests.adapter.incremental.test_incremental_predicates import BaseIncrementalPredicates
619
from dbt.tests.adapter.incremental.test_incremental_unique_id import BaseIncrementalUniqueKey
720

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+
850

951
class TestBaseIncrementalUniqueKeySQLServer(BaseIncrementalUniqueKey):
1052
pass
1153

1254

1355
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+
}
1572

1673

1774
class TestIncrementalPredicatesDeleteInsertSQLServer(BaseIncrementalPredicates):

0 commit comments

Comments
 (0)