Sorry for the late response, I lost track of this email. Anupam> 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.
@Anupam: I think that this is no longer true in release 1.18 (see [1]). @Kumar: The unit test HepPlannerTest#testMaterialization [2] is very similar to the code you provided. Possibly you are only missing the fix for CALCITE-2465. [1] https://issues.apache.org/jira/browse/CALCITE-2465 [2] https://github.com/apache/calcite/blob/73f71095ef4e66aa47563e28b02f3fd499a5a1ad/core/src/test/java/org/apache/calcite/test/HepPlannerTest.java#L305 Στις Τρί, 15 Ιαν 2019 στις 12:35 μ.μ., ο/η Kumar Vishal < kumarvishal1...@gmail.com> έγραψε: > Hi Anupam, > > Thanks for the info, I will try with VolcanoPlanner. > -Regards > Kumar Vishal > > On Tue, Jan 15, 2019 at 2:07 PM Anupam Aggarwal <anupam.aggar...@gmail.com > > > wrote: > > > 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 <kumarvishal1...@gmail.com> > > > To: dev@calcite.apache.org > > > 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 <zabe...@gmail.com > > > > > 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 < > > >> kumarvishal1...@gmail.com> έγραψε: > > >> > > >> > 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 < > > >> kumarvishal1...@gmail.com> > > >> > 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 < > > zabe...@gmail.com > > >> > > > >> > > 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 < > > >> > >> kumarvishal1...@gmail.com> έγραψε: > > >> > >> > > >> > >> > 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 > > >> > >> > > > >> > >> > > >> > > > > >> > > > >> > > > > > >