[ 
https://issues.apache.org/jira/browse/PHOENIX-6507?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

chenglei updated PHOENIX-6507:
------------------------------
    Description: 
Given following tables :
{code:java}
   create table test ( 
      pk1 varchar not null , 
      pk2 varchar not null, 
      pk3 varchar not null,
       v1 varchar, 
       v2 varchar, 
      CONSTRAINT TEST_PK PRIMARY KEY ( pk1,pk2,pk3))
{code}

The result of the following sql may be incorrect:
{code:java}
   select distinct pk1,max(v1) from test group by pk1,pk2,pk3 order by pk1
{code}

The problem is the {{order by}} is complied out because it is the prefix of the 
{{group by}}, but for {{distinct}},  {{DistinctAggregatingResultIterator}} 
using {{HashSet}} to rearrange the aggregated tuples.


  was:
Given following tables :
{code:java}
   create table test ( 
      pk1 varchar not null , 
      pk2 varchar not null, 
      pk3 varchar not null,
       v1 varchar, 
       v2 varchar, 
      CONSTRAINT TEST_PK PRIMARY KEY ( pk1,pk2,pk3))
{code}

The result of the following sql may be incorrect:
{code:java}
   select distinct pk1,max(v1) from test group by pk1,pk2,pk3 order by pk1
{code}

That is because 



> DistinctAggregatingResultIterator should keep original tuple order of the 
> AggregatingResultIterator
> ---------------------------------------------------------------------------------------------------
>
>                 Key: PHOENIX-6507
>                 URL: https://issues.apache.org/jira/browse/PHOENIX-6507
>             Project: Phoenix
>          Issue Type: Bug
>    Affects Versions: 4.16.1, 5.1.2
>            Reporter: chenglei
>            Priority: Major
>             Fix For: 4.17.0, 5.2.0
>
>
> Given following tables :
> {code:java}
>    create table test ( 
>       pk1 varchar not null , 
>       pk2 varchar not null, 
>       pk3 varchar not null,
>        v1 varchar, 
>        v2 varchar, 
>       CONSTRAINT TEST_PK PRIMARY KEY ( pk1,pk2,pk3))
> {code}
> The result of the following sql may be incorrect:
> {code:java}
>    select distinct pk1,max(v1) from test group by pk1,pk2,pk3 order by pk1
> {code}
> The problem is the {{order by}} is complied out because it is the prefix of 
> the {{group by}}, but for {{distinct}},  
> {{DistinctAggregatingResultIterator}} using {{HashSet}} to rearrange the 
> aggregated tuples.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to