lelit/pglast

Visualization

Opened this issue · 3 comments

Hi there! Is there a best practice to visualize this format of AST?
Thank you!

lelit commented

Sorry, what do you mean? What do you want to visualize and what is this format of AST?

Sorry for the ambiguous question.
I would like to achieve something like this:
https://shardingsphere.apache.org/document/current/img/sharding/sql_ast.png
And by "this format" of AST what i mean is any output that I can get by using pglast package on a valid SQL query.

lelit commented

Interesting, but no, there's nothing similar, and it's not trivial to obtain that, although probably doable with some effort, for example as an alternative set of printer functions that emits dot syntax....

The main problem I foresee is how to tag the various pieces... I mean, in that picture you see fields as a tag of id and name, but what should happen when the query is not trivial, and the fields are actually subselects, or expressions?