Skip to content

feat: add T-SQL parser to monorepo#25

Merged
h3n4l merged 1 commit into
mainfrom
add-tsql-parser
Nov 3, 2025
Merged

feat: add T-SQL parser to monorepo#25
h3n4l merged 1 commit into
mainfrom
add-tsql-parser

Conversation

@h3n4l
Copy link
Copy Markdown
Member

@h3n4l h3n4l commented Nov 3, 2025

Summary

Add ANTLR4-based T-SQL (Transact-SQL) parser from the tsql-parser repository into the parser monorepo.

Changes

  • Add tsql parser directory with complete parser implementation

    • Grammar files: TSqlLexer.g4, TSqlParser.g4
    • Helper files: keyword_map.go, tsql_base_lexer.go, generate_keyword_golang_map.py
    • Makefile with build and test targets (follows existing pattern)
    • README documentation
  • Test coverage: 143 SQL test examples covering:

    • DDL statements (CREATE, ALTER, DROP for databases, tables, views, indexes, procedures, functions, etc.)
    • DML statements (SELECT, INSERT, UPDATE, DELETE, MERGE)
    • T-SQL specific features:
      • Stored procedures and functions
      • Control flow (IF, WHILE, TRY/CATCH, etc.)
      • Built-in functions (date, string, math, cryptographic, JSON, XML, etc.)
      • DBCC commands
      • Query hints and table hints
      • Transactions and locks
      • Triggers and cursors
      • Security features (logins, roles, permissions, encryption)
      • High availability features (Always On, mirroring, etc.)
      • Extended events and auditing
  • Package updates:

    • Updated package name: github.com/bytebase/parser/tsql
    • Fixed import paths in test files
    • Generated Go parser files using ANTLR 4
    • Updated helper files to use tsql package
  • CI/CD integration:

    • Added tsql to the parser list in .github/workflows/tests.yml
    • Tests will run automatically on changes to tsql/ directory

Test Results

All test cases pass successfully:

PASS: TestTSQLParser

Migration Notes

This moves the parser from the standalone tsql-parser repository into the unified parser monorepo alongside PostgreSQL, Redshift, CQL, and Snowflake parsers.

🤖 Generated with Claude Code

Add ANTLR4-based T-SQL (Transact-SQL) parser from tsql-parser repository into the parser monorepo.

Changes:
- Add tsql/ directory with grammar files (TSqlLexer.g4, TSqlParser.g4)
- Add Makefile with build and test targets following the pattern of other parsers
- Include 143 SQL test examples covering comprehensive T-SQL features
- Update package name and import paths to github.com/bytebase/parser/tsql
- Add tsql to CI workflow to run tests automatically
- Include helper files (keyword_map.go, tsql_base_lexer.go) for lexer functionality
- All test cases passing

Test coverage includes:
- DDL statements (CREATE, ALTER, DROP for databases, tables, views, indexes, etc.)
- DML statements (SELECT, INSERT, UPDATE, DELETE, MERGE)
- Stored procedures and functions
- Control flow statements
- Built-in functions (date, string, math, cryptographic, JSON, etc.)
- T-SQL specific features (DBCC, hints, transactions, triggers, etc.)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@h3n4l h3n4l merged commit 31ad3d0 into main Nov 3, 2025
5 checks passed
@h3n4l h3n4l deleted the add-tsql-parser branch November 3, 2025 09:12
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.

1 participant