Skip to content

Adding a ast_util.py to visualize ASTs.#98

Merged
baiqiushi merged 2 commits intomainfrom
dev/qiushibai/ASTVisualization
Feb 25, 2026
Merged

Adding a ast_util.py to visualize ASTs.#98
baiqiushi merged 2 commits intomainfrom
dev/qiushibai/ASTVisualization

Conversation

@baiqiushi
Copy link
Contributor

@baiqiushi baiqiushi commented Feb 24, 2026

Introducing an ast_util.py to visualize the AST tree and help reveiw test cases.

The visualization result is like the following:

tests/test_query_parser.py::test_subquery_parse 
-------------------------------- live log call --------------------------------
INFO     tests.test_query_parser:test_query_parser.py:145 
============================================================================
SQL QUERY                             AST STRUCTURE
============================================================================
                                      +- query
SELECT empno,                         | +- select
       firstnme,                      | | +- column: empno
       lastname,                      | | +- column: firstnme
       phoneno                        | | +- column: lastname
FROM employee                         | | +- column: phoneno
WHERE workdept IN                     | +- from
    (SELECT deptno                    | | +- table: employee
     FROM department                  | +- where
     WHERE deptname = 'OPERATIONS')   | | +- operator: AND
  AND 1=1;                            | | | +- operator: IN
                                      | | | | +- column: workdept
                                      | | | | +- subquery
                                      | | | | | +- query
                                      | | | | | | +- select
                                      | | | | | | | +- column: deptno
                                      | | | | | | +- from
                                      | | | | | | | +- table: department
                                      | | | | | | +- where
                                      | | | | | | | +- operator: =
                                      | | | | | | | | +- column: deptname
                                      | | | | | | | | +- literal: OPERATIONS
                                      | | | +- operator: =
                                      | | | | +- literal: 1
                                      | | | | +- literal: 1
============================================================================

HazelYuAhiru
HazelYuAhiru previously approved these changes Feb 25, 2026
Copy link
Collaborator

@HazelYuAhiru HazelYuAhiru left a comment

Choose a reason for hiding this comment

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

LGTM, thanks a lot!

@baiqiushi baiqiushi changed the base branch from query_tests to main February 25, 2026 03:44
@baiqiushi baiqiushi dismissed HazelYuAhiru’s stale review February 25, 2026 03:44

The base branch was changed.

@baiqiushi baiqiushi force-pushed the dev/qiushibai/ASTVisualization branch from 736d011 to 839ecf4 Compare February 25, 2026 04:09
@baiqiushi baiqiushi merged commit 25b6710 into main Feb 25, 2026
2 checks passed
@baiqiushi baiqiushi deleted the dev/qiushibai/ASTVisualization branch February 25, 2026 17:00
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.

2 participants