feat(sqlserver): Part 6 — SQL type mapping and column builder - #16
Merged
Conversation
Adds SqlServer arms to sql_types.rs (format_arrow_type_as_sql dispatch, the convert_*_type consolidation match, field_comment, build_sdf_schema, max_varchar_size/max_varbinary_size) and column_builder.rs (build, build_from_parts), mirroring the Fabric arms where SQL Server's T-SQL surface agrees and diverging where it measurably doesn't. Values are checked against dbt/adapters/sqlserver/sqlserver_adapter.py and sqlserver_column.py (v1's actual behavior, not its deprecated legacy path — dbt_sqlserver_use_native_string_types defaults True as of 1.12): convert_number_type's "float" if decimals else "int" rule, convert_boolean_type's "bit", convert_datetime_type's "datetime2(6)", convert_time_type's "time(6)". STRING maps to VARCHAR(MAX), not Fabric's VARCHAR(8000): Fabric Warehouse tracks its own byte cap here, and on-prem/Azure SQL Database has no equivalent one — VARCHAR(MAX) is v1's native mapping. A new sqlserver module (mirroring the fabric one) backs the format_arrow_type_as_sql dispatch and build_sqlserver's type_ops.format_arrow_type_as_sql call. get_field_sql_type_metadata_key gets `todo!()`, matching its other untouched arms (Databricks, Postgres, Salesforce, Spark, DuckDB, Alt): the function is dead outside its own Bigquery-only test, and the answer that matters lives in dbt_adapter_sql::types::SQLSERVER_KEYS. Leaves Part 7's scope (adapter_impl.rs's SqlServer arms) untouched; those E0004s are unrelated to this file pair and still block a full crate build. Closes #6
axellpadilla
changed the base branch from
part-5-sqlserver-catalog
to
sqlserver-v2-port
August 3, 2026 01:18
4 tasks
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Part 6 of the SQL Server Fusion adapter series. Part of dbt-labs#15714.
sql_types.rsandcolumn_builder.rs— the two filesrg '\bFabric\b'flags as Part 6's work list. AddsSqlServereverywhereFabricalready has an arm, matching Fabric's value where SQL Server's T-SQL surface agrees and diverging where it measurably doesn't.Where it diverges from Fabric
VARCHAR(MAX), not Fabric'sVARCHAR(8000). Fabric Warehouse tracks its own byte cap inFABRIC_MAX_VARCHAR_TYPE; on-prem/Azure SQL Database has no equivalent limit tracked here.VARCHAR(MAX)is v1's current native mapping (dbt_sqlserver_use_native_string_types, defaultTrueas of 1.12) — the legacyVARCHAR(8000)path is deprecated in v1 and isn't what this ports."float"/"int"by scale, not Fabric's unconditional"float". v1'sconvert_number_typeis"float" if decimals else "int"; the newSqlServerarms in the scale-keyed match reproduce that threshold instead of Fabric's flat mapping."bit"), timestamp ("datetime2(6)"), and time ("time(6)") match both v1 and Fabric — no divergence, just added.Column builder
build_fabric, notbuild_postgres_like, is the right model here — confirmed by reading rather than assumed:build_postgres_likehardcodesColumn::new(AdapterType::Postgres, ...)(would mislabel every SQL Server column) and special-casesTimestamp/Time64to a bare"datetime"literal regardless of adapter (would lose thedatetime2(6)precision v1 relies on).build_sqlservermirrorsbuild_fabric's shape instead, backed by the newsqlserver::try_format_typemodule.Left alone
get_field_sql_type_metadata_keygetstodo!()forSqlServer, matching the other adapters that already work and are alreadytodo!()there (Databricks, Postgres, Salesforce, Spark, DuckDB, Alt). The function is unused outside its own Bigquery-only unit test; the metadata key that's actually live isdbt_adapter_sql::types::SQLSERVER_KEYS.adapter_impl.rs's remainingSqlServerE0004s are Part 7's scope, not this file pair's — a fullcargo check -p dbt-adapterstill fails until feat(sqlserver): Part 7 — adapter_impl.rs match arms #7 lands, same as it did before this PR.Verification
cargo check -p dbt-adapter --testsreports zero errors insql_types.rsorcolumn_builder.rs(all remaining errors are inadapter_impl.rs, Part 7's file). Fullcargo testcan't run yet — the crate doesn't build until Part 7 closes the gap — so the new unit tests (sqlserver_try_format_type_formats_native_types,sqlserver_try_format_type_rejects_unsupported_arrow_types, plusSqlServerassertions added to the existingconvert_*_typetests) are type-checked but not yet executed.PRs against
sqlserver-v2-portin this repo, useCloses #<this issue>.Closes #6