Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## dbt-databricks 1.12.4 (TBD)

### Under the Hood

- Raise the `pytest-rerunfailures` lower bound to `>=16.2` and remove the `SchemaNameVarMixin` workaround so min-deps CI no longer pins 14.0, which leaked class-scoped dbt test fixtures across reruns (test-only, no runtime impact) ([#1618](https://github.com/databricks/dbt-databricks/pull/1618))

## dbt-databricks 1.12.3 (Jul 29, 2026)

### Features
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ test = [
"dbt-tests-adapter>=1.20.0",
"pytest>=8.3.5",
"pytest-xdist>=3.6.1",
"pytest-rerunfailures>=14.0",
"pytest-rerunfailures>=16.2",
"pytest-dotenv>=0.5.2",
"freezegun>=1.5.1",
"pytest-cov>=6.0.0",
Expand Down
6 changes: 3 additions & 3 deletions requirements.lowest-direct.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1060,9 +1060,9 @@ pytest-dotenv==0.5.2 \
--hash=sha256:2dc6c3ac6d8764c71c6d2804e902d0ff810fa19692e95fe138aefc9b1aa73732 \
--hash=sha256:40a2cece120a213898afaa5407673f6bd924b1fa7eafce6bda0e8abffe2f710f
# via dbt-databricks (pyproject.toml:test)
pytest-rerunfailures==14.0 \
--hash=sha256:4197bdd2eaeffdbf50b5ea6e7236f47ff0e44d1def8dae08e409f536d84e7b32 \
--hash=sha256:4a400bcbcd3c7a4ad151ab8afac123d90eca3abe27f98725dc4d9702887d2e92
pytest-rerunfailures==16.2 \
--hash=sha256:5f5a32f15674a3d54f7598388fcd3cc1bc5c37284731a4704a44485dcdda5e23 \
--hash=sha256:c22a53d2827becc76f057d4ded123c0e726523f2f0e5f0bb4efb31fd59e1f14e
# via dbt-databricks (pyproject.toml:test)
pytest-xdist==3.6.1 \
--hash=sha256:9ed4adfb68a016610848639bb7e02c9352d5d9f03d04809919e2dafc3be4cca7 \
Expand Down
63 changes: 17 additions & 46 deletions tests/functional/adapter/python_model/test_python_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,31 +31,6 @@ def verify_temp_table_cleaned(project, suffix):
assert len(tmp_tables) == 0


class SchemaNameVarMixin:
"""Make the schema-change tests resilient to dbt-core test-isolation leakage.

These classes don't inherit ``BasePythonModelTests`` and run plain ``dbt run``. On
dbt-core 1.11.2 a sibling class's ``test_source`` schema.yml -- whose ``schema``
renders ``var(env_var('DBT_TEST_SCHEMA_NAME_VARIABLE'))`` -- can bleed into these
classes' parse when they run after one in the same xdist worker (``--dist=loadfile``),
failing with ``EnvVarMissingError``. Rendering that source needs both the env var
(read from the invocation context) and the ``test_run_schema`` var. Schema-yaml
rendering resolves ``var()`` from CLI vars only, so the var must be passed via
``--vars`` -- exactly as dbt-core's ``BasePythonModelTests`` does -- not via
project-level ``vars``.
"""

@pytest.fixture(scope="class", autouse=True)
def schema_name_env_var(self):
os.environ["DBT_TEST_SCHEMA_NAME_VARIABLE"] = "test_run_schema"
yield
os.environ.pop("DBT_TEST_SCHEMA_NAME_VARIABLE", None)

@staticmethod
def schema_name_vars(project):
return ["--vars", json.dumps({"test_run_schema": project.test_schema})]


class PythonModelDataMixin:
"""Assert that the built ``my_python_model`` holds the expected rows.

Expand Down Expand Up @@ -127,7 +102,7 @@ def project_config_update(self):

@pytest.mark.python
@pytest.mark.skip_profile("databricks_cluster")
class TestChangingSchema(SchemaNameVarMixin):
class TestChangingSchema:
"""Test Python model schema changes using serverless compute."""

@pytest.fixture(scope="class")
Expand All @@ -139,14 +114,13 @@ def project_config_update(self):
return {"models": {"+create_notebook": "true"}}

def test_changing_schema(self, project):
schema_vars = self.schema_name_vars(project)
util.run_dbt(["run", *schema_vars])
util.run_dbt(["run"])
util.write_file(
override_fixtures.simple_python_model_v2,
project.project_root + "/models",
"simple_python_model.py",
)
util.run_dbt(["run", *schema_vars])
util.run_dbt(["run"])
columns = project.run_sql(
"SELECT column_name FROM {database}.information_schema.columns "
"WHERE table_schema = '{schema}' AND table_name = 'simple_python_model' "
Expand All @@ -158,7 +132,7 @@ def test_changing_schema(self, project):

@pytest.mark.python
@pytest.mark.skip_profile("databricks_cluster")
class TestChangingSchemaIncremental(SchemaNameVarMixin):
class TestChangingSchemaIncremental:
"""Test Python incremental schema changes using serverless compute."""

@pytest.fixture(scope="class")
Expand All @@ -174,10 +148,9 @@ def project_config_update(self):
return {"models": {"+create_notebook": "true"}}

def test_changing_schema_via_incremental(self, project):
schema_vars = self.schema_name_vars(project)
util.run_dbt(["seed", *schema_vars])
util.run_dbt(["run", *schema_vars])
util.run_dbt(["run", *schema_vars])
util.run_dbt(["seed"])
util.run_dbt(["run"])
util.run_dbt(["run"])

util.check_relations_equal(project.adapter, ["incremental_model", "expected_incremental"])

Expand Down Expand Up @@ -459,7 +432,7 @@ def test_python_model_with_access_control_list(self, project):


@pytest.mark.skip_profile("databricks_cluster")
class TestChangingSchemaV2(SchemaNameVarMixin, MaterializationV2Mixin):
class TestChangingSchemaV2(MaterializationV2Mixin):
"""Test Python model schema changes with V2 materialization using serverless compute."""

@pytest.fixture(scope="class")
Expand All @@ -471,20 +444,19 @@ def project_config_update(self):
return {"models": {"+create_notebook": "true"}}

def test_changing_unique_tmp_table_suffix(self, project):
schema_vars = self.schema_name_vars(project)
util.run_dbt(["run", *schema_vars])
util.run_dbt(["run"])
util.write_file(
override_fixtures.simple_python_model_v2,
project.project_root + "/models",
"simple_python_model.py",
)
util.run_dbt(["run", *schema_vars])
util.run_dbt(["run"])
verify_temp_tables_cleaned(project)


@pytest.mark.python
@pytest.mark.skip_profile("databricks_cluster")
class TestChangingSchemaIncrementalV2(SchemaNameVarMixin, MaterializationV2Mixin):
class TestChangingSchemaIncrementalV2(MaterializationV2Mixin):
"""Test Python incremental schema changes with V2 materialization using serverless compute."""

@pytest.fixture(scope="class")
Expand All @@ -496,14 +468,13 @@ def project_config_update(self):
return {"models": {"+create_notebook": "true"}}

def test_changing_unique_tmp_table_suffix(self, project):
schema_vars = self.schema_name_vars(project)
util.run_dbt(["run", *schema_vars])
util.run_dbt(["run"])
util.write_file(
override_fixtures.simple_incremental_python_model_v2,
project.project_root + "/models",
"incremental_model.py",
)
util.run_dbt(["run", *schema_vars])
util.run_dbt(["run"])
verify_temp_tables_cleaned(project)


Expand Down Expand Up @@ -587,20 +558,20 @@ def project_config_update(self):


@pytest.mark.python
class TestJobClusterMissingConfig(SchemaNameVarMixin):
class TestJobClusterMissingConfig:
"""job_cluster submission requires job_cluster_config; omitting it fails the run."""

@pytest.fixture(scope="class")
def models(self):
return {"jc_no_config.py": override_fixtures.job_cluster_missing_config_model}

def test_missing_job_cluster_config_fails(self, project):
util.run_dbt(["run", *self.schema_name_vars(project)], expect_pass=False)
util.run_dbt(["run"], expect_pass=False)


@pytest.mark.python
@pytest.mark.skip_profile("databricks_cluster", "databricks_uc_cluster")
class TestAllPurposeClusterMissingClusterId(SchemaNameVarMixin):
class TestAllPurposeClusterMissingClusterId:
"""all_purpose_cluster needs a resolvable cluster_id; on a SQL warehouse connection
neither http_path nor cluster_id resolves to one, so the run fails."""

Expand All @@ -609,7 +580,7 @@ def models(self):
return {"ap_no_cluster.py": override_fixtures.all_purpose_missing_cluster_model}

def test_missing_cluster_id_fails(self, project):
util.run_dbt(["run", *self.schema_name_vars(project)], expect_pass=False)
util.run_dbt(["run"], expect_pass=False)


@pytest.mark.python
Expand Down
4 changes: 2 additions & 2 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading