Skip to content

Commit

Permalink
migrate away from spark specific version of test to universal one test
Browse files Browse the repository at this point in the history
  • Loading branch information
McKnight-42 committed Aug 1, 2024
1 parent 0acef8e commit bb5efcd
Showing 1 changed file with 3 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from dbt.tests.adapter.incremental.test_incremental_on_schema_change import (
BaseIncrementalOnSchemaChangeSetup,
BaseIncrementalCaseSenstivityOnSchemaChange,
)


Expand Down Expand Up @@ -82,56 +83,5 @@ def test_run_incremental_sync_all_columns(self, project):
self.run_incremental_sync_remove_only(project)


_MODELS__SRC_ARTISTS = """
{{
config(
materialized='table',
)
}}
{% if var("version", 0) == 0 %}
select {{ dbt.current_timestamp() }} as inserted_at, 'john' as name
{% else %}
-- add a non-zero version to the end of the command to get a different version:
-- --vars "{'version': 1}"
select {{ dbt.current_timestamp() }} as inserted_at, 'john' as name, 'engineer' as `Job`
{% endif %}
"""

_MODELS__DIM_ARTISTS = """
{{
config(
materialized='incremental',
on_schema_change='append_new_columns',
)
}}
select * from {{ ref("src_artists") }}
"""


@pytest.mark.skip_profile("apache_spark", "spark_session")
class TestIncrementalCaseSenstivityOnSchemaChange:
@pytest.fixture(scope="class")
def models(self):
return {
"src_artists.sql": _MODELS__SRC_ARTISTS,
"dim_artists.sql": _MODELS__DIM_ARTISTS,
}

def test_run_incremental_check_quoting_on_new_columns(self, project):
select = "src_artists dim_artists"
run_dbt(["run", "--models", select, "--full-refresh"])
res, logs = run_dbt_and_capture(
["show", "--inline", "select * from {{ ref('dim_artists') }}"]
)
assert "Job" not in logs

run_dbt(["run", "--vars", "{'version': 1}"])
res, logs = run_dbt_and_capture(
["show", "--inline", "select * from {{ ref('dim_artists') }}"]
)
assert "Job" in logs
class TestIncrementalCaseSenstivityOnSchemaChange(BaseIncrementalCaseSenstivityOnSchemaChange):
pass

0 comments on commit bb5efcd

Please sign in to comment.