Skip to content

[Refactor] New Tests for Query Parser/Formatter#97

Merged
colinthebomb1 merged 5 commits intomainfrom
query_tests
Feb 25, 2026
Merged

[Refactor] New Tests for Query Parser/Formatter#97
colinthebomb1 merged 5 commits intomainfrom
query_tests

Conversation

@HazelYuAhiru
Copy link
Collaborator

@HazelYuAhiru HazelYuAhiru commented Feb 19, 2026

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

  • Added 40 new test cases in test_query_parser.py.

Issues Detected

  • Missing AST support: Type/Special keywords (TEXT, INTEGER, DATE, NULL) are FunctionNodes; consider a keyword/node type (tests 1–5, 41-43).
  • Missing AST support: UNION not supported (queries 15, 29, 32).
  • Missing AST support: DISTINCT(tests 11, 18, 35)/DISTINCT ON(test 40) not supported.
  • Parser Issue: IS NULL emitted as FunctionNode("MISSING"); desired form is OperatorNode(col, "IS", [NULL]) (test 41).
  • Parser Issue: Arithmetic (+, -, , /) emitted as FunctionNode ADD/SUB/MUL/DIV; could map to OperatorNode (tests 27, 42).
  • Parser Issue: the right-hand side of IN should be a list of literals, not one LiteralNode whose value is a list. (test 20)

Design Questions

  • New node for CASE: CASE currently is under FunctionNode; consider a dedicated CaseNode? (test 31) -> create CaseNode with parent as Node
  • Special SQL cases:
    • GROUP BY 1, 2 handling to be confirmed. Currently are literals 1, 2; consider replace as column refs? (test 43) -> replace as column refs.
    • INTERVAL handling to be confirmed (test 42, 43). -> treat it as function.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 colinthebomb1 merged commit b6587e9 into main Feb 25, 2026
2 checks 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.

4 participants