You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@phoenix.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2017/02/13 08:15:43 UTC

[jira] [Commented] (PHOENIX-3471) Allow accessing full (legacy) Phoenix EXPLAIN information via Calcite

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

ASF GitHub Bot commented on PHOENIX-3471:
-----------------------------------------

GitHub user gabrielreid opened a pull request:

    https://github.com/apache/phoenix/pull/231

    PHOENIX-3471 Add query plan matching system

    Add a generic system for parsing and matching Calcite query
    plans using Hamcrest matchers. The general intention is to make
    matching of query plans less brittle and somewhat easier to write
    than simply matching the full text of the query plan.

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/gabrielreid/phoenix PHOENIX-3471_explain_plan

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/phoenix/pull/231.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #231
    
----
commit 128ff0a3288b0cfc48b068fc21704ca07278a33c
Author: Gabriel Reid <ga...@ngdata.com>
Date:   2016-11-18T09:58:18Z

    PHOENIX-3471 Add query plan matching system
    
    Add a generic system for parsing and matching Calcite query
    plans using Hamcrest matchers. The general intention is to make
    matching of query plans less brittle and somewhat easier to write
    than simply matching the full text of the query plan.

----


> Allow accessing full (legacy) Phoenix EXPLAIN information via Calcite
> ---------------------------------------------------------------------
>
>                 Key: PHOENIX-3471
>                 URL: https://issues.apache.org/jira/browse/PHOENIX-3471
>             Project: Phoenix
>          Issue Type: Sub-task
>            Reporter: Gabriel Reid
>            Assignee: Gabriel Reid
>
> The EXPLAIN syntax in Calcite-Phoenix (either "EXPLAIN <sql>" or "EXPLAIN PLAN FOR <sql>") currently returns the Calcite plan for a query. For example:
> {code}
> EXPLAIN SELECT MAX(I) FROM T1
> {code}
> results in the following Calcite explain plan:
> {code}
> PhoenixToEnumerableConverter
>   PhoenixServerAggregate(group=[{}], EXPR$0=[MAX($0)])
>     PhoenixTableScan(table=[[phoenix, T1]])
> {code}
> and the following (legacy) Phoenix explain plan:
> {code}
> CLIENT PARALLEL 1-WAY FULL SCAN OVER T1
>     SERVER FILTER BY FIRST KEY ONLY
> {code}
> There are currently a large number of integration tests which depend on the legacy Phoenix format of explain plan, and this format is no longer available when running via Calcite. PHOENIX-3105 added support for accessing the explain plan via the "EXPLAIN <sql>" syntax, but this update to the syntax still only provides the Calcite-specific explain plan.
> There are three main approaches which can be taken here:
> h4. Option 1: Custom EXPLAIN execution
> This approach extends the work done in PHOENIX-3105 to plug in a custom SqlPhoenixExplain
> node which returns the legacy Phoenix explain plan, with the "EXPLAIN PLAN FOR <sql>"
> syntax still returning the Calcite explain plan.
> h4. Option 2: Add the legacy Phoenix explain plan to the Calcite plan as a top-level attribute
> This approach results in an explain plan that looks as follows:
> {code}
> PhoenixToEnumerableConverter(PhoenixExecutionPlan=[CLIENT PARALLEL 1-WAY FULL SCAN OVER T1
>     SERVER FILTER BY FIRST KEY ONLY])
>   PhoenixServerAggregate(group=[{}], EXPR$0=[MAX($0)])
>     PhoenixTableScan(table=[[phoenix, T1]])
> {code}
> The disadvantage of this approach is that it's not really "correct" -- we're just tacking 
> a different representation of the explain plan into the Calcite explain plan.
> The advantage of this approach is that it's very quick and easy to implement (i.e. it
> can be done immediately), and it will require minimal changes to the many test cases which have
> hard-coded explain plans that things are checked against. All we need to do is have a 
> utility to extract the PhoenixExecutionPlan value from the full Calcite plan, and other
> than that all test cases stay the same.
> h4. Option 3: Add all relevant information to the correct parts of the Calcite explain plan
> This approach would result in an explain plan that looks as follows:
> {code}
> PhoenixToEnumerableConverter
>   PhoenixServerAggregate(group=[{}], EXPR$0=[MAX($0)])
>     PhoenixTableScan(table=[[phoenix, T1]], scanType[CLIENT PARALLEL 1-WAY FULL ])
> {code}
> This is undoubtedly the "right" way to do things. However, it has the major disadvantage
> that it will require a large amount of work to do the following:
> * add all relevant information into various implementations of {{AbstractRelNode.explainTerms}}
> * rework all test cases which verify things against an expected explain plan
> It is of course also an option is to start with option 2 here, and eventually migrate to option 3.
> If we go for option 2 or option 3, we should probably remove the custom EXPLAIN parsing.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)