Re: Need a Jason output if physical tree

2020-12-22 Thread Fan Liya
Hi Vladmir, Thanks for your feedback. IMO, Root[$0] should depend on t.a and t.b, because the value of t.b decides if some value could be included in Root[$0]. However, after investigating the code, I find you are right! The current implementation of RelMdColumnOrigins#getColumnOrigins(Filter, R

Re: Need a Jason output if physical tree

2020-12-21 Thread Vladimir Ozerov
Hi Liya, This will not work AFAIK. Consider the query "SELECT a FROM t WHERE b>1". The top-level operator has only one column: Root[$0] Project[$0] Filter[$1>1] Scan[$0=a, $1=b] If you invoke RelMdColumnOrigins on Root[$0], you will get [t.a], but miss [t.b]. To my knowledge, rules a

Re: Need a Jason output if physical tree

2020-12-21 Thread Fan Liya
Hi Bhavya, Sorry I am not sure if I fully understand your question. Let me try to answer it according to my understanding: 1. Through RelColumnMDOrigins, we can get the RelColumnOrigin object, which includes a RelOptTable object. 2. The table scan also has a RelOptTable object, and all table sca

Re: Need a Jason output if physical tree

2020-12-21 Thread Bhavya Aggarwal
Hi Liya, I had a look at the RelColumnMDOrigins and it is useful in determining which columns are from which table but still I am not sure how can I get the column information for TableScan without the rules. If you have any specific example where we have used this approach will be really helpful

Re: Need a Jason output if physical tree

2020-12-21 Thread Fan Liya
Hi Bhavya, IMO, to solve the problem from a global view, the following steps needs to be taken: 1. Generate a physical plan in the original way (without considering column pruning in the table scan) 2. Modify all the table scans in the plan with the RelColumnMDOrigins utility (the details have be

Re: Need a Jason output if physical tree

2020-12-20 Thread Bhavya Aggarwal
Hi Fan, I looked at the class RelColumnMDOrigins and it is giving me the origin of the column, but even if I want to take it as a global decision I am not sure how to proceed. Can you please elaborate on how to achieve this ? I am literally stuck as I do not want to use so many rules as in any cas

Re: Need a Jason output if physical tree

2020-12-20 Thread Fan Liya
Hi Vladmir, Thanks for your feedback. I see your point. The example I gave above was not a good one. I agree with you that making the decision locally solves most problems. However, it may be sub-optimal for some scenarios: The project operator may contain unnecessary columns (even if the colum

Re: Need a Jason output if physical tree

2020-12-18 Thread Vladimir Ozerov
Hi Liya, I do not think, this is a global decision. If you go bottom-up in the plan, and find the Project operator, than none parent operators will use any columns from the lower scans, other than those present in the Project. It is a common practice for Calcite integrations to restrict the numbe

Re: Need a Jason output if physical tree

2020-12-18 Thread Fan Liya
Hi Bhavya, Thanks for your explanation. I do not think a rule like ProjectFilterTableScan solves the problem. To see this, please note that the parent operator of the LogicalProject may need other columns from the table (e.g. the parent operator may be a join, which uses some other columns as the

Re: Need a Jason output if physical tree

2020-12-18 Thread Bhavya Aggarwal
Hi Liya, Please see below , I have a query as given below SELECT t_1.ID FROM USERS t_1 where NAME = 'HELLO'; Now I know that I have to fetch two columns from my columnar database i.e. ID, Name, so need to pass these parameters in my custom Table Scan. But when I convert the LogicalTableScan to m

Re: Need a Jason output if physical tree

2020-12-17 Thread Fan Liya
Hi Bhavya, Sorry I do not understand your question. Why is it difficult to pass sth. to child operators? Best, Liya Fan On Fri, Dec 18, 2020 at 12:38 PM Bhavya Aggarwal wrote: > Hi Liya, > > Actually the question is how to pass the projection columns to Table Scan > as right now in the Logica

Re: Need a Jason output if physical tree

2020-12-17 Thread Bhavya Aggarwal
Hi Liya, Actually the question is how to pass the projection columns to Table Scan as right now in the LogicalTableScan there are no projection columns being passed so when I am trying to create my custom JSON , I do not have those projected columns or columns that are being used in the query. I w

Re: Need a Jason output if physical tree

2020-12-17 Thread Fan Liya
Hi Bhavya, It seems the problem is that the json format provided by Calcite does not include properties specific to your operator? If so, I think you can override RelNode#explainTerms in your operator to attach the properties. Best, Liya Fan On Thu, Dec 17, 2020 at 10:45 PM Bhavya Aggarwal wrot

Re: Need a Jason output if physical tree

2020-12-17 Thread Bhavya Aggarwal
Please let me know if we have an example for writing a custom visitor that I can use. I see a RelVisitor class that I can extend but how to make it to visit the specific Physical Operator. Thanks and Regards Bhavya On Thu, Dec 17, 2020 at 7:43 PM Bhavya Aggarwal wrote: > Thanks, > > I tried usi

Re: Need a Jason output if physical tree

2020-12-17 Thread Bhavya Aggarwal
Thanks, I tried using the RelJsonWriter and tried to add my custom implementation in the my custom Rel Nodes but I am not getting all the data in my child operators. We are trying to use Calcite for a columnar data and we need the information of the projections in the TableScan as well because we

Re: Need a Jason output if physical tree

2020-12-13 Thread Michael Mior
That would likely be the best approach if you have some specific JSON format you're trying to generate. If you're happy with a JSON format defined by Calcite, you can look at RelJsonWriter. -- Michael Mior mm...@apache.org Le dim. 13 déc. 2020 à 05:36, Muhammad Gelbana a écrit : > > I would use

Re: Need a Jason output if physical tree

2020-12-13 Thread Muhammad Gelbana
I would use a visitor to traverse the optimized/physical plan. On Sun, Dec 13, 2020 at 6:42 AM Bhavya Aggarwal wrote: > Hi All, > > We need to generate a JSON object for the physical execution tree that has > been created. Is there an option in Calcite that we can use to do this. I > am not su

Need a Jason output if physical tree

2020-12-12 Thread Bhavya Aggarwal
Hi All, We need to generate a JSON object for the physical execution tree that has been created. Is there an option in Calcite that we can use to do this. I am not sure what is the right approach to do it. Please let me know if there are different ways to achieve this. Regards Bhavya -- Your fe