Skip to content

Conversation

@kyleconroy
Copy link
Collaborator

Add comprehensive SELECT parsing with the following features:

  • TOP clause with PERCENT and WITH TIES options
  • SELECT INTO for table creation
  • WHERE, GROUP BY, HAVING clauses
  • ORDER BY clause with ASC/DESC
  • UNION, EXCEPT, INTERSECT set operations
  • JOIN support (INNER, LEFT/RIGHT/FULL OUTER, CROSS)
  • ODBC literal syntax for guid, date, time, timestamp
  • Empty schema identifier handling (db..table syntax)

New AST types:

  • TopRowFilter for TOP clause
  • NumericLiteral for decimal numbers
  • QueryParenthesisExpression for parenthesized subqueries
  • BinaryQueryExpression for UNION/EXCEPT/INTERSECT
  • UnqualifiedJoin for CROSS JOIN
  • OdbcLiteral for ODBC escape sequences

Added ~25 new lexer tokens and updated JSON serialization
to match Microsoft SqlScriptDOM output format.

SelectStatementTests now passes (unskipped).

Add comprehensive SELECT parsing with the following features:
- TOP clause with PERCENT and WITH TIES options
- SELECT INTO for table creation
- WHERE, GROUP BY, HAVING clauses
- ORDER BY clause with ASC/DESC
- UNION, EXCEPT, INTERSECT set operations
- JOIN support (INNER, LEFT/RIGHT/FULL OUTER, CROSS)
- ODBC literal syntax for guid, date, time, timestamp
- Empty schema identifier handling (db..table syntax)

New AST types:
- TopRowFilter for TOP clause
- NumericLiteral for decimal numbers
- QueryParenthesisExpression for parenthesized subqueries
- BinaryQueryExpression for UNION/EXCEPT/INTERSECT
- UnqualifiedJoin for CROSS JOIN
- OdbcLiteral for ODBC escape sequences

Added ~25 new lexer tokens and updated JSON serialization
to match Microsoft SqlScriptDOM output format.

SelectStatementTests now passes (unskipped).
Add comprehensive T-SQL parser support for:
- Expression types: NULL, DEFAULT, UnaryExpression
- DML statements: INSERT, UPDATE, DELETE
- DDL statements: CREATE TABLE, CREATE VIEW, CREATE SCHEMA, GRANT
- Control flow: DECLARE, IF, WHILE, BEGIN/END, BREAK, CONTINUE, RETURN
- SET statements: PredicateSetStatement (ANSI_NULLS, etc.)
- EXECUTE statements with procedure references

New AST types (26 files):
- begin_end_block_statement.go, break_statement.go, continue_statement.go
- create_schema_statement.go, create_table_statement.go, create_view_statement.go
- declare_variable_statement.go, delete_statement.go, execute_statement.go
- grant_statement.go, if_statement.go, insert_statement.go
- predicate_set_statement.go, return_statement.go, set_variable_statement.go
- update_statement.go, while_statement.go
- null_literal.go, default_literal.go, unary_expression.go
- cursor_id.go, internal_open_rowset.go, literal_optimizer_hint.go
- schema_object_function_table_reference.go, table_hint.go
- variable_table_reference.go

Lexer additions (8 new token types):
- Security keywords: GRANT, REVOKE, TO, PUBLIC

Parser enhancements (~3000 lines):
- Parsing functions for all new statement types
- JSON serialization for AST output
- Proper $ref handling for duplicate identifiers

Passing tests: BeginEndBlockStatementTests, CreateSchemaStatementTests,
DeclareVariableStatementTests, IfStatementTests, SelectStatementTests,
and more existing tests.
@kyleconroy kyleconroy merged commit 0be5352 into main Dec 14, 2025
1 check 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.

3 participants