You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues-all@impala.apache.org by "ASF subversion and git services (JIRA)" <ji...@apache.org> on 2018/11/23 19:43:00 UTC

[jira] [Commented] (IMPALA-7881) Visualize AST for easier debugging

    [ https://issues.apache.org/jira/browse/IMPALA-7881?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16697471#comment-16697471 ] 

ASF subversion and git services commented on IMPALA-7881:
---------------------------------------------------------

Commit aa294cf6b2c03e3ab0816cd447b72f4c0ffee4aa in impala's branch refs/heads/master from [~paul-rogers]
[ https://git-wip-us.apache.org/repos/asf?p=impala.git;h=aa294cf ]

IMPALA-7881: Visualize AST for easier debugging

Provides a debug-time class to visualize the analysis-time AST for use
by developers. Uses a very simple JSON-like output. See IMPALA-7881 for
an example. Emphasize simplicity over elegance, many refinements can
follow.

Tests: This is test only code that is not even called from anywhere. A
developer must insert a temporary call when doing debugging. As a
result, the code cannot impact any other part of the code base.

Change-Id: Ia083c63953ceec0abedd2e0753b9444c19fcd114
Reviewed-on: http://gerrit.cloudera.org:8080/11980
Reviewed-by: Impala Public Jenkins <im...@cloudera.com>
Reviewed-by: Lars Volker <lv...@cloudera.com>
Tested-by: Impala Public Jenkins <im...@cloudera.com>


> Visualize AST for easier debugging
> ----------------------------------
>
>                 Key: IMPALA-7881
>                 URL: https://issues.apache.org/jira/browse/IMPALA-7881
>             Project: IMPALA
>          Issue Type: Improvement
>          Components: Frontend
>    Affects Versions: Impala 3.0
>            Reporter: Paul Rogers
>            Assignee: Paul Rogers
>            Priority: Minor
>
> The parser creates a "raw" AST (abstract syntax tree), which is then "decorated" by the analyzer. Often, when debugging the analyzer, one wants to see the state of the tree. At present, doing so using an IDE's debugger is tedious as one has to slowly navigate within the tree.
>  Provide a debug tool that visualizes the tree. For example:
> {noformat}
> <root> (SelectStmt): {
> . isExplain: false
> . analyzer: <Skip Analyzer>
> . withClause: <null>
> . orderByElements: [
> . . 0 (OrderByElement): {
> . . . expr (SlotRef): {
> ...
> . selectList (SelectList): {
> . . planHints: []
> . . isDistinct: false
> . . items: [
> . . . 0 (SelectListItem): {
> . . . . expr (SlotRef): {
> ...
> . . . . . rawPath: [
> . . . . . . 0: "id"
> . . . . . ]
> . . . . . label: "id"
> {noformat}
> Many improvements can be made. (Format as JSON, export to a nice JSON visualizer, etc.) The purpose here is to just get started.
> To avoid the need to write code for every AST node class (of which there are many), use Java introspection to walk fields directly. The result may be overly verbose, but it is a quick way to get started.
> The idea is to use the visualizer in conjunction with a unit test:
> {code:java}
>   @Test
>   public void test() {
>     String stmt =
>         "SELECT id, int_col + 10 AS c" +
>         " FROM functional.alltypestiny" +
>         " WHERE id > 10" +
>         " ORDER BY c";
>     ParseNode root = AnalyzesOk(stmt);
>     AstPrinter.printTree(root);
>   }
> {code}
> When debugging an issue, create a test. If things are not working, temporarily insert a call to the visualizer to see what's what. Remove the call when done.
> Poking at the AST from outside a unit test (perhaps from the Impala shell) is a larger project, beyond the scope of this ticket.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-all-unsubscribe@impala.apache.org
For additional commands, e-mail: issues-all-help@impala.apache.org