[Refactor] Query Parser Fix After AST Support#100
Conversation
There was a problem hiding this comment.
Pull request overview
This PR refactors the SQL-to-AST query parser to handle a broader set of mo_sql_parsing constructs (e.g., DISTINCT/DISTINCT ON, IN literal lists, CASE, INTERVAL/EXTRACT, NULL/IS NULL), and updates the test suite to re-enable many previously disabled parser/AST equality assertions.
Changes:
- Expanded
core/query_parser.pyto parse additional SQL constructs into the project’s AST node types (e.g.,ListNode,CaseNode,IntervalNode,DataTypeNode, DISTINCT ON support). - Adjusted alias handling across clauses (notably GROUP BY / WHERE comments and resolution behavior).
- Re-enabled many
tests/test_query_parser.pyassertions, while leavingtest_basic_parseandtest_query_42effectively disabled pending design decisions.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| tests/test_query_parser.py | Re-enables most parser-vs-expected-AST assertions, but leaves two key tests disabled via commented asserts. |
| core/query_parser.py | Adds parsing support for DISTINCT(+ON), IN lists/subqueries, NULL/IS NULL, CASE, INTERVAL, EXTRACT, and tweaks alias resolution logic. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
This PR refactors and extends the SQL-to-AST query parser to support more complex query patterns emitted by mo_sql_parsing, with the goal of turning previously-disabled parser tests back on.
Changes:
- Expanded
QueryParserto handle additional SQL constructs (e.g.,DISTINCT/DISTINCT ON,INliteral lists,INTERVAL,EXTRACT,CASE,NULLnormalization). - Adjusted alias resolution behavior across clauses (notably
GROUP BY,ORDER BY, andWHERE) to better match expected AST semantics. - Re-enabled many previously-commented test assertions (while leaving a couple still disabled).
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
core/query_parser.py |
Adds parsing support for more AST node types and improves clause parsing/alias resolution to satisfy more real-world queries. |
tests/test_query_parser.py |
Re-enables many parser equality assertions; still has two key tests with assertions commented out. |
data/asts.py |
Minor comment/TODO update on GROUP BY ordinal handling in Query 42 expected AST. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
511885a to
d247637
Compare
There was a problem hiding this comment.
Pull request overview
This PR updates the SQL → AST query parser to handle additional SQL constructs (e.g., DISTINCT/DISTINCT ON, CASE, INTERVAL/EXTRACT, IN-lists, NULL/IS NULL), and re-enables previously commented-out parser assertions so the expanded suite is executed.
Changes:
- Re-enabled
assert parser.parse(sql) == get_ast(...)checks across many query parser tests. - Extended
core/query_parser.pyto support moremo_sql_parsingAST shapes and SQL features (DISTINCT/DISTINCT ON, CASE, INTERVAL, IN literal lists/subqueries, NULL/IS NULL). - Minor fixture comment tweak in
data/asts.py.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
tests/test_query_parser.py |
Uncomments parser-vs-fixture asserts so the full set of query AST expectations is enforced. |
data/asts.py |
Updates a comment in query 42’s expected AST fixture. |
core/query_parser.py |
Adds parsing support for additional SQL constructs required by the expanded tests (distinctness, CASE, intervals, IN lists, NULL checks, alias handling). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Overview
This PR updates the query parser logic to support more complex test cases. All existing test cases now pass.