Skip to content

Add opt-in native string type mappings via behaviour flag (#626).#671

Merged
axellpadilla merged 1 commit into
dbt-msft:masterfrom
Benjamin-Knight:feat/#626-string-type-defaults
May 20, 2026
Merged

Add opt-in native string type mappings via behaviour flag (#626).#671
axellpadilla merged 1 commit into
dbt-msft:masterfrom
Benjamin-Knight:feat/#626-string-type-defaults

Conversation

@Benjamin-Knight
Copy link
Copy Markdown
Collaborator

@Benjamin-Knight Benjamin-Knight commented May 20, 2026

Introduces SQLServerColumnNative which maps STRING -> VARCHAR(MAX), NCHAR -> NCHAR(1), and NVARCHAR -> NVARCHAR(4000). The current default (SQLServerColumn) is unchanged: STRING / NVARCHAR -> VARCHAR(8000), NCHAR -> CHAR(1).

Users opt into the new mappings by setting dbt_sqlserver_use_native_string_types to True in dbt_project.yml; the new behaviour is intended to become the default in a future release.

Fixes a silent non-unicode aliasing of NCHAR / NVARCHAR in the default mappings (now opt-out).
Fixes #626

…).

Introduces SQLServerColumnNative which maps STRING -> VARCHAR(MAX),
NCHAR -> NCHAR(1), and NVARCHAR -> NVARCHAR(4000). The current default
(SQLServerColumn) is unchanged: STRING / NVARCHAR -> VARCHAR(8000),
NCHAR -> CHAR(1). Users opt into the new mappings by setting
`dbt_sqlserver_use_native_string_types` to True in dbt_project.yml;
the new behaviour is intended to become the default in a future release.

Fixes a silent non-unicode aliasing of NCHAR / NVARCHAR in the default
mappings (now opt-out), and uses NVARCHAR(4000) — the maximum fixed
NVARCHAR size — rather than NVARCHAR(8000) which exceeds SQL Server's
fixed-length cap.
@axellpadilla axellpadilla merged commit feb0612 into dbt-msft:master May 20, 2026
53 checks passed
@Benjamin-Knight Benjamin-Knight deleted the feat/#626-string-type-defaults branch May 21, 2026 08:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

dbt.type_string() compiles to varchar(8000)

2 participants