Commit 2d36bee
authored
test: stabilize TestChangingSchema* python-model tests under min-deps (dbt-core 1.11.2) (#1488)
## Problem
The nightly **Integration Tests (Min-Deps)** workflow fails on the
SQL-warehouse shard ([run
26536340109](https://github.com/databricks/dbt-databricks/actions/runs/26536340109)):
```
FAILED tests/functional/adapter/python_model/test_python_model.py::TestChangingSchemaV2::test_changing_unique_tmp_table_suffix
FAILED tests/functional/adapter/python_model/test_python_model.py::TestChangingSchemaIncrementalV2::test_changing_unique_tmp_table_suffix
dbt.exceptions.ParsingError: Failed to render models/schema.yml ...
dbt.exceptions.EnvVarMissingError: Env var required but not provided: 'DBT_TEST_SCHEMA_NAME_VARIABLE'
```
The same `main` commit **passes** these tests on latest-deps (dbt-core
1.11.8) the same night — this is specific to **dbt-core 1.11.2**, newly
exercised since min-deps became first-class CI (#1480, #1476).
## Root cause
Under `--dist=loadfile`, every `test_python_model.py` class runs in one
xdist worker. On dbt-core 1.11.2, a sibling `BasePythonModelTests`
class's `test_source` schema.yml — whose `schema` renders `{{
var(env_var('DBT_TEST_SCHEMA_NAME_VARIABLE')) }}` — leaks into the parse
of a *following* class. The `TestChangingSchema*` classes don't inherit
`BasePythonModelTests`, so they supply neither thing that leaked source
needs:
- `env_var('DBT_TEST_SCHEMA_NAME_VARIABLE')` resolves from the per-class
invocation-context snapshot → needs the env var set.
- `var('test_run_schema')` is resolved by `ConfiguredVar` during schema
rendering, which reads **only `config.cli_vars`**
(`dbt/context/configured.py`) → needs `--vars`, not project-level
`vars:`.
It is position-dependent: `TestChangingSchema` (V1) passes only because
its predecessor has no source; the V2 classes run right after
`TestServerlessCluster*`. dbt-core 1.11.8 isolates parses correctly, so
latest-deps is unaffected.
## Fix
Test-only. A `SchemaNameVarMixin` that (a) sets
`DBT_TEST_SCHEMA_NAME_VARIABLE` via an autouse fixture and (b) passes
`test_run_schema` via `--vars` on `run_dbt` — exactly mirroring
dbt-core's own `BasePythonModelTests`. Applied to all four
`TestChangingSchema*` classes (the two failing V2 classes plus the two
V1 classes, which pass only by ordering luck today). Inert on dbt-core
1.11.8.
## Verification
Against the live SQL warehouse under min-deps (dbt-core 1.11.2), full
file with `-n 2 --dist=loadfile --reruns 1` (faithful to CI):
- Before: **2 failed** (`EnvVarMissingError`) — reproduces CI.
- After: **11 passed, 9 skipped, 0 failed** (both V2 classes pass).1 parent 437a7c3 commit 2d36bee
2 files changed
Lines changed: 44 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
| |||
Lines changed: 43 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
1 | 2 | | |
2 | 3 | | |
3 | 4 | | |
| |||
29 | 30 | | |
30 | 31 | | |
31 | 32 | | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
32 | 58 | | |
33 | 59 | | |
34 | 60 | | |
| |||
84 | 110 | | |
85 | 111 | | |
86 | 112 | | |
87 | | - | |
| 113 | + | |
88 | 114 | | |
89 | 115 | | |
90 | 116 | | |
| |||
96 | 122 | | |
97 | 123 | | |
98 | 124 | | |
99 | | - | |
| 125 | + | |
| 126 | + | |
100 | 127 | | |
101 | 128 | | |
102 | 129 | | |
103 | 130 | | |
104 | 131 | | |
105 | | - | |
| 132 | + | |
106 | 133 | | |
107 | 134 | | |
108 | 135 | | |
| |||
113 | 140 | | |
114 | 141 | | |
115 | 142 | | |
116 | | - | |
| 143 | + | |
117 | 144 | | |
118 | 145 | | |
119 | 146 | | |
| |||
129 | 156 | | |
130 | 157 | | |
131 | 158 | | |
132 | | - | |
133 | | - | |
134 | | - | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
135 | 163 | | |
136 | 164 | | |
137 | 165 | | |
| |||
412 | 440 | | |
413 | 441 | | |
414 | 442 | | |
415 | | - | |
| 443 | + | |
416 | 444 | | |
417 | 445 | | |
418 | 446 | | |
| |||
424 | 452 | | |
425 | 453 | | |
426 | 454 | | |
427 | | - | |
| 455 | + | |
| 456 | + | |
428 | 457 | | |
429 | 458 | | |
430 | 459 | | |
431 | 460 | | |
432 | 461 | | |
433 | | - | |
| 462 | + | |
434 | 463 | | |
435 | 464 | | |
436 | 465 | | |
437 | 466 | | |
438 | 467 | | |
439 | | - | |
| 468 | + | |
440 | 469 | | |
441 | 470 | | |
442 | 471 | | |
| |||
448 | 477 | | |
449 | 478 | | |
450 | 479 | | |
451 | | - | |
| 480 | + | |
| 481 | + | |
452 | 482 | | |
453 | 483 | | |
454 | 484 | | |
455 | 485 | | |
456 | 486 | | |
457 | | - | |
| 487 | + | |
458 | 488 | | |
459 | 489 | | |
460 | 490 | | |
| |||
0 commit comments