-
Notifications
You must be signed in to change notification settings - Fork 111
feat: SQL Server 2025 support (plus as_columnstore docs and a store-failures regression test) #721
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
axellpadilla
merged 7 commits into
dbt-msft:feat/sqlserver-2025-support
from
joshmarkovic:feat/sql-server-2025
Jun 25, 2026
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
703862b
feat: add SQL Server 2025 support
joshmarkovic 391080c
docs: document the as_columnstore table config
joshmarkovic 7d8e90b
test: keep empty audit table on passing store-failures run (#601)
joshmarkovic 66634a1
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] c137d80
Update README.md
joshmarkovic 4938cf2
Merge branch 'master' into feat/sql-server-2025
joshmarkovic ad89962
ci: promote SQL Server 2025 to baseline and fix README support section
joshmarkovic File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
102 changes: 102 additions & 0 deletions
102
tests/functional/adapter/mssql/test_store_failures_passing.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,102 @@ | ||
| # flake8: noqa: E501 | ||
| """Regression test for dbt-msft/dbt-sqlserver#601. | ||
|
|
||
| With ``--store-failures``, a test that *passes* must leave behind an empty | ||
| audit relation, not drop it. dbt's contract: "A test's results will always | ||
| replace previous failures for the same test, even if that test results in no | ||
| failures." The SQL Server adapter was reported to ``DROP`` the audit table on a | ||
| passing test instead of replacing it with an empty table (Postgres creates the | ||
| empty table). | ||
|
|
||
| This exercises the exact reported scenario: a passing test configured with | ||
| ``store_failures`` materialized as a ``table``. It asserts the audit relation | ||
| exists, is a base table (not a view), is empty, and survives idempotent re-runs. | ||
| """ | ||
|
|
||
| import pytest | ||
|
|
||
| from dbt.tests.util import run_dbt | ||
|
|
||
| # the default audit schema (_dbt_test__audit) plus the test schema can exceed | ||
| # identifier limits; use a short suffix as the rest of the suite does. | ||
| TEST_AUDIT_SCHEMA_SUFFIX = "dbt_test__aud" | ||
|
|
||
| model__chipmunks = """ | ||
| select 1 as id, 'alvin' as name | ||
| union all | ||
| select 2 as id, 'simon' as name | ||
| """ | ||
|
|
||
| # returns zero rows -> the test passes | ||
| test__passing_601 = """ | ||
| {{ config(store_failures=true, store_failures_as='table') }} | ||
| select * from {{ ref('chipmunks') }} | ||
| where 1 = 2 | ||
| """ | ||
|
|
||
|
|
||
| class TestStoreFailuresPassingKeepsEmptyTable: | ||
| @pytest.fixture(scope="class") | ||
| def models(self): | ||
| return {"chipmunks.sql": model__chipmunks} | ||
|
|
||
| @pytest.fixture(scope="class") | ||
| def tests(self): | ||
| return {"passing_601.sql": test__passing_601} | ||
|
|
||
| @pytest.fixture(scope="class") | ||
| def project_config_update(self): | ||
| return { | ||
| "vars": {"dbt_sqlserver_use_default_schema_concat": True}, | ||
| "data_tests": {"+schema": TEST_AUDIT_SCHEMA_SUFFIX}, | ||
| } | ||
|
|
||
| @pytest.fixture(scope="function", autouse=True) | ||
| def setup(self, project): | ||
| self.audit_schema = f"{project.test_schema}_{TEST_AUDIT_SCHEMA_SUFFIX}" | ||
| run_dbt(["run"]) | ||
| yield | ||
| with project.adapter.connection_named("__test"): | ||
| relation = project.adapter.Relation.create( | ||
| database=project.database, schema=self.audit_schema | ||
| ) | ||
| project.adapter.drop_schema(relation) | ||
|
|
||
| def _assert_empty_audit_table(self, project): | ||
| # type_desc proves the relation exists AND is a user table (not a view). | ||
| # On the #601 bug the relation is dropped, so this returns no rows. | ||
| # Queried via sys catalog (lowercase column names) so it is safe under a | ||
| # case-sensitive database collation. | ||
| rows = project.run_sql( | ||
| f""" | ||
| select o.type_desc | ||
| from sys.objects o | ||
| join sys.schemas s on o.schema_id = s.schema_id | ||
| where s.name = '{self.audit_schema}' | ||
| and o.name = 'passing_601' | ||
| """, | ||
| fetch="all", | ||
| ) | ||
| assert len(rows) == 1 and rows[0][0] == "USER_TABLE", ( | ||
| f"audit relation [{self.audit_schema}].[passing_601] should be a user " | ||
| f"table that persists after a passing store-failures run, got: " | ||
| f"{[tuple(r) for r in rows]}" | ||
| ) | ||
| # and it must be empty (the failures were replaced with nothing) | ||
| count = project.run_sql( | ||
| f"select count(*) from [{self.audit_schema}].[passing_601]", | ||
| fetch="one", | ||
| ) | ||
| assert count[0] == 0, f"audit table should be empty, has {count[0]} rows" | ||
|
|
||
| def test_passing_test_keeps_empty_audit_table(self, project): | ||
| results = run_dbt(["test", "--store-failures"], expect_pass=True) | ||
| assert len(results) == 1 | ||
| assert results[0].status == "pass" | ||
| assert results[0].failures == 0 | ||
| self._assert_empty_audit_table(project) | ||
|
|
||
| # idempotency: a second run must still leave the empty table in place | ||
| results = run_dbt(["test", "--store-failures"], expect_pass=True) | ||
| assert results[0].status == "pass" | ||
| self._assert_empty_audit_table(project) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.