dbt-sqlserver 1.10.0__tar.gz → 1.10.1rc1__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.
- dbt_sqlserver-1.10.1rc1/PKG-INFO +235 -0
- dbt_sqlserver-1.10.1rc1/README.md +198 -0
- dbt_sqlserver-1.10.1rc1/dbt/adapters/sqlserver/__version__.py +1 -0
- {dbt_sqlserver-1.10.0 → dbt_sqlserver-1.10.1rc1}/dbt/adapters/sqlserver/relation_configs/__init__.py +8 -0
- dbt_sqlserver-1.10.1rc1/dbt/adapters/sqlserver/relation_configs/index.py +605 -0
- {dbt_sqlserver-1.10.0 → dbt_sqlserver-1.10.1rc1}/dbt/adapters/sqlserver/sqlserver_adapter.py +218 -4
- dbt_sqlserver-1.10.1rc1/dbt/adapters/sqlserver/sqlserver_auth.py +323 -0
- dbt_sqlserver-1.10.1rc1/dbt/adapters/sqlserver/sqlserver_backend.py +342 -0
- dbt_sqlserver-1.10.1rc1/dbt/adapters/sqlserver/sqlserver_column.py +277 -0
- dbt_sqlserver-1.10.1rc1/dbt/adapters/sqlserver/sqlserver_configs.py +16 -0
- dbt_sqlserver-1.10.1rc1/dbt/adapters/sqlserver/sqlserver_connections.py +367 -0
- dbt_sqlserver-1.10.1rc1/dbt/adapters/sqlserver/sqlserver_constants.py +114 -0
- dbt_sqlserver-1.10.1rc1/dbt/adapters/sqlserver/sqlserver_credentials.py +119 -0
- dbt_sqlserver-1.10.1rc1/dbt/adapters/sqlserver/sqlserver_helpers.py +291 -0
- dbt_sqlserver-1.10.1rc1/dbt/adapters/sqlserver/sqlserver_runtime.py +450 -0
- {dbt_sqlserver-1.10.0 → dbt_sqlserver-1.10.1rc1}/dbt/include/sqlserver/macros/adapters/catalog.sql +86 -42
- dbt_sqlserver-1.10.1rc1/dbt/include/sqlserver/macros/adapters/columns.sql +114 -0
- dbt_sqlserver-1.10.1rc1/dbt/include/sqlserver/macros/adapters/indexes.sql +456 -0
- {dbt_sqlserver-1.10.0 → dbt_sqlserver-1.10.1rc1}/dbt/include/sqlserver/macros/adapters/metadata.sql +3 -2
- dbt_sqlserver-1.10.1rc1/dbt/include/sqlserver/macros/adapters/persist_docs.sql +137 -0
- {dbt_sqlserver-1.10.0 → dbt_sqlserver-1.10.1rc1}/dbt/include/sqlserver/macros/adapters/schema.sql +1 -1
- dbt_sqlserver-1.10.1rc1/dbt/include/sqlserver/macros/materializations/hooks.sql +19 -0
- {dbt_sqlserver-1.10.0 → dbt_sqlserver-1.10.1rc1}/dbt/include/sqlserver/macros/materializations/models/incremental/incremental.sql +7 -2
- {dbt_sqlserver-1.10.0 → dbt_sqlserver-1.10.1rc1}/dbt/include/sqlserver/macros/materializations/models/incremental/incremental_strategies.sql +1 -1
- {dbt_sqlserver-1.10.0 → dbt_sqlserver-1.10.1rc1}/dbt/include/sqlserver/macros/materializations/models/table/table.sql +1 -1
- {dbt_sqlserver-1.10.0 → dbt_sqlserver-1.10.1rc1}/dbt/include/sqlserver/macros/materializations/models/table/table_dml_refresh.sql +11 -2
- dbt_sqlserver-1.10.1rc1/dbt/include/sqlserver/macros/materializations/models/unit_test/get_fixture_sql.sql +101 -0
- {dbt_sqlserver-1.10.0 → dbt_sqlserver-1.10.1rc1}/dbt/include/sqlserver/macros/materializations/models/view/view.sql +1 -1
- {dbt_sqlserver-1.10.0 → dbt_sqlserver-1.10.1rc1}/dbt/include/sqlserver/macros/materializations/snapshots/snapshot.sql +7 -2
- {dbt_sqlserver-1.10.0 → dbt_sqlserver-1.10.1rc1}/dbt/include/sqlserver/macros/relations/seeds/helpers.sql +13 -10
- {dbt_sqlserver-1.10.0 → dbt_sqlserver-1.10.1rc1}/dbt/include/sqlserver/macros/relations/views/create.sql +0 -3
- {dbt_sqlserver-1.10.0 → dbt_sqlserver-1.10.1rc1}/dbt/include/sqlserver/macros/utils/split_part.sql +1 -1
- {dbt_sqlserver-1.10.0 → dbt_sqlserver-1.10.1rc1}/dbt/include/sqlserver/profile_template.yml +1 -1
- dbt_sqlserver-1.10.1rc1/dbt_sqlserver.egg-info/PKG-INFO +235 -0
- {dbt_sqlserver-1.10.0 → dbt_sqlserver-1.10.1rc1}/dbt_sqlserver.egg-info/SOURCES.txt +9 -1
- {dbt_sqlserver-1.10.0 → dbt_sqlserver-1.10.1rc1}/dbt_sqlserver.egg-info/requires.txt +5 -0
- {dbt_sqlserver-1.10.0 → dbt_sqlserver-1.10.1rc1}/pyproject.toml +29 -1
- dbt_sqlserver-1.10.0/PKG-INFO +0 -130
- dbt_sqlserver-1.10.0/README.md +0 -97
- dbt_sqlserver-1.10.0/dbt/adapters/sqlserver/__version__.py +0 -1
- dbt_sqlserver-1.10.0/dbt/adapters/sqlserver/sqlserver_column.py +0 -116
- dbt_sqlserver-1.10.0/dbt/adapters/sqlserver/sqlserver_configs.py +0 -9
- dbt_sqlserver-1.10.0/dbt/adapters/sqlserver/sqlserver_connections.py +0 -673
- dbt_sqlserver-1.10.0/dbt/adapters/sqlserver/sqlserver_credentials.py +0 -74
- dbt_sqlserver-1.10.0/dbt/include/sqlserver/macros/adapters/columns.sql +0 -91
- dbt_sqlserver-1.10.0/dbt/include/sqlserver/macros/adapters/indexes.sql +0 -238
- dbt_sqlserver-1.10.0/dbt/include/sqlserver/macros/materializations/models/table/clone.sql +0 -4
- dbt_sqlserver-1.10.0/dbt_sqlserver.egg-info/PKG-INFO +0 -130
- {dbt_sqlserver-1.10.0 → dbt_sqlserver-1.10.1rc1}/LICENSE +0 -0
- {dbt_sqlserver-1.10.0 → dbt_sqlserver-1.10.1rc1}/dbt/__init__.py +0 -0
- {dbt_sqlserver-1.10.0 → dbt_sqlserver-1.10.1rc1}/dbt/adapters/sqlserver/__init__.py +0 -0
- {dbt_sqlserver-1.10.0 → dbt_sqlserver-1.10.1rc1}/dbt/adapters/sqlserver/py.typed +0 -0
- {dbt_sqlserver-1.10.0 → dbt_sqlserver-1.10.1rc1}/dbt/adapters/sqlserver/relation_configs/policies.py +0 -0
- {dbt_sqlserver-1.10.0 → dbt_sqlserver-1.10.1rc1}/dbt/adapters/sqlserver/sqlserver_relation.py +0 -0
- {dbt_sqlserver-1.10.0 → dbt_sqlserver-1.10.1rc1}/dbt/include/sqlserver/__init__.py +0 -0
- {dbt_sqlserver-1.10.0 → dbt_sqlserver-1.10.1rc1}/dbt/include/sqlserver/dbt_project.yml +0 -0
- {dbt_sqlserver-1.10.0 → dbt_sqlserver-1.10.1rc1}/dbt/include/sqlserver/macros/adapters/apply_grants.sql +0 -0
- {dbt_sqlserver-1.10.0 → dbt_sqlserver-1.10.1rc1}/dbt/include/sqlserver/macros/adapters/relation.sql +0 -0
- {dbt_sqlserver-1.10.0 → dbt_sqlserver-1.10.1rc1}/dbt/include/sqlserver/macros/adapters/show.sql +0 -0
- {dbt_sqlserver-1.10.0 → dbt_sqlserver-1.10.1rc1}/dbt/include/sqlserver/macros/adapters/validate_sql.sql +0 -0
- {dbt_sqlserver-1.10.0 → dbt_sqlserver-1.10.1rc1}/dbt/include/sqlserver/macros/materializations/models/incremental/merge.sql +0 -0
- {dbt_sqlserver-1.10.0 → dbt_sqlserver-1.10.1rc1}/dbt/include/sqlserver/macros/materializations/models/table/columns_spec_ddl.sql +0 -0
- {dbt_sqlserver-1.10.0 → dbt_sqlserver-1.10.1rc1}/dbt/include/sqlserver/macros/materializations/models/unit_test/unit_test_create_table_as.sql +0 -0
- {dbt_sqlserver-1.10.0 → dbt_sqlserver-1.10.1rc1}/dbt/include/sqlserver/macros/materializations/models/view/create_view_as.sql +0 -0
- {dbt_sqlserver-1.10.0 → dbt_sqlserver-1.10.1rc1}/dbt/include/sqlserver/macros/materializations/snapshots/helpers.sql +0 -0
- {dbt_sqlserver-1.10.0 → dbt_sqlserver-1.10.1rc1}/dbt/include/sqlserver/macros/materializations/snapshots/snapshot_merge.sql +0 -0
- {dbt_sqlserver-1.10.0 → dbt_sqlserver-1.10.1rc1}/dbt/include/sqlserver/macros/materializations/snapshots/strategies.sql +0 -0
- {dbt_sqlserver-1.10.0 → dbt_sqlserver-1.10.1rc1}/dbt/include/sqlserver/macros/materializations/tests.sql +0 -0
- {dbt_sqlserver-1.10.0 → dbt_sqlserver-1.10.1rc1}/dbt/include/sqlserver/macros/materializations/unit_tests.sql +0 -0
- {dbt_sqlserver-1.10.0 → dbt_sqlserver-1.10.1rc1}/dbt/include/sqlserver/macros/relations/table/clone.sql +0 -0
- {dbt_sqlserver-1.10.0 → dbt_sqlserver-1.10.1rc1}/dbt/include/sqlserver/macros/relations/table/create.sql +0 -0
- {dbt_sqlserver-1.10.0 → dbt_sqlserver-1.10.1rc1}/dbt/include/sqlserver/macros/utils/any_value.sql +0 -0
- {dbt_sqlserver-1.10.0 → dbt_sqlserver-1.10.1rc1}/dbt/include/sqlserver/macros/utils/array_construct.sql +0 -0
- {dbt_sqlserver-1.10.0 → dbt_sqlserver-1.10.1rc1}/dbt/include/sqlserver/macros/utils/cast_bool_to_text.sql +0 -0
- {dbt_sqlserver-1.10.0 → dbt_sqlserver-1.10.1rc1}/dbt/include/sqlserver/macros/utils/concat.sql +0 -0
- {dbt_sqlserver-1.10.0 → dbt_sqlserver-1.10.1rc1}/dbt/include/sqlserver/macros/utils/date_trunc.sql +0 -0
- {dbt_sqlserver-1.10.0 → dbt_sqlserver-1.10.1rc1}/dbt/include/sqlserver/macros/utils/dateadd.sql +0 -0
- {dbt_sqlserver-1.10.0 → dbt_sqlserver-1.10.1rc1}/dbt/include/sqlserver/macros/utils/get_tables_by_pattern.sql +0 -0
- {dbt_sqlserver-1.10.0 → dbt_sqlserver-1.10.1rc1}/dbt/include/sqlserver/macros/utils/hash.sql +0 -0
- {dbt_sqlserver-1.10.0 → dbt_sqlserver-1.10.1rc1}/dbt/include/sqlserver/macros/utils/last_day.sql +0 -0
- {dbt_sqlserver-1.10.0 → dbt_sqlserver-1.10.1rc1}/dbt/include/sqlserver/macros/utils/length.sql +0 -0
- {dbt_sqlserver-1.10.0 → dbt_sqlserver-1.10.1rc1}/dbt/include/sqlserver/macros/utils/listagg.sql +0 -0
- {dbt_sqlserver-1.10.0 → dbt_sqlserver-1.10.1rc1}/dbt/include/sqlserver/macros/utils/position.sql +0 -0
- {dbt_sqlserver-1.10.0 → dbt_sqlserver-1.10.1rc1}/dbt/include/sqlserver/macros/utils/safe_cast.sql +0 -0
- {dbt_sqlserver-1.10.0 → dbt_sqlserver-1.10.1rc1}/dbt/include/sqlserver/macros/utils/timestamps.sql +0 -0
- {dbt_sqlserver-1.10.0 → dbt_sqlserver-1.10.1rc1}/dbt_sqlserver.egg-info/dependency_links.txt +0 -0
- {dbt_sqlserver-1.10.0 → dbt_sqlserver-1.10.1rc1}/dbt_sqlserver.egg-info/top_level.txt +0 -0
- {dbt_sqlserver-1.10.0 → dbt_sqlserver-1.10.1rc1}/setup.cfg +0 -0
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: dbt-sqlserver
|
|
3
|
+
Version: 1.10.1rc1
|
|
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 0.14 or newer and follows the same versioning scheme.
|
|
43
|
+
E.g. version 1.1.x of the adapter will be compatible with dbt-core 1.1.x.
|
|
44
|
+
|
|
45
|
+
The minimum supported SQL Server version is SQL Server 2017.
|
|
46
|
+
|
|
47
|
+
## Documentation
|
|
48
|
+
|
|
49
|
+
We've bundled all documentation on the dbt docs site:
|
|
50
|
+
|
|
51
|
+
- [Profile setup & authentication](https://docs.getdbt.com/reference/warehouse-profiles/mssql-profile)
|
|
52
|
+
- [Adapter documentation, usage and important notes](https://docs.getdbt.com/reference/resource-configs/mssql-configs)
|
|
53
|
+
|
|
54
|
+
Join us on the [dbt Slack](https://getdbt.slack.com/archives/CMRMDDQ9W) to ask questions, get help, or to discuss the project.
|
|
55
|
+
|
|
56
|
+
## Installation
|
|
57
|
+
|
|
58
|
+
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.
|
|
59
|
+
|
|
60
|
+
Latest version: 
|
|
61
|
+
Latest pre-release: 
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
### Backend requirements at a glance
|
|
65
|
+
|
|
66
|
+
| Backend | Python package | Debian/Ubuntu system packages |
|
|
67
|
+
|---|---|---|
|
|
68
|
+
| `pyodbc` | `dbt-sqlserver[pyodbc]` or `pyodbc` | `unixodbc-dev` plus the Microsoft ODBC Driver for SQL Server |
|
|
69
|
+
| `mssql-python` | `dbt-sqlserver[mssql]` or `mssql-python` | `libltdl7`, `libkrb5-3`, `libgssapi-krb5-2` |
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
### `pyodbc` backend
|
|
73
|
+
|
|
74
|
+
The legacy and currently default ODBC path uses `pyodbc` and the Microsoft ODBC driver.
|
|
75
|
+
|
|
76
|
+
```shell
|
|
77
|
+
pip install -U dbt-sqlserver
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
You should migrate to using an explicit extra in preparation for deprecation; the following is equivalent:
|
|
81
|
+
|
|
82
|
+
```shell
|
|
83
|
+
pip install -U "dbt-sqlserver[pyodbc]"
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
You also need the Microsoft ODBC driver for SQL Server installed on your system:
|
|
87
|
+
[Windows](https://docs.microsoft.com/en-us/sql/connect/odbc/download-odbc-driver-for-sql-server?view=sql-server-ver16#download-for-windows) |
|
|
88
|
+
[macOS](https://docs.microsoft.com/en-us/sql/connect/odbc/linux-mac/install-microsoft-odbc-driver-sql-server-macos?view=sql-server-ver16) |
|
|
89
|
+
[Linux](https://docs.microsoft.com/en-us/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-sql-server?view=sql-server-ver16)
|
|
90
|
+
|
|
91
|
+
<details><summary>Debian/Ubuntu</summary>
|
|
92
|
+
|
|
93
|
+
Install the ODBC headers as well as the driver linked above:
|
|
94
|
+
|
|
95
|
+
```shell
|
|
96
|
+
sudo apt-get install -y unixodbc-dev
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
</details>
|
|
100
|
+
|
|
101
|
+
### `mssql-python` backend
|
|
102
|
+
|
|
103
|
+
An alternative backend that does not require the ODBC driver.
|
|
104
|
+
|
|
105
|
+
```shell
|
|
106
|
+
pip install -U "dbt-sqlserver[mssql]"
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
On Debian/Ubuntu-based systems, `mssql-python` requires these system libraries:
|
|
110
|
+
|
|
111
|
+
```shell
|
|
112
|
+
sudo apt-get install -y libltdl7 libkrb5-3 libgssapi-krb5-2
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
Enable it per target in your `profiles.yml`:
|
|
116
|
+
|
|
117
|
+
```yaml
|
|
118
|
+
your_profile:
|
|
119
|
+
target: dev
|
|
120
|
+
outputs:
|
|
121
|
+
dev:
|
|
122
|
+
type: sqlserver
|
|
123
|
+
host: your-server
|
|
124
|
+
port: 1433
|
|
125
|
+
database: your-database
|
|
126
|
+
schema: dbo
|
|
127
|
+
user: your-user
|
|
128
|
+
password: your-password
|
|
129
|
+
encrypt: true
|
|
130
|
+
trust_cert: false
|
|
131
|
+
backend: mssql-python # <-- enables this backend
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
## Changelog
|
|
135
|
+
|
|
136
|
+
See [the changelog](CHANGELOG.md)
|
|
137
|
+
|
|
138
|
+
## Configuration
|
|
139
|
+
|
|
140
|
+
### `dbt_sqlserver_use_default_schema_concat`
|
|
141
|
+
|
|
142
|
+
*(default: `false`)* Controls schema name generation when a [custom schema](https://docs.getdbt.com/docs/build/custom-schemas) is set on a model.
|
|
143
|
+
|
|
144
|
+
| Flag value | `custom_schema_name` | Result |
|
|
145
|
+
|---|---|---|
|
|
146
|
+
| `false` (default, legacy) | *(none)* | `target.schema` |
|
|
147
|
+
| `false` (default, legacy) | `"reporting"` | `reporting` |
|
|
148
|
+
| `true` (dbt-core standard) | *(none)* | `target.schema` |
|
|
149
|
+
| `true` (dbt-core standard) | `"reporting"` | `target.schema_reporting` |
|
|
150
|
+
|
|
151
|
+
When `false` (the default), the adapter uses its legacy behaviour: `custom_schema_name` is used **as-is** without being prefixed by `target.schema`.
|
|
152
|
+
When `true`, the adapter delegates to dbt-core's `default__generate_schema_name`, which concatenates `target.schema` + `_` + `custom_schema_name`.
|
|
153
|
+
|
|
154
|
+
**Example usage in `dbt_project.yml`:**
|
|
155
|
+
|
|
156
|
+
```yaml
|
|
157
|
+
flags:
|
|
158
|
+
dbt_sqlserver_use_default_schema_concat: true # Enable standard schema concatenation
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
The same setting is also honoured via `vars:` for backwards compatibility; the behavior flag under `flags:` takes precedence when both are set.
|
|
162
|
+
|
|
163
|
+
> **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.
|
|
164
|
+
|
|
165
|
+
### `backend`
|
|
166
|
+
|
|
167
|
+
*(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.
|
|
168
|
+
|
|
169
|
+
### `dbt_sqlserver_enable_safe_type_expansion`
|
|
170
|
+
|
|
171
|
+
*(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:
|
|
172
|
+
|
|
173
|
+
- **Cross-family string**: `varchar`/`char` → `nvarchar`/`nchar` (same or larger size)
|
|
174
|
+
- **Integer family**: `bit` → `tinyint` → `smallint` → `int` → `bigint`
|
|
175
|
+
- **Integer → numeric**: `int` → `numeric` (with sufficient precision to hold the integer range)
|
|
176
|
+
- **Numeric precision/scale**: `numeric(p,s)` → `numeric(p2,s2)` where precision and scale both increase
|
|
177
|
+
- **Fixed-money**: `smallmoney` → `money`, `money` → `numeric` (with sufficient precision)
|
|
178
|
+
|
|
179
|
+
Safe expansions are further gated by `column_type_expansion_max_rows` (default 1,000,000 rows) to avoid long-running operations on large tables.
|
|
180
|
+
|
|
181
|
+
### `dbt_sqlserver_use_dbt_transactions`
|
|
182
|
+
|
|
183
|
+
_(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.
|
|
184
|
+
|
|
185
|
+
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`.
|
|
186
|
+
|
|
187
|
+
The driver connection remains in autocommit mode (`autocommit=true`) in both modes.
|
|
188
|
+
|
|
189
|
+
This mode is opt-in and should be tested carefully with project-specific materializations and hooks.
|
|
190
|
+
|
|
191
|
+
```yaml
|
|
192
|
+
# dbt_project.yml
|
|
193
|
+
flags:
|
|
194
|
+
dbt_sqlserver_enable_safe_type_expansion: true
|
|
195
|
+
dbt_sqlserver_use_dbt_transactions: true # <-- opt-in; default is false
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
### `column_type_expansion_max_rows`
|
|
199
|
+
|
|
200
|
+
*(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.
|
|
201
|
+
|
|
202
|
+
```sql
|
|
203
|
+
-- In an incremental model
|
|
204
|
+
{{ config(materialized='incremental', unique_key='id',
|
|
205
|
+
column_type_expansion_max_rows=500000) }}
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
### `prefer_single_alter_column`
|
|
209
|
+
|
|
210
|
+
*(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.
|
|
211
|
+
|
|
212
|
+
```sql
|
|
213
|
+
-- In an incremental model
|
|
214
|
+
{{ config(materialized='incremental', unique_key='id',
|
|
215
|
+
prefer_single_alter_column=true) }}
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
**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.
|
|
219
|
+
|
|
220
|
+
## Contributing
|
|
221
|
+
|
|
222
|
+
[](https://github.com/dbt-msft/dbt-sqlserver/actions/workflows/unit-tests.yml)
|
|
223
|
+
[](https://github.com/dbt-msft/dbt-sqlserver/actions/workflows/integration-tests-sqlserver.yml)
|
|
224
|
+
|
|
225
|
+
This adapter is community-maintained.
|
|
226
|
+
You are welcome to contribute by creating issues, opening or reviewing pull requests, or helping other users in the Slack channel.
|
|
227
|
+
If you're unsure how to get started, check out our [contributing guide](CONTRIBUTING.md).
|
|
228
|
+
|
|
229
|
+
## License
|
|
230
|
+
|
|
231
|
+
[](https://github.com/dbt-msft/dbt-sqlserver/blob/master/LICENSE)
|
|
232
|
+
|
|
233
|
+
## Code of Conduct
|
|
234
|
+
|
|
235
|
+
This project and everyone involved is expected to follow the [dbt Code of Conduct](https://community.getdbt.com/code-of-conduct).
|
|
@@ -0,0 +1,198 @@
|
|
|
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 0.14 or newer and follows the same versioning scheme.
|
|
6
|
+
E.g. version 1.1.x of the adapter will be compatible with dbt-core 1.1.x.
|
|
7
|
+
|
|
8
|
+
The minimum supported SQL Server version is SQL Server 2017.
|
|
9
|
+
|
|
10
|
+
## Documentation
|
|
11
|
+
|
|
12
|
+
We've bundled all documentation on the dbt docs site:
|
|
13
|
+
|
|
14
|
+
- [Profile setup & authentication](https://docs.getdbt.com/reference/warehouse-profiles/mssql-profile)
|
|
15
|
+
- [Adapter documentation, usage and important notes](https://docs.getdbt.com/reference/resource-configs/mssql-configs)
|
|
16
|
+
|
|
17
|
+
Join us on the [dbt Slack](https://getdbt.slack.com/archives/CMRMDDQ9W) to ask questions, get help, or to discuss the project.
|
|
18
|
+
|
|
19
|
+
## Installation
|
|
20
|
+
|
|
21
|
+
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.
|
|
22
|
+
|
|
23
|
+
Latest version: 
|
|
24
|
+
Latest pre-release: 
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
### Backend requirements at a glance
|
|
28
|
+
|
|
29
|
+
| Backend | Python package | Debian/Ubuntu system packages |
|
|
30
|
+
|---|---|---|
|
|
31
|
+
| `pyodbc` | `dbt-sqlserver[pyodbc]` or `pyodbc` | `unixodbc-dev` plus the Microsoft ODBC Driver for SQL Server |
|
|
32
|
+
| `mssql-python` | `dbt-sqlserver[mssql]` or `mssql-python` | `libltdl7`, `libkrb5-3`, `libgssapi-krb5-2` |
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
### `pyodbc` backend
|
|
36
|
+
|
|
37
|
+
The legacy and currently default ODBC path uses `pyodbc` and the Microsoft ODBC driver.
|
|
38
|
+
|
|
39
|
+
```shell
|
|
40
|
+
pip install -U dbt-sqlserver
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
You should migrate to using an explicit extra in preparation for deprecation; the following is equivalent:
|
|
44
|
+
|
|
45
|
+
```shell
|
|
46
|
+
pip install -U "dbt-sqlserver[pyodbc]"
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
You also need the Microsoft ODBC driver for SQL Server installed on your system:
|
|
50
|
+
[Windows](https://docs.microsoft.com/en-us/sql/connect/odbc/download-odbc-driver-for-sql-server?view=sql-server-ver16#download-for-windows) |
|
|
51
|
+
[macOS](https://docs.microsoft.com/en-us/sql/connect/odbc/linux-mac/install-microsoft-odbc-driver-sql-server-macos?view=sql-server-ver16) |
|
|
52
|
+
[Linux](https://docs.microsoft.com/en-us/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-sql-server?view=sql-server-ver16)
|
|
53
|
+
|
|
54
|
+
<details><summary>Debian/Ubuntu</summary>
|
|
55
|
+
|
|
56
|
+
Install the ODBC headers as well as the driver linked above:
|
|
57
|
+
|
|
58
|
+
```shell
|
|
59
|
+
sudo apt-get install -y unixodbc-dev
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
</details>
|
|
63
|
+
|
|
64
|
+
### `mssql-python` backend
|
|
65
|
+
|
|
66
|
+
An alternative backend that does not require the ODBC driver.
|
|
67
|
+
|
|
68
|
+
```shell
|
|
69
|
+
pip install -U "dbt-sqlserver[mssql]"
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
On Debian/Ubuntu-based systems, `mssql-python` requires these system libraries:
|
|
73
|
+
|
|
74
|
+
```shell
|
|
75
|
+
sudo apt-get install -y libltdl7 libkrb5-3 libgssapi-krb5-2
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Enable it per target in your `profiles.yml`:
|
|
79
|
+
|
|
80
|
+
```yaml
|
|
81
|
+
your_profile:
|
|
82
|
+
target: dev
|
|
83
|
+
outputs:
|
|
84
|
+
dev:
|
|
85
|
+
type: sqlserver
|
|
86
|
+
host: your-server
|
|
87
|
+
port: 1433
|
|
88
|
+
database: your-database
|
|
89
|
+
schema: dbo
|
|
90
|
+
user: your-user
|
|
91
|
+
password: your-password
|
|
92
|
+
encrypt: true
|
|
93
|
+
trust_cert: false
|
|
94
|
+
backend: mssql-python # <-- enables this backend
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## Changelog
|
|
98
|
+
|
|
99
|
+
See [the changelog](CHANGELOG.md)
|
|
100
|
+
|
|
101
|
+
## Configuration
|
|
102
|
+
|
|
103
|
+
### `dbt_sqlserver_use_default_schema_concat`
|
|
104
|
+
|
|
105
|
+
*(default: `false`)* Controls schema name generation when a [custom schema](https://docs.getdbt.com/docs/build/custom-schemas) is set on a model.
|
|
106
|
+
|
|
107
|
+
| Flag value | `custom_schema_name` | Result |
|
|
108
|
+
|---|---|---|
|
|
109
|
+
| `false` (default, legacy) | *(none)* | `target.schema` |
|
|
110
|
+
| `false` (default, legacy) | `"reporting"` | `reporting` |
|
|
111
|
+
| `true` (dbt-core standard) | *(none)* | `target.schema` |
|
|
112
|
+
| `true` (dbt-core standard) | `"reporting"` | `target.schema_reporting` |
|
|
113
|
+
|
|
114
|
+
When `false` (the default), the adapter uses its legacy behaviour: `custom_schema_name` is used **as-is** without being prefixed by `target.schema`.
|
|
115
|
+
When `true`, the adapter delegates to dbt-core's `default__generate_schema_name`, which concatenates `target.schema` + `_` + `custom_schema_name`.
|
|
116
|
+
|
|
117
|
+
**Example usage in `dbt_project.yml`:**
|
|
118
|
+
|
|
119
|
+
```yaml
|
|
120
|
+
flags:
|
|
121
|
+
dbt_sqlserver_use_default_schema_concat: true # Enable standard schema concatenation
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
The same setting is also honoured via `vars:` for backwards compatibility; the behavior flag under `flags:` takes precedence when both are set.
|
|
125
|
+
|
|
126
|
+
> **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.
|
|
127
|
+
|
|
128
|
+
### `backend`
|
|
129
|
+
|
|
130
|
+
*(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.
|
|
131
|
+
|
|
132
|
+
### `dbt_sqlserver_enable_safe_type_expansion`
|
|
133
|
+
|
|
134
|
+
*(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:
|
|
135
|
+
|
|
136
|
+
- **Cross-family string**: `varchar`/`char` → `nvarchar`/`nchar` (same or larger size)
|
|
137
|
+
- **Integer family**: `bit` → `tinyint` → `smallint` → `int` → `bigint`
|
|
138
|
+
- **Integer → numeric**: `int` → `numeric` (with sufficient precision to hold the integer range)
|
|
139
|
+
- **Numeric precision/scale**: `numeric(p,s)` → `numeric(p2,s2)` where precision and scale both increase
|
|
140
|
+
- **Fixed-money**: `smallmoney` → `money`, `money` → `numeric` (with sufficient precision)
|
|
141
|
+
|
|
142
|
+
Safe expansions are further gated by `column_type_expansion_max_rows` (default 1,000,000 rows) to avoid long-running operations on large tables.
|
|
143
|
+
|
|
144
|
+
### `dbt_sqlserver_use_dbt_transactions`
|
|
145
|
+
|
|
146
|
+
_(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.
|
|
147
|
+
|
|
148
|
+
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`.
|
|
149
|
+
|
|
150
|
+
The driver connection remains in autocommit mode (`autocommit=true`) in both modes.
|
|
151
|
+
|
|
152
|
+
This mode is opt-in and should be tested carefully with project-specific materializations and hooks.
|
|
153
|
+
|
|
154
|
+
```yaml
|
|
155
|
+
# dbt_project.yml
|
|
156
|
+
flags:
|
|
157
|
+
dbt_sqlserver_enable_safe_type_expansion: true
|
|
158
|
+
dbt_sqlserver_use_dbt_transactions: true # <-- opt-in; default is false
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
### `column_type_expansion_max_rows`
|
|
162
|
+
|
|
163
|
+
*(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.
|
|
164
|
+
|
|
165
|
+
```sql
|
|
166
|
+
-- In an incremental model
|
|
167
|
+
{{ config(materialized='incremental', unique_key='id',
|
|
168
|
+
column_type_expansion_max_rows=500000) }}
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
### `prefer_single_alter_column`
|
|
172
|
+
|
|
173
|
+
*(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.
|
|
174
|
+
|
|
175
|
+
```sql
|
|
176
|
+
-- In an incremental model
|
|
177
|
+
{{ config(materialized='incremental', unique_key='id',
|
|
178
|
+
prefer_single_alter_column=true) }}
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
**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.
|
|
182
|
+
|
|
183
|
+
## Contributing
|
|
184
|
+
|
|
185
|
+
[](https://github.com/dbt-msft/dbt-sqlserver/actions/workflows/unit-tests.yml)
|
|
186
|
+
[](https://github.com/dbt-msft/dbt-sqlserver/actions/workflows/integration-tests-sqlserver.yml)
|
|
187
|
+
|
|
188
|
+
This adapter is community-maintained.
|
|
189
|
+
You are welcome to contribute by creating issues, opening or reviewing pull requests, or helping other users in the Slack channel.
|
|
190
|
+
If you're unsure how to get started, check out our [contributing guide](CONTRIBUTING.md).
|
|
191
|
+
|
|
192
|
+
## License
|
|
193
|
+
|
|
194
|
+
[](https://github.com/dbt-msft/dbt-sqlserver/blob/master/LICENSE)
|
|
195
|
+
|
|
196
|
+
## Code of Conduct
|
|
197
|
+
|
|
198
|
+
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.1rc1"
|
{dbt_sqlserver-1.10.0 → dbt_sqlserver-1.10.1rc1}/dbt/adapters/sqlserver/relation_configs/__init__.py
RENAMED
|
@@ -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
|
]
|