Skip to content

Add query_options model config for SQL Server OPTION clauses (#613).#674

Merged
axellpadilla merged 7 commits into
dbt-msft:masterfrom
Benjamin-Knight:feat/#613-query-options
Jun 2, 2026
Merged

Add query_options model config for SQL Server OPTION clauses (#613).#674
axellpadilla merged 7 commits into
dbt-msft:masterfrom
Benjamin-Knight:feat/#613-query-options

Conversation

@Benjamin-Knight
Copy link
Copy Markdown
Collaborator

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

Supports a dict form (allowlisted hints; MAX_GRANT_PERCENT / MIN_GRANT_PERCENT use = syntax) and a query_options_raw escape hatch. Usable on table, incremental (delete+insert, merge, microbatch), snapshot, and unit_test materializations.
Usage on a view raises a compiler error if set.
Apply_label() is preserved as a backward-compat alias emitting only the LABEL hint.
Fixes #613

…t#613).

Supports a dict form (allowlisted hints; MAX_GRANT_PERCENT / MIN_GRANT_PERCENT
use `=` syntax) and a query_options_raw escape hatch. Honoured on table,
incremental (delete+insert, merge, microbatch), snapshot, and unit_test
materializations; view raises a compiler error if set. apply_label() is
preserved as a backward-compat alias emitting only the LABEL hint.
@Benjamin-Knight Benjamin-Knight added this to the v1.10.0 milestone May 21, 2026
Comment thread dbt/include/sqlserver/macros/adapters/metadata.sql Outdated
Comment thread dbt/include/sqlserver/macros/adapters/metadata.sql
Comment thread dbt/include/sqlserver/macros/adapters/metadata.sql
Comment thread tests/functional/adapter/mssql/test_query_options.py
Benjamin-Knight and others added 4 commits May 28, 2026 11:56
- Drop `| int` cast so MAX_GRANT_PERCENT / MIN_GRANT_PERCENT render decimals
  verbatim (SQL Server accepts 0.0–100.0).
- Remove PARAMETERIZATION from the allowlist — its SIMPLE/FORCED syntax
  cannot be rendered through the numeric value path. Users needing it can
  fall back to query_options_raw.
- Reject string/mapping values for query_options_raw to prevent silent
  character-by-character iteration when a non-list is passed.
- Sharpen the apply_label() deprecation comment to direct overriders to
  get_query_options() as the new extension point.
- Add CHANGELOG v1.10.0 entry covering the new configs and the apply_label
  override migration note.
- Add tests covering decimal MAX_GRANT_PERCENT, query_options_raw string
  rejection, and PARAMETERIZATION now hitting the invalid-key branch.
…query-options.

Brings in 21 commits from upstream that were missing from this branch
(view materialization improvements, multi-database catalog support,
TABLOCK on contract-enforced inserts, reserved-keyword quoting fix,
default-schema-concat flag, etc.).

Conflict in dbt/include/sqlserver/macros/adapters/catalog.sql resolved
by keeping upstream's multi-database structure while replacing the
remaining apply_label() call with get_query_options().
Comment thread tests/functional/adapter/mssql/test_query_options.py Outdated
Benjamin-Knight and others added 2 commits June 2, 2026 12:56
Your right it is, when I did the first pass it was not.

Co-authored-by: Axell Padilla <68310020+axellpadilla@users.noreply.github.com>
@axellpadilla axellpadilla merged commit d9bb235 into dbt-msft:master Jun 2, 2026
53 checks passed
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.

Max Recursion config property

2 participants