Michael is correct that to get all alternative plans you can create your own 
visitor.

However note that the number of plans is typically very large. Consider a query 
that starts of as

  Scan -> Project -> Filter

and broadens to 3 equivalence sets with 3 RelNodes in each:

  {R11, R12, R13} -> {R21, R22, R23} -> {R31, R32, R33}

There are 27 paths even in this small graph, (R11 -> R21 -> R31), (R12 -> R21 
-> R31), …, (R13, R23, R33). Each path is a valid plan. The number of plans can 
grow exponentially in the number of equivalence sets. So your “visitor” should 
probably be an iterator; if it were to materialize the full list it would run 
out of memory.

Julian


> On Feb 4, 2019, at 10:13 AM, Michael Mior <[email protected]> wrote:
> 
> In general, there's no way to guarantee you get "all" the plans for a
> particular query. If you want to get a variety of plans and their
> associated cost, take a look at CheapestPlanVisitor in RelSubset.java.
> This is used by VolcanoPlanner to build the cheapest plan at the end
> of the planning phase. You could construct your own visitor which will
> produce multiple alternative plans.
> 
> --
> Michael Mior
> [email protected]
> 
> Le ven. 1 févr. 2019 à 12:41, asma zgolli <[email protected]> a écrit :
>> 
>> Hello ,
>> 
>> my use case is building the search space of a special optimizer and I which
>> to general all the equivalent logical query plans after parsing. Is it
>> possible with apache calcite. Can you please tell me how or direct me to
>> some useful documentation / tutorial.
>> 
>> thank you very much.
>> yours sincerely
>> Asma ZGOLLI
>> 
>> PhD student in data engineering - computer science
>> Email : [email protected]
>> email alt:  [email protected] <[email protected]>
>> Tel : (+33) 07 52 95 04 45
>> Skype : asma_zgolli

Reply via email to