You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@calcite.apache.org by Kumar Vishal <ku...@gmail.com> on 2018/12/07 16:15:28 UTC
[Query] Can we use calcite for rewriting the query based on
Materialized View
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
Re: [Query] Can we use calcite for rewriting the query based on
Materialized View
Posted by Kumar Vishal <ku...@gmail.com>.
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 <za...@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 <
> kumarvishal1802@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 <kumarvishal1802@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 <za...@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 <
> > >> kumarvishal1802@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
> > >> >
> > >>
> > >
> >
>
Re: [Query] Can we use calcite for rewriting the query based on
Materialized View
Posted by Stamatis Zampetakis <za...@gmail.com>.
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 <
kumarvishal1802@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 <ku...@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 <za...@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 <
> >> kumarvishal1802@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
> >> >
> >>
> >
>
Re: [Query] Can we use calcite for rewriting the query based on
Materialized View
Posted by Kumar Vishal <ku...@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 <ku...@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 <za...@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 <
>> kumarvishal1802@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
>> >
>>
>
Re: [Query] Can we use calcite for rewriting the query based on
Materialized View
Posted by Kumar Vishal <ku...@gmail.com>.
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 <za...@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 <
> kumarvishal1802@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
> >
>
Re: [Query] Can we use calcite for rewriting the query based on
Materialized View
Posted by Stamatis Zampetakis <za...@gmail.com>.
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 <
kumarvishal1802@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
>