[Refactor] New Tests for Query Parser/Formatter#97
Merged
colinthebomb1 merged 5 commits intomainfrom Feb 25, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request adds 40 new test cases for the query parser to document expected AST representations and known parser limitations. The tests cover various SQL constructs including CAST operations, self-joins, subqueries, complex WHERE conditions, aggregations with CASE statements, and advanced features like DISTINCT and UNION.
Changes:
- Added 40 new test functions in
test_query_parser.py, documenting expected AST structures for real-world SQL queries - Included TODO comments throughout the tests identifying known parser limitations that need to be addressed (e.g., TYPE keywords as FunctionNodes, missing UNION support, missing DISTINCT support)
- Most test assertions are commented out since many features are not yet fully supported by the parser
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
colinthebomb1
approved these changes
Feb 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
Add tests for the query parser. After this PR, the reviewed test cases can be copied to the formatter and end-to-end test files.
Code Changes
test_query_parser.py.Issues Detected
TEXT, INTEGER, DATE, NULL) areFunctionNodes; consider a keyword/node type (tests 1–5, 41-43).UNIONnot supported (queries 15, 29, 32).DISTINCT(tests 11, 18, 35)/DISTINCT ON(test 40) not supported.IS NULLemitted asFunctionNode("MISSING"); desired form isOperatorNode(col, "IS", [NULL])(test 41).FunctionNode ADD/SUB/MUL/DIV; could map toOperatorNode(tests 27, 42).INshould be a list of literals, not oneLiteralNodewhose value is a list. (test 20)Design Questions
CASE:CASEcurrently is underFunctionNode; consider a dedicated CaseNode? (test 31) -> create CaseNode with parent as NodeGROUP BY 1, 2handling to be confirmed. Currently are literals1,2; consider replace as column refs? (test 43) -> replace as column refs.INTERVALhandling to be confirmed (test 42, 43). -> treat it as function.