Re: Cross reference between Relsub and one of rels

2016-10-19 Thread Jungtaek Lim
Just turned out it's a bug on my code... One of Rel doesn't replace its input with parameter in copy() method, so RelSubset doesn't get rid of. CheapestPlanReplacer is working well. Also closed relate issue. Sorry Julian to waste your time. - Jungtaek Lim (HeartSaVioR) 2016년 10월 15일 (토) 오전 10:33,

Re: Cross reference between Relsub and one of rels

2016-10-14 Thread Jungtaek Lim
Please correct if I'm wrong, but asking myself to part of my question, in normal case RelSubset is not shown after planning. I can only see RelSubset from planned tree the case what I've originally reported. Even this case I can visit the known 'best' to try its best not failing at all, but curiou

Re: Cross reference between Relsub and one of rels

2016-10-14 Thread Jungtaek Lim
I just would like to say that end-user would intuitively think that what Volcano Planner returns is the actual plan. If VolcanoPlanner is able to do it, it would be better to provide it. findBestExp transcribes the plan into a tree where each RelNode's inputs are real RelNodes. Then if visitor mee

Re: Cross reference between Relsub and one of rels

2016-10-14 Thread Julian Hyde
When inside VolcanoPlanner, every input to every RelNode will be a RelSubset. The RelSubset represents the alternatives. When findBestExp has finished, it transcribes the plan into a tree where each RelNode’s inputs are real RelNodes, each the cheapest possible alternative. I’m sorry that build

Re: Cross reference between Relsub and one of rels

2016-10-14 Thread Jungtaek Lim
RelSubset.buildCheapestPlan() is not open to public. It's used by only VolcanoPlanner.findBestExp(). Btw, I'm a bit confused - suppose the logical plan is not changed once sql statement is parsed and validated, then if VolcanoPlanner provides actual plan, actual plan doesn't need to be changed unl

Re: Cross reference between Relsub and one of rels

2016-10-14 Thread Julian Hyde
Did you try RelSubset.buildCheapestPlan? > On Oct 14, 2016, at 3:46 PM, Jungtaek Lim wrote: > > Let me elaborate on what I'm working on. > > I'm working on converting Calcite logical plan to Storm Trident logical > plan. > (Trident itself does optimization on topology so I just create the Tride

Re: Cross reference between Relsub and one of rels

2016-10-14 Thread Jungtaek Lim
Let me elaborate on what I'm working on. I'm working on converting Calcite logical plan to Storm Trident logical plan. (Trident itself does optimization on topology so I just create the Trident topology and let Trident plans on it.) Thanks to Samza SQL implementation, I also succeed to translate

Re: Cross reference between Relsub and one of rels

2016-10-14 Thread Julian Hyde
If you’re wanting to traverse into RelSubsets you’re almost certainly doing it wrong. We have a very powerful mechanism for identifying sub-sections of the RelNode graph: planner rules and the VolcanoPlanner. Suppose that a RelSubset has 8 RelNodes in it, and also has 5 consumers. That is 40 pa

Re: Cross reference between Relsub and one of rels

2016-10-13 Thread Jungtaek Lim
This makes me another question, since Storm SQL should traverse the selected plan so having similar requirement. How we can visit RelSubset if it's an input node in current RelNode? Before asking a question I was following 'best' rel in RelSubset, assuming that best is what Volcano planner picks.

Re: Cross reference between Relsub and one of rels

2016-10-13 Thread Julian Hyde
I agree, it would be useful to be able to print out the plan (or the best plan known at the moment). I suppose RelWriter could have a method that chooses which member of a RelSubset is to be preferred; and if that member is the best according to some cost model then what will come out is the bes

Re: Cross reference between Relsub and one of rels

2016-10-13 Thread Jungtaek Lim
Sorry I was not clear on that. RelSubSet is correct, and while executing RelOptUtil.toString(), it calls RelSubSet.explain(), and RelSubSet.explain() picks input with that manner. Yes I'm saying about after planning. I agree that RelOptUtil.toString() can be called before planning so it can't hand

Re: Cross reference between Relsub and one of rels

2016-10-13 Thread Julian Hyde
No, it’s not possible to print the “actual plan” because until planning is finished there is no plan. The job of toString is to print the STRUCTURE of the rel, and cost should not come into that. There is no “RelSub” class - I presume you mean RelSubSet? But RelSubSet has no toString method (ot

Re: Cross reference between Relsub and one of rels

2016-10-13 Thread Jungtaek Lim
Thanks Julian for the quick response. I'll follow CALCITE-794. And I got more details: rels: 0 = {LogicalFilter@3579} "rel#10:LogicalFilter.NONE.[](input=rel#9:Subset#0.ENUMERABLE.[],condition=>($0, 3))" 1 = {LogicalProject@3584} "rel#12:LogicalProject.NONE.[](input=rel#11:Subset#1.NONE.[],ID=$0,

Re: Cross reference between Relsub and one of rels

2016-10-13 Thread Julian Hyde
Cycles in the rel graph are difficult to avoid. See https://issues.apache.org/jira/browse/CALCITE-794 for details. They are not fatal for optimization (as long as the nodes in the graph have positive cost, the cheapest plan (which is basically

Cross reference between Relsub and one of rels

2016-10-13 Thread Jungtaek Lim
Hi devs, While I'm converting Storm SQL to convert Calcite logical to Storm's own logical, I found one of Storm's unit test is failing. I put RelOptUtil.toString() on every tests, and broken test is throwing StackOverflowError. When it was also failing from IDEA, I dug it more, and found that one