Skip to content

chore: port TSQL sqlcmd commands :r and :setvar (#4653)#2671

Merged
benfdking merged 1 commit into
mainfrom
port/sqlfluff-4653
Jun 6, 2026
Merged

chore: port TSQL sqlcmd commands :r and :setvar (#4653)#2671
benfdking merged 1 commit into
mainfrom
port/sqlfluff-4653

Conversation

@mikills
Copy link
Copy Markdown
Collaborator

@mikills mikills commented Jun 6, 2026

Summary

  • SQLFluff #4653 added T-SQL sqlcmd command support (:r <file> and :setvar <name> <value>). Ported it to sqruff's tsql.rs: a new unquoted_relative_sql_file_path lexer matcher, SqlcmdOperatorSegment (MultiStringParser over r/setvar), SqlcmdFilePathSegment, and SqlcmdCommandSegment, wired into the T-SQL statement list, with R/SETVAR registered as unreserved keywords.
  • Added the sqlcmd_command fixture (.sql + .yml); the dialect test parses all commands with no unparsable segments. Parser-only change.

Ported from SQLFluff 964dcd18d158980e0321ab67131f07ced9f8440b
sqlfluff/sqlfluff#4653
sqlfluff/sqlfluff@964dcd1

Stacked on #2670 (#4654); base will revert to main once that merges.

@mikills mikills self-assigned this Jun 6, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 6, 2026

Benchmark for 760b144

Click to view benchmark
Test Base PR %
DepthMap::from_parent 61.2±0.29µs 61.4±0.46µs +0.33%
fix_complex_query 13.0±0.11ms 12.8±0.13ms -1.54%
fix_superlong 209.8±13.73ms 217.8±9.47ms +3.81%
parse_complex_query 4.3±0.05µs 4.3±0.06µs 0.00%
parse_expression_recursion 7.3±0.15µs 7.5±0.46µs +2.74%
parse_simple_query 1064.4±13.83ns 1041.7±15.36ns -2.13%

## Summary
  - SQLFluff #4653 added T-SQL `sqlcmd` command support (`:r <file>` and `:setvar <name> <value>`). Ported it to sqruff's `tsql.rs`: a new `unquoted_relative_sql_file_path` lexer matcher, `SqlcmdOperatorSegment` (MultiStringParser over `r`/`setvar`), `SqlcmdFilePathSegment`, and `SqlcmdCommandSegment`, wired into the T-SQL statement list, with `R`/`SETVAR` registered as unreserved keywords.
  - Added the `sqlcmd_command` fixture (.sql + .yml); the dialect test parses all commands with no unparsable segments. Parser-only change.

  Ported from SQLFluff 964dcd18d158980e0321ab67131f07ced9f8440b
  sqlfluff/sqlfluff#4653
  sqlfluff/sqlfluff@964dcd1
@benfdking benfdking force-pushed the port/sqlfluff-4653 branch from 062cb99 to 7dcaa6b Compare June 6, 2026 22:33
@benfdking benfdking merged commit 32dff06 into main Jun 6, 2026
19 of 27 checks passed
@benfdking benfdking deleted the port/sqlfluff-4653 branch June 6, 2026 22:42
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 6, 2026

Benchmark for 4e7b5d4

Click to view benchmark
Test Base PR %
DepthMap::from_parent 61.1±0.76µs 61.5±1.00µs +0.65%
fix_complex_query 13.0±0.13ms 12.9±0.11ms -0.77%
fix_superlong 237.1±11.24ms 238.0±9.64ms +0.38%
parse_complex_query 4.1±0.02µs 4.4±0.09µs +7.32%
parse_expression_recursion 7.4±0.10µs 7.5±0.09µs +1.35%
parse_simple_query 1068.4±43.46ns 1047.5±6.52ns -1.96%

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.

2 participants