Thanks Maryann.

Trying to debug what's going on I created ArchiveConverterRule (and
registered this rule).
Rule implements ConverterRule and add convert(), which returns
ArchiveEnumerableSort.

So basically ArchiveEnumerableSort should be my replacement of EnumerableSort.
But when I call explain plan for select I get EnumerableSort anyway,
while I expect to see
implemented ArchiveEnumerableSort.

Should it work as I expect, or there is something other that I need to do?

On Sat, Oct 31, 2015 at 3:26 AM, Maryann Xue <[email protected]> wrote:
> Oh, it's not on master branch yet. It's the "calcite" branch, and for
> PhoenixTable specifically, you can go:
> https://git1-us-west.apache.org/repos/asf?p=phoenix.git;a=blob;f=phoenix-core/src/main/java/org/apache/phoenix/calcite/PhoenixTable.java;h=4be745036335443bc1bcaae07acf1f32fda6c59a;hb=refs/heads/calcite
> .
>
> On Fri, Oct 30, 2015 at 4:36 PM, Alexander Reshetov <
> [email protected]> wrote:
>
>> Could you please point me to PhoenixTable in repo? Unfortunately I
>> could not find it.
>>
>> On Fri, Oct 30, 2015 at 10:33 PM, Maryann Xue <[email protected]>
>> wrote:
>> > SortRemoveRule.INSTANCE is already in the default rule set. I think what
>> > you should do is just make your table return the right collation trait.
>> For
>> > example in Phoenix we have a Table implementation called PhoenixTable
>> which
>> > overrides getStatistic() and implements getCollations() of Statistic.
>> >
>> > On Fri, Oct 30, 2015 at 1:40 PM, Alexander Reshetov <
>> > [email protected]> wrote:
>> >
>> >> Is it correct that I need to override
>> >> org.apache.calcite.rel.AbstractRelNode.register and add rule
>> >> SortRemoveRule.INSTANCE ?
>> >>
>> >> But while it checks RelCollation, then I should also somehow set it.
>> >> But I could not find how to do it.
>> >>
>> >> On Fri, Oct 30, 2015 at 4:23 PM, Alexander Reshetov
>> >> <[email protected]> wrote:
>> >> > Here some clarification of my intends.
>> >> >
>> >> > Calcite choosing next plan:
>> >> >
>> >> > +------+
>> >> > | PLAN |
>> >> > +------+
>> >> > | EnumerableSort(sort0=[$0], dir0=[DESC])
>> >> >   ArchiveTableScan(table=[[MAIN, SUB]], fields=[[0, 1, 2, 3, 4, 5, 6,
>> >> > 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21]])
>> >> >  |
>> >> > +------+
>> >> >
>> >> >
>> >> > The problem is invocation of EnumerableSort. Because data already
>> >> > sorted by one column. So I need to force exclusion of EnumerableSort
>> >> > from planner.
>> >> >
>> >> > Do I need implement some interface or override some method to achieve
>> >> this?
>> >> >
>> >> > On Fri, Oct 30, 2015 at 9:51 AM, Julian Hyde <[email protected]>
>> wrote:
>> >> >> Yes, this is possible. In fact Phoenix does exactly this.
>> >> >>
>> >> >> Take a look at https://issues.apache.org/jira/browse/CALCITE-818 and
>> >> https://issues.apache.org/jira/browse/CALCITE-71, which were fixed
>> along
>> >> the way.
>> >> >>
>> >> >>> On Oct 29, 2015, at 1:16 AM, Alexander Reshetov <
>> >> [email protected]> wrote:
>> >> >>>
>> >> >>> Hello,
>> >> >>>
>> >> >>> I have kinda theoretical question. But it should help to understand
>> >> >>> overall Calcite's possibility.
>> >> >>>
>> >> >>> Suppose there is some abstract format/table, which supports only
>> >> >>> sorting by one column.
>> >> >>>
>> >> >>> Let's say there is next query passed to calcite:
>> >> >>>
>> >> >>>    select * from table order by id
>> >> >>>
>> >> >>> Is it possible to rewrite query tree so it will change this request
>> >> into this?
>> >> >>>
>> >> >>>    select * from table
>> >> >>>
>> >> >>> In this way after logical query rewrite Calcite should not be
>> >> >>> concerned about sorting at all.
>> >> >>
>> >>
>>

Reply via email to