Hi, Not sure if you are still waiting for this I was trying to do something very similar , new to calcite myself, I was able to achieve this by using a volcanoPlanner
I don't think HepPlanner does MV substitution (add materialization method on the RelOptPlanner is not overloaded in HepPlanner) You would have to use VolcanoPlanner and instantiate with the same rules you did for HepPlanner. Also based on the code you shared you would have to create a new RelOptTable node for materialization.tableRel materialization.tableRel = <this should be a RelOptTable) node obtained from catalog reader Hope this helps -Anupam > > > ---------- Forwarded message ---------- > From: Kumar Vishal <[email protected]> > To: [email protected] > Cc: > Bcc: > Date: Mon, 7 Jan 2019 15:44:57 +0530 > Subject: Re: [Query] Can we use calcite for rewriting the query based on > Materialized View > Hi Stamatis, > > I have converted my testcase to UT, please find it in the attachment. > > -Regards > Kumar Vishal > > On Sat, Dec 22, 2018 at 1:32 PM Stamatis Zampetakis <[email protected]> > wrote: > >> Hi Kumar, >> >> I think it would be helpful if you could shape your code into a unit test >> and share it with us. It will be easier for people to understand what is >> happening >> and possibly give you some hints. >> >> Best, >> Stamatis >> >> Στις Παρ, 21 Δεκ 2018 στις 6:17 μ.μ., ο/η Kumar Vishal < >> [email protected]> έγραψε: >> >> > Hi Stamatis, >> > >> > I have referred MaterializationTest as you suggested, I have created a >> > Schema similar to one present in the testcase and added Materialized >> View. >> > I have created HepPlanner with all the rules present in >> > AbstractMaterializedViewRule but when I am applying rules it's able to >> > select the Materialized View but not able to rewrite the query. >> > >> > Can you please suggest me any clue to proceed? >> > >> > >> > - Regards >> > Kumar Vishal >> > >> > On Tue, Dec 11, 2018 at 12:51 PM Kumar Vishal < >> [email protected]> >> > wrote: >> > >> > > Hi Stamatis, >> > > >> > > Thanks for the info, I will check this and get back to you. >> > > >> > > -Regards >> > > Kumar Vishal >> > > >> > > On Sun, Dec 9, 2018 at 6:46 PM Stamatis Zampetakis <[email protected] >> > >> > > wrote: >> > > >> > >> Hi Kumar, >> > >> >> > >> Yes, it is possible. >> > >> >> > >> As long as you have your schema defined you can create a Planner >> > (Volcano, >> > >> or Heuristic) with the appropriate rules for view based rewritting >> and >> > >> obtain a plan that is using the views. Then you can pass from a plan >> > back >> > >> to sql using RelToSqlConverter. >> > >> >> > >> You might find interesting the discussion in [1]. You can also have a >> > look >> > >> in the MaterializationTest which can serve as an entry point in >> order to >> > >> understand how the rewritting works. >> > >> >> > >> Best, >> > >> Stamatis >> > >> >> > >> [1] >> > >> >> > >> >> > >> http://mail-archives.apache.org/mod_mbox/calcite-dev/201810.mbox/%3CAM0PR07MB5185C3F75488AA768815CF4FCCFD0%40AM0PR07MB5185.eurprd07.prod.outlook.com%3E >> > >> >> > >> Στις Παρ, 7 Δεκ 2018 στις 5:15 μ.μ., ο/η Kumar Vishal < >> > >> [email protected]> έγραψε: >> > >> >> > >> > Hi Dev, >> > >> > >> > >> > I am a new bee and analysing Calcite Materialized View. In my >> > scenario I >> > >> > have multiple execution engines which have their own parser and >> > >> > optimizer(Some do not have integration with calcite). I want to >> > register >> > >> > all the tables and Materialized Views to Calcite and handle >> commonly >> > for >> > >> > all execution engines. >> > >> > >> > >> > i.e. I want to redirect User queries to calcite and get back the >> > >> rewritten >> > >> > sql (by selecting best fit Materialized View), so rewritten sql >> can be >> > >> > executed by execution engine. >> > >> > >> > >> > Is there anyway to get the rewritten sql based on Materialized >> View?? >> > >> > >> > >> > -Regards >> > >> > Kumar Vishal >> > >> > >> > >> >> > > >> > >> >
