Github user maryannxue commented on a diff in the pull request:

    https://github.com/apache/phoenix/pull/314#discussion_r206377190
  
    --- Diff: 
phoenix-core/src/main/java/org/apache/phoenix/compile/QueryCompiler.java ---
    @@ -559,8 +559,16 @@ protected QueryPlan 
compileSingleFlatQuery(StatementContext context, SelectState
             groupBy = groupBy.compile(context, innerPlanTupleProjector);
             context.setResolver(resolver); // recover resolver
             RowProjector projector = ProjectionCompiler.compile(context, 
select, groupBy, asSubquery ? Collections.<PDatum>emptyList() : targetColumns, 
where);
    -        OrderBy orderBy = OrderByCompiler.compile(context, select, 
groupBy, limit, offset, projector,
    -                groupBy == GroupBy.EMPTY_GROUP_BY ? 
innerPlanTupleProjector : null, isInRowKeyOrder);
    +        OrderBy orderBy = OrderByCompiler.compile(
    +                context,
    +                select,
    +                groupBy,
    +                limit,
    +                offset,
    +                projector,
    +                groupBy == GroupBy.EMPTY_GROUP_BY ? 
innerPlanTupleProjector : null,
    +                groupBy == GroupBy.EMPTY_GROUP_BY ? isInRowKeyOrder : true,
    +                where);
    --- End diff --
    
    Eliminating order-by based on the inner plan ordering is definitely the 
right and ultimate solution, and we should get rid of all “dirty fix” flags 
here. The compile result, in our case, the QueryPlan should have a definite 
ordering whether it’s from an order by, or a group-by, or a natural row 
order, or an order-by from the inner query. However, letting QueryPlan contain 
that information might not be a good idea. So we should see if we can infer the 
ordering from a QueryPlan.


---

Reply via email to