This plan outlines the strategy to unskip all 1,011 currently skipped query tests in the T-SQL parser. The tests are organized in /home/user/teesql/parser/testdata/ with each test containing:
metadata.json- Skip flag ({"skip": true}or{"skip": false})query.sql- T-SQL query to parseast.json- Expected AST output
- Total tests: 1,023
- Skipped tests: 1,011 (98.9%)
- Active tests: 12 (1.1%)
- SELECT statements (basic: columns, FROM, aliases)
- PRINT statements
- THROW statements
- ALTER TABLE DROP INDEX
- DROP DATABASE SCOPED CREDENTIAL
- REVERT statements
Goal: Unskip SelectStatementTests and related baseline tests
- TOP clause -
SELECT TOP 10 ...,TOP (n) PERCENT WITH TIES - INTO clause -
SELECT ... INTO table FROM ... - Column aliases -
AS alias,[column name]without AS - Bracketed identifiers -
[schema].[table].[column]
- Comparison operators -
=,<>,<,>,<=,>= - Boolean operators -
AND,OR,NOT - IN expressions -
col IN (1, 2, 3) - BETWEEN expressions -
col BETWEEN 1 AND 10 - LIKE expressions -
col LIKE 'pattern%' - IS NULL / IS NOT NULL
- Basic GROUP BY -
GROUP BY col1, col2 - GROUP BY ALL
- WITH ROLLUP / WITH CUBE
- HAVING clause
- ORDER BY clause -
ORDER BY col ASC/DESC - Multiple columns
- Ordinal references -
ORDER BY 1, 2
- INNER JOIN
- LEFT/RIGHT/FULL OUTER JOIN
- CROSS JOIN
- JOIN hints (LOOP, HASH, MERGE)
- UNION / UNION ALL
- EXCEPT
- INTERSECT
- Scalar subqueries -
(SELECT ...) - Table subqueries -
FROM (SELECT ...) AS t - EXISTS / NOT EXISTS
SelectStatementTests→SelectStatementTests/metadata.jsonBaselines*_SelectStatementTestsvariants
Goal: Support all expression types used across tests
- Numeric literals - integers, decimals, floats
- Binary literals -
0x... - National strings -
N'...' - GUID literals -
{guid'...'} - Date/time literals
- NULL literal
- Multiplication / Division -
*,/,% - Unary minus/plus
- Bitwise operators -
&,|,^,~
- Scalar functions -
GETDATE(),ISNULL(), etc. - Aggregate functions -
COUNT(),SUM(),AVG(),MIN(),MAX() - Window functions -
ROW_NUMBER() OVER(...) - CAST / CONVERT
- CASE expressions
- COALESCE
- NULLIF
- IIF
- Collation expressions
- INSERT INTO ... VALUES
- INSERT INTO ... SELECT
- INSERT INTO ... EXEC
- DEFAULT VALUES
- OUTPUT clause
Tests: InsertStatementTests, related baselines
- UPDATE ... SET
- UPDATE with FROM clause
- UPDATE with JOINs
- OUTPUT clause
Tests: UpdateStatementTests, related baselines
- DELETE FROM
- DELETE with JOINs
- OUTPUT clause
- TRUNCATE TABLE
Tests: DeleteStatementTests, TruncateTableStatementTests, related baselines
- MERGE ... USING ... ON
- WHEN MATCHED / NOT MATCHED
- OUTPUT clause
Tests: MergeStatementTests*
- Column definitions
- Data types (all SQL Server types)
- Constraints (PRIMARY KEY, FOREIGN KEY, UNIQUE, CHECK, DEFAULT)
- Computed columns
- Temporal tables
- Partitioning
Tests: CreateTableTests*
- ADD column
- ALTER COLUMN
- DROP COLUMN
- ADD/DROP CONSTRAINT
Tests: AlterTableStatementTests*
- Clustered/Nonclustered indexes
- INCLUDE columns
- WHERE clause (filtered)
- Index options
Tests: CreateIndexStatementTests*, AlterIndexStatementTests*
- DECLARE - variables, table variables
- SET - variable assignment
- IF...ELSE
- WHILE
- BEGIN...END blocks
- TRY...CATCH
- GOTO/LABEL
- RETURN
- WAITFOR
Tests: DeclareStatementTests, SetStatementTests, IfStatementTests, WhileStatementTests, TryCatchStatementTests, etc.
- CREATE/ALTER PROCEDURE
- EXECUTE/EXEC
- Parameters (IN, OUT, DEFAULT)
- WITH options (RECOMPILE, ENCRYPTION, etc.)
Tests: CreateProcedureStatementTests*, AlterProcedureStatementTests*, ExecuteStatementTests*
- CREATE/ALTER FUNCTION
- Scalar functions
- Table-valued functions
- Inline table-valued functions
Tests: CreateFunctionStatementTests*, AlterFunctionStatementTests*
- CREATE/ALTER TRIGGER
- DML triggers
- DDL triggers
- Logon triggers
Tests: CreateTriggerStatementTests*, AlterTriggerStatementTests*
- CREATE/ALTER VIEW
- WITH CHECK OPTION
- WITH SCHEMABINDING
Tests: CreateViewStatementTests*, AlterViewStatementTests*
- CREATE/ALTER SCHEMA
- CREATE/ALTER USER
- CREATE/ALTER LOGIN
- CREATE/ALTER ROLE
Tests: CreateSchemaStatementTests*, CreateUserStatementTests*, etc.
- Sequences
- Synonyms
- Types (user-defined types)
- Assemblies
- Certificates and Keys
- Credentials
- CREATE/ALTER DATABASE
- DROP DATABASE
- USE database
- Database options
Tests: AlterCreateDatabaseStatementTests*, AlterDatabaseOptionsTests*
- BACKUP DATABASE/LOG
- RESTORE DATABASE/LOG
Tests: BackupStatementTests*, RestoreStatementTests*
- Server configuration
- Endpoints
- Linked servers
- WITH ... AS (SELECT ...)
- Recursive CTEs
Tests: CTEStatementTests*
- FOR XML
- OPENXML
- XML methods (query, value, nodes, etc.)
Tests: ForXmlTests*, OpenXmlStatementTests*
- FOR JSON
- OPENJSON
- JSON functions
Tests: JsonFunctionTests*
- CONTAINS
- FREETEXT
- Fulltext indexes
Tests: ContainsStatementTests*, FulltextTests*
- Geometry/Geography types
- Spatial methods
Once statement types are implemented, unskip corresponding baseline tests:
Baselines80_*- SQL Server 2000Baselines90_*- SQL Server 2005Baselines100_*- SQL Server 2008Baselines110_*- SQL Server 2012Baselines120_*- SQL Server 2014Baselines130_*- SQL Server 2016Baselines140_*- SQL Server 2017Baselines150_*- SQL Server 2019Baselines160_*- SQL Server 2022Baselines170_*- Future versionsBaselinesCommon_*- Common tests
- Analyze test files - Read the
query.sqlandast.jsonfor relevant tests - Implement lexer tokens - Add any new tokens to
/parser/lexer.go - Add AST types - Create new files in
/ast/for new node types - Implement parser - Add parsing logic to
/parser/parser.go - Add JSON marshaling - Add
*ToJSONfunctions in parser - Run tests - Execute
go test ./parser/... - Unskip tests - Change
"skip": trueto"skip": falseinmetadata.json - Commit - Commit changes with descriptive message
- High Priority - Complete SELECT support (enables many baseline tests)
- Medium Priority - DML statements (INSERT, UPDATE, DELETE)
- Medium Priority - Control flow (IF, WHILE, TRY/CATCH)
- Lower Priority - Complex DDL (stored procedures, functions)
- Lowest Priority - Advanced features (XML, JSON, Fulltext)
- All 1,023 tests pass without skipping
- All statement types properly generate matching AST JSON
- No regressions in currently passing tests
- Tests are organized in
testdata/with related baselines prefixed by version - The parser uses a hand-written recursive descent approach
- AST JSON format follows the Microsoft SqlScriptDOM conventions
- Some tests may require version-specific behavior