dbt-sqlserver 1.10.0__tar.gz → 1.10.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. dbt_sqlserver-1.10.1/PKG-INFO +271 -0
  2. dbt_sqlserver-1.10.1/README.md +234 -0
  3. dbt_sqlserver-1.10.1/dbt/adapters/sqlserver/__version__.py +1 -0
  4. {dbt_sqlserver-1.10.0 → dbt_sqlserver-1.10.1}/dbt/adapters/sqlserver/relation_configs/__init__.py +8 -0
  5. dbt_sqlserver-1.10.1/dbt/adapters/sqlserver/relation_configs/index.py +605 -0
  6. {dbt_sqlserver-1.10.0 → dbt_sqlserver-1.10.1}/dbt/adapters/sqlserver/sqlserver_adapter.py +218 -4
  7. dbt_sqlserver-1.10.1/dbt/adapters/sqlserver/sqlserver_auth.py +323 -0
  8. dbt_sqlserver-1.10.1/dbt/adapters/sqlserver/sqlserver_backend.py +342 -0
  9. dbt_sqlserver-1.10.1/dbt/adapters/sqlserver/sqlserver_column.py +277 -0
  10. dbt_sqlserver-1.10.1/dbt/adapters/sqlserver/sqlserver_configs.py +16 -0
  11. dbt_sqlserver-1.10.1/dbt/adapters/sqlserver/sqlserver_connections.py +412 -0
  12. dbt_sqlserver-1.10.1/dbt/adapters/sqlserver/sqlserver_constants.py +114 -0
  13. dbt_sqlserver-1.10.1/dbt/adapters/sqlserver/sqlserver_credentials.py +119 -0
  14. dbt_sqlserver-1.10.1/dbt/adapters/sqlserver/sqlserver_helpers.py +297 -0
  15. dbt_sqlserver-1.10.1/dbt/adapters/sqlserver/sqlserver_runtime.py +450 -0
  16. {dbt_sqlserver-1.10.0 → dbt_sqlserver-1.10.1}/dbt/include/sqlserver/macros/adapters/catalog.sql +86 -42
  17. dbt_sqlserver-1.10.1/dbt/include/sqlserver/macros/adapters/columns.sql +114 -0
  18. dbt_sqlserver-1.10.1/dbt/include/sqlserver/macros/adapters/indexes.sql +505 -0
  19. {dbt_sqlserver-1.10.0 → dbt_sqlserver-1.10.1}/dbt/include/sqlserver/macros/adapters/metadata.sql +3 -2
  20. dbt_sqlserver-1.10.1/dbt/include/sqlserver/macros/adapters/persist_docs.sql +137 -0
  21. {dbt_sqlserver-1.10.0 → dbt_sqlserver-1.10.1}/dbt/include/sqlserver/macros/adapters/schema.sql +1 -1
  22. dbt_sqlserver-1.10.1/dbt/include/sqlserver/macros/materializations/hooks.sql +19 -0
  23. {dbt_sqlserver-1.10.0 → dbt_sqlserver-1.10.1}/dbt/include/sqlserver/macros/materializations/models/incremental/incremental.sql +7 -2
  24. {dbt_sqlserver-1.10.0 → dbt_sqlserver-1.10.1}/dbt/include/sqlserver/macros/materializations/models/incremental/incremental_strategies.sql +1 -1
  25. {dbt_sqlserver-1.10.0 → dbt_sqlserver-1.10.1}/dbt/include/sqlserver/macros/materializations/models/incremental/merge.sql +6 -0
  26. {dbt_sqlserver-1.10.0 → dbt_sqlserver-1.10.1}/dbt/include/sqlserver/macros/materializations/models/table/table.sql +1 -1
  27. {dbt_sqlserver-1.10.0 → dbt_sqlserver-1.10.1}/dbt/include/sqlserver/macros/materializations/models/table/table_dml_refresh.sql +18 -4
  28. dbt_sqlserver-1.10.1/dbt/include/sqlserver/macros/materializations/models/unit_test/get_fixture_sql.sql +101 -0
  29. {dbt_sqlserver-1.10.0 → dbt_sqlserver-1.10.1}/dbt/include/sqlserver/macros/materializations/models/view/view.sql +1 -1
  30. {dbt_sqlserver-1.10.0 → dbt_sqlserver-1.10.1}/dbt/include/sqlserver/macros/materializations/snapshots/snapshot.sql +7 -2
  31. {dbt_sqlserver-1.10.0 → dbt_sqlserver-1.10.1}/dbt/include/sqlserver/macros/relations/seeds/helpers.sql +13 -10
  32. {dbt_sqlserver-1.10.0 → dbt_sqlserver-1.10.1}/dbt/include/sqlserver/macros/relations/views/create.sql +0 -3
  33. {dbt_sqlserver-1.10.0 → dbt_sqlserver-1.10.1}/dbt/include/sqlserver/macros/utils/split_part.sql +1 -1
  34. {dbt_sqlserver-1.10.0 → dbt_sqlserver-1.10.1}/dbt/include/sqlserver/profile_template.yml +1 -1
  35. dbt_sqlserver-1.10.1/dbt_sqlserver.egg-info/PKG-INFO +271 -0
  36. {dbt_sqlserver-1.10.0 → dbt_sqlserver-1.10.1}/dbt_sqlserver.egg-info/SOURCES.txt +9 -1
  37. {dbt_sqlserver-1.10.0 → dbt_sqlserver-1.10.1}/dbt_sqlserver.egg-info/requires.txt +5 -0
  38. {dbt_sqlserver-1.10.0 → dbt_sqlserver-1.10.1}/pyproject.toml +29 -1
  39. dbt_sqlserver-1.10.0/PKG-INFO +0 -130
  40. dbt_sqlserver-1.10.0/README.md +0 -97
  41. dbt_sqlserver-1.10.0/dbt/adapters/sqlserver/__version__.py +0 -1
  42. dbt_sqlserver-1.10.0/dbt/adapters/sqlserver/sqlserver_column.py +0 -116
  43. dbt_sqlserver-1.10.0/dbt/adapters/sqlserver/sqlserver_configs.py +0 -9
  44. dbt_sqlserver-1.10.0/dbt/adapters/sqlserver/sqlserver_connections.py +0 -673
  45. dbt_sqlserver-1.10.0/dbt/adapters/sqlserver/sqlserver_credentials.py +0 -74
  46. dbt_sqlserver-1.10.0/dbt/include/sqlserver/macros/adapters/columns.sql +0 -91
  47. dbt_sqlserver-1.10.0/dbt/include/sqlserver/macros/adapters/indexes.sql +0 -238
  48. dbt_sqlserver-1.10.0/dbt/include/sqlserver/macros/materializations/models/table/clone.sql +0 -4
  49. dbt_sqlserver-1.10.0/dbt_sqlserver.egg-info/PKG-INFO +0 -130
  50. {dbt_sqlserver-1.10.0 → dbt_sqlserver-1.10.1}/LICENSE +0 -0
  51. {dbt_sqlserver-1.10.0 → dbt_sqlserver-1.10.1}/dbt/__init__.py +0 -0
  52. {dbt_sqlserver-1.10.0 → dbt_sqlserver-1.10.1}/dbt/adapters/sqlserver/__init__.py +0 -0
  53. {dbt_sqlserver-1.10.0 → dbt_sqlserver-1.10.1}/dbt/adapters/sqlserver/py.typed +0 -0
  54. {dbt_sqlserver-1.10.0 → dbt_sqlserver-1.10.1}/dbt/adapters/sqlserver/relation_configs/policies.py +0 -0
  55. {dbt_sqlserver-1.10.0 → dbt_sqlserver-1.10.1}/dbt/adapters/sqlserver/sqlserver_relation.py +0 -0
  56. {dbt_sqlserver-1.10.0 → dbt_sqlserver-1.10.1}/dbt/include/sqlserver/__init__.py +0 -0
  57. {dbt_sqlserver-1.10.0 → dbt_sqlserver-1.10.1}/dbt/include/sqlserver/dbt_project.yml +0 -0
  58. {dbt_sqlserver-1.10.0 → dbt_sqlserver-1.10.1}/dbt/include/sqlserver/macros/adapters/apply_grants.sql +0 -0
  59. {dbt_sqlserver-1.10.0 → dbt_sqlserver-1.10.1}/dbt/include/sqlserver/macros/adapters/relation.sql +0 -0
  60. {dbt_sqlserver-1.10.0 → dbt_sqlserver-1.10.1}/dbt/include/sqlserver/macros/adapters/show.sql +0 -0
  61. {dbt_sqlserver-1.10.0 → dbt_sqlserver-1.10.1}/dbt/include/sqlserver/macros/adapters/validate_sql.sql +0 -0
  62. {dbt_sqlserver-1.10.0 → dbt_sqlserver-1.10.1}/dbt/include/sqlserver/macros/materializations/models/table/columns_spec_ddl.sql +0 -0
  63. {dbt_sqlserver-1.10.0 → dbt_sqlserver-1.10.1}/dbt/include/sqlserver/macros/materializations/models/unit_test/unit_test_create_table_as.sql +0 -0
  64. {dbt_sqlserver-1.10.0 → dbt_sqlserver-1.10.1}/dbt/include/sqlserver/macros/materializations/models/view/create_view_as.sql +0 -0
  65. {dbt_sqlserver-1.10.0 → dbt_sqlserver-1.10.1}/dbt/include/sqlserver/macros/materializations/snapshots/helpers.sql +0 -0
  66. {dbt_sqlserver-1.10.0 → dbt_sqlserver-1.10.1}/dbt/include/sqlserver/macros/materializations/snapshots/snapshot_merge.sql +0 -0
  67. {dbt_sqlserver-1.10.0 → dbt_sqlserver-1.10.1}/dbt/include/sqlserver/macros/materializations/snapshots/strategies.sql +0 -0
  68. {dbt_sqlserver-1.10.0 → dbt_sqlserver-1.10.1}/dbt/include/sqlserver/macros/materializations/tests.sql +0 -0
  69. {dbt_sqlserver-1.10.0 → dbt_sqlserver-1.10.1}/dbt/include/sqlserver/macros/materializations/unit_tests.sql +0 -0
  70. {dbt_sqlserver-1.10.0 → dbt_sqlserver-1.10.1}/dbt/include/sqlserver/macros/relations/table/clone.sql +0 -0
  71. {dbt_sqlserver-1.10.0 → dbt_sqlserver-1.10.1}/dbt/include/sqlserver/macros/relations/table/create.sql +0 -0
  72. {dbt_sqlserver-1.10.0 → dbt_sqlserver-1.10.1}/dbt/include/sqlserver/macros/utils/any_value.sql +0 -0
  73. {dbt_sqlserver-1.10.0 → dbt_sqlserver-1.10.1}/dbt/include/sqlserver/macros/utils/array_construct.sql +0 -0
  74. {dbt_sqlserver-1.10.0 → dbt_sqlserver-1.10.1}/dbt/include/sqlserver/macros/utils/cast_bool_to_text.sql +0 -0
  75. {dbt_sqlserver-1.10.0 → dbt_sqlserver-1.10.1}/dbt/include/sqlserver/macros/utils/concat.sql +0 -0
  76. {dbt_sqlserver-1.10.0 → dbt_sqlserver-1.10.1}/dbt/include/sqlserver/macros/utils/date_trunc.sql +0 -0
  77. {dbt_sqlserver-1.10.0 → dbt_sqlserver-1.10.1}/dbt/include/sqlserver/macros/utils/dateadd.sql +0 -0
  78. {dbt_sqlserver-1.10.0 → dbt_sqlserver-1.10.1}/dbt/include/sqlserver/macros/utils/get_tables_by_pattern.sql +0 -0
  79. {dbt_sqlserver-1.10.0 → dbt_sqlserver-1.10.1}/dbt/include/sqlserver/macros/utils/hash.sql +0 -0
  80. {dbt_sqlserver-1.10.0 → dbt_sqlserver-1.10.1}/dbt/include/sqlserver/macros/utils/last_day.sql +0 -0
  81. {dbt_sqlserver-1.10.0 → dbt_sqlserver-1.10.1}/dbt/include/sqlserver/macros/utils/length.sql +0 -0
  82. {dbt_sqlserver-1.10.0 → dbt_sqlserver-1.10.1}/dbt/include/sqlserver/macros/utils/listagg.sql +0 -0
  83. {dbt_sqlserver-1.10.0 → dbt_sqlserver-1.10.1}/dbt/include/sqlserver/macros/utils/position.sql +0 -0
  84. {dbt_sqlserver-1.10.0 → dbt_sqlserver-1.10.1}/dbt/include/sqlserver/macros/utils/safe_cast.sql +0 -0
  85. {dbt_sqlserver-1.10.0 → dbt_sqlserver-1.10.1}/dbt/include/sqlserver/macros/utils/timestamps.sql +0 -0
  86. {dbt_sqlserver-1.10.0 → dbt_sqlserver-1.10.1}/dbt_sqlserver.egg-info/dependency_links.txt +0 -0
  87. {dbt_sqlserver-1.10.0 → dbt_sqlserver-1.10.1}/dbt_sqlserver.egg-info/top_level.txt +0 -0
  88. {dbt_sqlserver-1.10.0 → dbt_sqlserver-1.10.1}/setup.cfg +0 -0
@@ -0,0 +1,271 @@
1
+ Metadata-Version: 2.4
2
+ Name: dbt-sqlserver
3
+ Version: 1.10.1
4
+ Summary: A Microsoft SQL Server adapter plugin for dbt
5
+ Author: Mikael Ene, Anders Swanson, Sam Debruyn, Cor Zuurmond, Cody Scott
6
+ License: MIT
7
+ Project-URL: Setup & configuration, https://docs.getdbt.com/reference/warehouse-profiles/mssql-profile
8
+ Project-URL: Documentation & usage, https://docs.getdbt.com/reference/resource-configs/mssql-configs
9
+ Project-URL: Changelog, https://github.com/dbt-msft/dbt-sqlserver/blob/master/CHANGELOG.md
10
+ Project-URL: Issue Tracker, https://github.com/dbt-msft/dbt-sqlserver/issues
11
+ Project-URL: Source, https://github.com/dbt-msft/dbt-sqlserver
12
+ Classifier: Development Status :: 5 - Production/Stable
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Operating System :: Microsoft :: Windows
15
+ Classifier: Operating System :: MacOS :: MacOS X
16
+ Classifier: Operating System :: POSIX :: Linux
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3.13
21
+ Requires-Python: >=3.10
22
+ Description-Content-Type: text/markdown
23
+ License-File: LICENSE
24
+ Requires-Dist: dbt-core<2.0,>=1.10.0
25
+ Requires-Dist: dbt-common<2.0,>=1.22.0
26
+ Requires-Dist: dbt-adapters<2.0,>=1.15.2
27
+ Requires-Dist: pyodbc>=5.2.0
28
+ Provides-Extra: azure
29
+ Requires-Dist: azure-identity>=1.12.0; extra == "azure"
30
+ Provides-Extra: pyodbc
31
+ Requires-Dist: pyodbc>=5.2.0; extra == "pyodbc"
32
+ Provides-Extra: mssql
33
+ Requires-Dist: mssql-python>=1.7.1; extra == "mssql"
34
+ Requires-Dist: azure-identity>=1.12.0; extra == "mssql"
35
+ Requires-Dist: azure-core>=1.0.0; extra == "mssql"
36
+ Dynamic: license-file
37
+
38
+ # dbt-sqlserver
39
+
40
+ [dbt](https://www.getdbt.com) adapter for Microsoft SQL Server and Azure SQL services.
41
+
42
+ The adapter supports dbt-core 1.10 or newer and follows the same versioning scheme.
43
+ E.g. version 1.10.x of the adapter is compatible with dbt-core 1.10.x.
44
+
45
+ ## Supported SQL Server versions
46
+
47
+ The adapter is tested against the following SQL Server versions:
48
+
49
+ | SQL Server version | Supported |
50
+ |---|---|
51
+ | SQL Server 2017 | ✅ (minimum supported version) |
52
+ | SQL Server 2019 | ✅ |
53
+ | SQL Server 2022 | ✅ |
54
+ | SQL Server 2025 | ✅ |
55
+
56
+ The minimum supported SQL Server version is SQL Server 2017; older versions are not supported.
57
+
58
+ SQL Server 2017, 2019, 2022, and 2025 are covered by the integration test suite. Azure SQL Database and Azure SQL Managed Instance are not covered by the integration test suite, but are expected to be compatible.
59
+
60
+ ## Documentation
61
+
62
+ We've bundled all documentation on the dbt docs site:
63
+
64
+ - [Profile setup & authentication](https://docs.getdbt.com/reference/warehouse-profiles/mssql-profile)
65
+ - [Adapter documentation, usage and important notes](https://docs.getdbt.com/reference/resource-configs/mssql-configs)
66
+
67
+ Join us on the [dbt Slack](https://getdbt.slack.com/archives/CMRMDDQ9W) to ask questions, get help, or to discuss the project.
68
+
69
+ ## Installation
70
+
71
+ The default install uses the `pyodbc` backend and includes the `pyodbc` dependency. If you want the optional `mssql-python` backend instead, install the `mssql` extra.
72
+
73
+ Latest version: ![PyPI](https://img.shields.io/pypi/v/dbt-sqlserver?label=latest%20stable&logo=pypi)
74
+ Latest pre-release: ![GitHub tag (latest SemVer pre-release)](https://img.shields.io/github/v/tag/dbt-msft/dbt-sqlserver?include_prereleases&label=latest%20pre-release&logo=pypi)
75
+
76
+
77
+ ### Backend requirements at a glance
78
+
79
+ | Backend | Python package | Debian/Ubuntu system packages |
80
+ |---|---|---|
81
+ | `pyodbc` | `dbt-sqlserver[pyodbc]` or `pyodbc` | `unixodbc-dev` plus the Microsoft ODBC Driver for SQL Server |
82
+ | `mssql-python` | `dbt-sqlserver[mssql]` or `mssql-python` | `libltdl7`, `libkrb5-3`, `libgssapi-krb5-2` |
83
+
84
+
85
+ ### `pyodbc` backend
86
+
87
+ The legacy and currently default ODBC path uses `pyodbc` and the Microsoft ODBC driver.
88
+
89
+ ```shell
90
+ pip install -U dbt-sqlserver
91
+ ```
92
+
93
+ You should migrate to using an explicit extra in preparation for deprecation; the following is equivalent:
94
+
95
+ ```shell
96
+ pip install -U "dbt-sqlserver[pyodbc]"
97
+ ```
98
+
99
+ You also need the Microsoft ODBC driver for SQL Server installed on your system:
100
+ [Windows](https://docs.microsoft.com/en-us/sql/connect/odbc/download-odbc-driver-for-sql-server?view=sql-server-ver16#download-for-windows) |
101
+ [macOS](https://docs.microsoft.com/en-us/sql/connect/odbc/linux-mac/install-microsoft-odbc-driver-sql-server-macos?view=sql-server-ver16) |
102
+ [Linux](https://docs.microsoft.com/en-us/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-sql-server?view=sql-server-ver16)
103
+
104
+ <details><summary>Debian/Ubuntu</summary>
105
+
106
+ Install the ODBC headers as well as the driver linked above:
107
+
108
+ ```shell
109
+ sudo apt-get install -y unixodbc-dev
110
+ ```
111
+
112
+ </details>
113
+
114
+ ### `mssql-python` backend
115
+
116
+ An alternative backend that does not require the ODBC driver.
117
+
118
+ ```shell
119
+ pip install -U "dbt-sqlserver[mssql]"
120
+ ```
121
+
122
+ On Debian/Ubuntu-based systems, `mssql-python` requires these system libraries:
123
+
124
+ ```shell
125
+ sudo apt-get install -y libltdl7 libkrb5-3 libgssapi-krb5-2
126
+ ```
127
+
128
+ Enable it per target in your `profiles.yml`:
129
+
130
+ ```yaml
131
+ your_profile:
132
+ target: dev
133
+ outputs:
134
+ dev:
135
+ type: sqlserver
136
+ host: your-server
137
+ port: 1433
138
+ database: your-database
139
+ schema: dbo
140
+ user: your-user
141
+ password: your-password
142
+ encrypt: true
143
+ trust_cert: false
144
+ backend: mssql-python # <-- enables this backend
145
+ ```
146
+
147
+ ## Changelog
148
+
149
+ See [the changelog](CHANGELOG.md)
150
+
151
+ ## Configuration
152
+
153
+ ### `dbt_sqlserver_use_default_schema_concat`
154
+
155
+ *(default: `false`)* Controls schema name generation when a [custom schema](https://docs.getdbt.com/docs/build/custom-schemas) is set on a model.
156
+
157
+ | Flag value | `custom_schema_name` | Result |
158
+ |---|---|---|
159
+ | `false` (default, legacy) | *(none)* | `target.schema` |
160
+ | `false` (default, legacy) | `"reporting"` | `reporting` |
161
+ | `true` (dbt-core standard) | *(none)* | `target.schema` |
162
+ | `true` (dbt-core standard) | `"reporting"` | `target.schema_reporting` |
163
+
164
+ When `false` (the default), the adapter uses its legacy behaviour: `custom_schema_name` is used **as-is** without being prefixed by `target.schema`.
165
+ When `true`, the adapter delegates to dbt-core's `default__generate_schema_name`, which concatenates `target.schema` + `_` + `custom_schema_name`.
166
+
167
+ **Example usage in `dbt_project.yml`:**
168
+
169
+ ```yaml
170
+ flags:
171
+ dbt_sqlserver_use_default_schema_concat: true # Enable standard schema concatenation
172
+ ```
173
+
174
+ The same setting is also honoured via `vars:` for backwards compatibility; the behavior flag under `flags:` takes precedence when both are set.
175
+
176
+ > **Note:** If you want to permanently customise schema generation and avoid any future changes, override the `sqlserver__generate_schema_name` macro directly in your project instead.
177
+
178
+ ### `backend`
179
+
180
+ *(default: `pyodbc`)* Set to `mssql-python` in a profile target to use the `mssql-python` backend instead of `pyodbc`. The adapter fails if the required backend package (Python dependency), such as `pyodbc` or `mssql-python`, is not installed.
181
+
182
+ ### `dbt_sqlserver_enable_safe_type_expansion`
183
+
184
+ *(default: `false`)* When enabled, allows the adapter to widen column types during incremental model schema expansion beyond same-family string resizes. Supported safe expansions include:
185
+
186
+ - **Cross-family string**: `varchar`/`char` → `nvarchar`/`nchar` (same or larger size)
187
+ - **Integer family**: `bit` → `tinyint` → `smallint` → `int` → `bigint`
188
+ - **Integer → numeric**: `int` → `numeric` (with sufficient precision to hold the integer range)
189
+ - **Numeric precision/scale**: `numeric(p,s)` → `numeric(p2,s2)` where precision and scale both increase
190
+ - **Fixed-money**: `smallmoney` → `money`, `money` → `numeric` (with sufficient precision)
191
+
192
+ Safe expansions are further gated by `column_type_expansion_max_rows` (default 1,000,000 rows) to avoid long-running operations on large tables.
193
+
194
+ ### `dbt_sqlserver_use_dbt_transactions`
195
+
196
+ _(default: `false`)_ When enabled, makes dbt's transaction hooks real at the SQL Server level by emitting `BEGIN TRANSACTION` / `COMMIT TRANSACTION` through the adapter's `add_begin_query` and `add_commit_query` methods.
197
+
198
+ The default is `false`, preserving existing behavior where `begin`/`commit` hooks are logical no-ops and the ODBC driver auto-commits each statement. When `dbt_sqlserver_use_dbt_transactions: true`, the adapter emits real T-SQL transaction statements, and rollback uses `IF @@TRANCOUNT > 0 ROLLBACK TRANSACTION`.
199
+
200
+ The driver connection remains in autocommit mode (`autocommit=true`) in both modes.
201
+
202
+ This mode is opt-in and should be tested carefully with project-specific materializations and hooks.
203
+
204
+ ```yaml
205
+ # dbt_project.yml
206
+ flags:
207
+ dbt_sqlserver_enable_safe_type_expansion: true
208
+ dbt_sqlserver_use_dbt_transactions: true # <-- opt-in; default is false
209
+ ```
210
+
211
+ ### `column_type_expansion_max_rows`
212
+
213
+ *(default: `1000000`)* Per-model config that limits when safe type expansion runs. When the target table exceeds this row count, safe type expansion is skipped (basic same-family string resizes still proceed). Set to `-1` to disable the check entirely.
214
+
215
+ ```sql
216
+ -- In an incremental model
217
+ {{ config(materialized='incremental', unique_key='id',
218
+ column_type_expansion_max_rows=500000) }}
219
+ ```
220
+
221
+ ### `prefer_single_alter_column`
222
+
223
+ *(default: `false`)* Model-level config that controls how `alter_column_type` changes column types on tables. When `false` (default), the adapter uses the safer approach: add a temporary column, copy data, drop the original, and rename. When `true`, the adapter uses a single `ALTER COLUMN` statement, which is faster on small, medium tables and instant on safe type expansions but may fail for types that cannot be implicitly converted.
224
+
225
+ ```sql
226
+ -- In an incremental model
227
+ {{ config(materialized='incremental', unique_key='id',
228
+ prefer_single_alter_column=true) }}
229
+ ```
230
+
231
+ **Compatibility notes:** Enabling `dbt_sqlserver_use_dbt_transactions: true` may expose transaction-state assumptions hidden by autocommit-only mode. Explicit transaction macros may interact with dbt-managed transactions, and cleanup after failed DDL/DML may differ. Review pre/post hooks for in-transaction vs out-of-transaction semantics.
232
+
233
+ ### `as_columnstore`
234
+
235
+ *(default: `true`)* When building a table, the adapter creates a [clustered columnstore index](https://learn.microsoft.com/en-us/sql/relational-databases/indexes/columnstore-indexes-overview) (CCI) on it. Set `as_columnstore: false` to build a plain rowstore table instead.
236
+
237
+ This matters for any table containing a `(n)varchar(max)` or other LOB column, because SQL Server does not allow those data types to participate in a columnstore index. The table build fails with:
238
+
239
+ > Column '...' has a data type that cannot participate in a columnstore index.
240
+
241
+ A common case is dbt's [test failure storage](https://docs.getdbt.com/reference/resource-configs/store_failures): the audit tables can contain `VARCHAR(MAX)` columns (dbt's `STRING` type maps to `VARCHAR(MAX)`), so disable the CCI on those resources:
242
+
243
+ ```yaml
244
+ # dbt_project.yml
245
+ data_tests:
246
+ +store_failures: true
247
+ +as_columnstore: false # avoids CCI on (n)varchar(max) audit columns
248
+ ```
249
+
250
+ You can also set it per model:
251
+
252
+ ```sql
253
+ {{ config(materialized="table", as_columnstore=false) }}
254
+ ```
255
+
256
+ ## Contributing
257
+
258
+ [![Unit tests](https://github.com/dbt-msft/dbt-sqlserver/actions/workflows/unit-tests.yml/badge.svg)](https://github.com/dbt-msft/dbt-sqlserver/actions/workflows/unit-tests.yml)
259
+ [![Integration tests on SQL Server](https://github.com/dbt-msft/dbt-sqlserver/actions/workflows/integration-tests-sqlserver.yml/badge.svg)](https://github.com/dbt-msft/dbt-sqlserver/actions/workflows/integration-tests-sqlserver.yml)
260
+
261
+ This adapter is community-maintained.
262
+ You are welcome to contribute by creating issues, opening or reviewing pull requests, or helping other users in the Slack channel.
263
+ If you're unsure how to get started, check out our [contributing guide](CONTRIBUTING.md).
264
+
265
+ ## License
266
+
267
+ [![PyPI - License](https://img.shields.io/pypi/l/dbt-sqlserver)](https://github.com/dbt-msft/dbt-sqlserver/blob/master/LICENSE)
268
+
269
+ ## Code of Conduct
270
+
271
+ This project and everyone involved is expected to follow the [dbt Code of Conduct](https://community.getdbt.com/code-of-conduct).
@@ -0,0 +1,234 @@
1
+ # dbt-sqlserver
2
+
3
+ [dbt](https://www.getdbt.com) adapter for Microsoft SQL Server and Azure SQL services.
4
+
5
+ The adapter supports dbt-core 1.10 or newer and follows the same versioning scheme.
6
+ E.g. version 1.10.x of the adapter is compatible with dbt-core 1.10.x.
7
+
8
+ ## Supported SQL Server versions
9
+
10
+ The adapter is tested against the following SQL Server versions:
11
+
12
+ | SQL Server version | Supported |
13
+ |---|---|
14
+ | SQL Server 2017 | ✅ (minimum supported version) |
15
+ | SQL Server 2019 | ✅ |
16
+ | SQL Server 2022 | ✅ |
17
+ | SQL Server 2025 | ✅ |
18
+
19
+ The minimum supported SQL Server version is SQL Server 2017; older versions are not supported.
20
+
21
+ SQL Server 2017, 2019, 2022, and 2025 are covered by the integration test suite. Azure SQL Database and Azure SQL Managed Instance are not covered by the integration test suite, but are expected to be compatible.
22
+
23
+ ## Documentation
24
+
25
+ We've bundled all documentation on the dbt docs site:
26
+
27
+ - [Profile setup & authentication](https://docs.getdbt.com/reference/warehouse-profiles/mssql-profile)
28
+ - [Adapter documentation, usage and important notes](https://docs.getdbt.com/reference/resource-configs/mssql-configs)
29
+
30
+ Join us on the [dbt Slack](https://getdbt.slack.com/archives/CMRMDDQ9W) to ask questions, get help, or to discuss the project.
31
+
32
+ ## Installation
33
+
34
+ The default install uses the `pyodbc` backend and includes the `pyodbc` dependency. If you want the optional `mssql-python` backend instead, install the `mssql` extra.
35
+
36
+ Latest version: ![PyPI](https://img.shields.io/pypi/v/dbt-sqlserver?label=latest%20stable&logo=pypi)
37
+ Latest pre-release: ![GitHub tag (latest SemVer pre-release)](https://img.shields.io/github/v/tag/dbt-msft/dbt-sqlserver?include_prereleases&label=latest%20pre-release&logo=pypi)
38
+
39
+
40
+ ### Backend requirements at a glance
41
+
42
+ | Backend | Python package | Debian/Ubuntu system packages |
43
+ |---|---|---|
44
+ | `pyodbc` | `dbt-sqlserver[pyodbc]` or `pyodbc` | `unixodbc-dev` plus the Microsoft ODBC Driver for SQL Server |
45
+ | `mssql-python` | `dbt-sqlserver[mssql]` or `mssql-python` | `libltdl7`, `libkrb5-3`, `libgssapi-krb5-2` |
46
+
47
+
48
+ ### `pyodbc` backend
49
+
50
+ The legacy and currently default ODBC path uses `pyodbc` and the Microsoft ODBC driver.
51
+
52
+ ```shell
53
+ pip install -U dbt-sqlserver
54
+ ```
55
+
56
+ You should migrate to using an explicit extra in preparation for deprecation; the following is equivalent:
57
+
58
+ ```shell
59
+ pip install -U "dbt-sqlserver[pyodbc]"
60
+ ```
61
+
62
+ You also need the Microsoft ODBC driver for SQL Server installed on your system:
63
+ [Windows](https://docs.microsoft.com/en-us/sql/connect/odbc/download-odbc-driver-for-sql-server?view=sql-server-ver16#download-for-windows) |
64
+ [macOS](https://docs.microsoft.com/en-us/sql/connect/odbc/linux-mac/install-microsoft-odbc-driver-sql-server-macos?view=sql-server-ver16) |
65
+ [Linux](https://docs.microsoft.com/en-us/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-sql-server?view=sql-server-ver16)
66
+
67
+ <details><summary>Debian/Ubuntu</summary>
68
+
69
+ Install the ODBC headers as well as the driver linked above:
70
+
71
+ ```shell
72
+ sudo apt-get install -y unixodbc-dev
73
+ ```
74
+
75
+ </details>
76
+
77
+ ### `mssql-python` backend
78
+
79
+ An alternative backend that does not require the ODBC driver.
80
+
81
+ ```shell
82
+ pip install -U "dbt-sqlserver[mssql]"
83
+ ```
84
+
85
+ On Debian/Ubuntu-based systems, `mssql-python` requires these system libraries:
86
+
87
+ ```shell
88
+ sudo apt-get install -y libltdl7 libkrb5-3 libgssapi-krb5-2
89
+ ```
90
+
91
+ Enable it per target in your `profiles.yml`:
92
+
93
+ ```yaml
94
+ your_profile:
95
+ target: dev
96
+ outputs:
97
+ dev:
98
+ type: sqlserver
99
+ host: your-server
100
+ port: 1433
101
+ database: your-database
102
+ schema: dbo
103
+ user: your-user
104
+ password: your-password
105
+ encrypt: true
106
+ trust_cert: false
107
+ backend: mssql-python # <-- enables this backend
108
+ ```
109
+
110
+ ## Changelog
111
+
112
+ See [the changelog](CHANGELOG.md)
113
+
114
+ ## Configuration
115
+
116
+ ### `dbt_sqlserver_use_default_schema_concat`
117
+
118
+ *(default: `false`)* Controls schema name generation when a [custom schema](https://docs.getdbt.com/docs/build/custom-schemas) is set on a model.
119
+
120
+ | Flag value | `custom_schema_name` | Result |
121
+ |---|---|---|
122
+ | `false` (default, legacy) | *(none)* | `target.schema` |
123
+ | `false` (default, legacy) | `"reporting"` | `reporting` |
124
+ | `true` (dbt-core standard) | *(none)* | `target.schema` |
125
+ | `true` (dbt-core standard) | `"reporting"` | `target.schema_reporting` |
126
+
127
+ When `false` (the default), the adapter uses its legacy behaviour: `custom_schema_name` is used **as-is** without being prefixed by `target.schema`.
128
+ When `true`, the adapter delegates to dbt-core's `default__generate_schema_name`, which concatenates `target.schema` + `_` + `custom_schema_name`.
129
+
130
+ **Example usage in `dbt_project.yml`:**
131
+
132
+ ```yaml
133
+ flags:
134
+ dbt_sqlserver_use_default_schema_concat: true # Enable standard schema concatenation
135
+ ```
136
+
137
+ The same setting is also honoured via `vars:` for backwards compatibility; the behavior flag under `flags:` takes precedence when both are set.
138
+
139
+ > **Note:** If you want to permanently customise schema generation and avoid any future changes, override the `sqlserver__generate_schema_name` macro directly in your project instead.
140
+
141
+ ### `backend`
142
+
143
+ *(default: `pyodbc`)* Set to `mssql-python` in a profile target to use the `mssql-python` backend instead of `pyodbc`. The adapter fails if the required backend package (Python dependency), such as `pyodbc` or `mssql-python`, is not installed.
144
+
145
+ ### `dbt_sqlserver_enable_safe_type_expansion`
146
+
147
+ *(default: `false`)* When enabled, allows the adapter to widen column types during incremental model schema expansion beyond same-family string resizes. Supported safe expansions include:
148
+
149
+ - **Cross-family string**: `varchar`/`char` → `nvarchar`/`nchar` (same or larger size)
150
+ - **Integer family**: `bit` → `tinyint` → `smallint` → `int` → `bigint`
151
+ - **Integer → numeric**: `int` → `numeric` (with sufficient precision to hold the integer range)
152
+ - **Numeric precision/scale**: `numeric(p,s)` → `numeric(p2,s2)` where precision and scale both increase
153
+ - **Fixed-money**: `smallmoney` → `money`, `money` → `numeric` (with sufficient precision)
154
+
155
+ Safe expansions are further gated by `column_type_expansion_max_rows` (default 1,000,000 rows) to avoid long-running operations on large tables.
156
+
157
+ ### `dbt_sqlserver_use_dbt_transactions`
158
+
159
+ _(default: `false`)_ When enabled, makes dbt's transaction hooks real at the SQL Server level by emitting `BEGIN TRANSACTION` / `COMMIT TRANSACTION` through the adapter's `add_begin_query` and `add_commit_query` methods.
160
+
161
+ The default is `false`, preserving existing behavior where `begin`/`commit` hooks are logical no-ops and the ODBC driver auto-commits each statement. When `dbt_sqlserver_use_dbt_transactions: true`, the adapter emits real T-SQL transaction statements, and rollback uses `IF @@TRANCOUNT > 0 ROLLBACK TRANSACTION`.
162
+
163
+ The driver connection remains in autocommit mode (`autocommit=true`) in both modes.
164
+
165
+ This mode is opt-in and should be tested carefully with project-specific materializations and hooks.
166
+
167
+ ```yaml
168
+ # dbt_project.yml
169
+ flags:
170
+ dbt_sqlserver_enable_safe_type_expansion: true
171
+ dbt_sqlserver_use_dbt_transactions: true # <-- opt-in; default is false
172
+ ```
173
+
174
+ ### `column_type_expansion_max_rows`
175
+
176
+ *(default: `1000000`)* Per-model config that limits when safe type expansion runs. When the target table exceeds this row count, safe type expansion is skipped (basic same-family string resizes still proceed). Set to `-1` to disable the check entirely.
177
+
178
+ ```sql
179
+ -- In an incremental model
180
+ {{ config(materialized='incremental', unique_key='id',
181
+ column_type_expansion_max_rows=500000) }}
182
+ ```
183
+
184
+ ### `prefer_single_alter_column`
185
+
186
+ *(default: `false`)* Model-level config that controls how `alter_column_type` changes column types on tables. When `false` (default), the adapter uses the safer approach: add a temporary column, copy data, drop the original, and rename. When `true`, the adapter uses a single `ALTER COLUMN` statement, which is faster on small, medium tables and instant on safe type expansions but may fail for types that cannot be implicitly converted.
187
+
188
+ ```sql
189
+ -- In an incremental model
190
+ {{ config(materialized='incremental', unique_key='id',
191
+ prefer_single_alter_column=true) }}
192
+ ```
193
+
194
+ **Compatibility notes:** Enabling `dbt_sqlserver_use_dbt_transactions: true` may expose transaction-state assumptions hidden by autocommit-only mode. Explicit transaction macros may interact with dbt-managed transactions, and cleanup after failed DDL/DML may differ. Review pre/post hooks for in-transaction vs out-of-transaction semantics.
195
+
196
+ ### `as_columnstore`
197
+
198
+ *(default: `true`)* When building a table, the adapter creates a [clustered columnstore index](https://learn.microsoft.com/en-us/sql/relational-databases/indexes/columnstore-indexes-overview) (CCI) on it. Set `as_columnstore: false` to build a plain rowstore table instead.
199
+
200
+ This matters for any table containing a `(n)varchar(max)` or other LOB column, because SQL Server does not allow those data types to participate in a columnstore index. The table build fails with:
201
+
202
+ > Column '...' has a data type that cannot participate in a columnstore index.
203
+
204
+ A common case is dbt's [test failure storage](https://docs.getdbt.com/reference/resource-configs/store_failures): the audit tables can contain `VARCHAR(MAX)` columns (dbt's `STRING` type maps to `VARCHAR(MAX)`), so disable the CCI on those resources:
205
+
206
+ ```yaml
207
+ # dbt_project.yml
208
+ data_tests:
209
+ +store_failures: true
210
+ +as_columnstore: false # avoids CCI on (n)varchar(max) audit columns
211
+ ```
212
+
213
+ You can also set it per model:
214
+
215
+ ```sql
216
+ {{ config(materialized="table", as_columnstore=false) }}
217
+ ```
218
+
219
+ ## Contributing
220
+
221
+ [![Unit tests](https://github.com/dbt-msft/dbt-sqlserver/actions/workflows/unit-tests.yml/badge.svg)](https://github.com/dbt-msft/dbt-sqlserver/actions/workflows/unit-tests.yml)
222
+ [![Integration tests on SQL Server](https://github.com/dbt-msft/dbt-sqlserver/actions/workflows/integration-tests-sqlserver.yml/badge.svg)](https://github.com/dbt-msft/dbt-sqlserver/actions/workflows/integration-tests-sqlserver.yml)
223
+
224
+ This adapter is community-maintained.
225
+ You are welcome to contribute by creating issues, opening or reviewing pull requests, or helping other users in the Slack channel.
226
+ If you're unsure how to get started, check out our [contributing guide](CONTRIBUTING.md).
227
+
228
+ ## License
229
+
230
+ [![PyPI - License](https://img.shields.io/pypi/l/dbt-sqlserver)](https://github.com/dbt-msft/dbt-sqlserver/blob/master/LICENSE)
231
+
232
+ ## Code of Conduct
233
+
234
+ This project and everyone involved is expected to follow the [dbt Code of Conduct](https://community.getdbt.com/code-of-conduct).
@@ -0,0 +1 @@
1
+ version = "1.10.1"
@@ -1,3 +1,8 @@
1
+ from dbt.adapters.sqlserver.relation_configs.index import (
2
+ SQLServerIndexConfig,
3
+ SQLServerIndexConfigChange,
4
+ SQLServerIndexType,
5
+ )
1
6
  from dbt.adapters.sqlserver.relation_configs.policies import (
2
7
  MAX_CHARACTERS_IN_IDENTIFIER,
3
8
  SQLServerIncludePolicy,
@@ -10,4 +15,7 @@ __all__ = [
10
15
  "SQLServerIncludePolicy",
11
16
  "SQLServerQuotePolicy",
12
17
  "SQLServerRelationType",
18
+ "SQLServerIndexType",
19
+ "SQLServerIndexConfig",
20
+ "SQLServerIndexConfigChange",
13
21
  ]