[ 
https://issues.apache.org/jira/browse/PHOENIX-4611?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16368026#comment-16368026
 ] 

Maryann Xue commented on PHOENIX-4611:
--------------------------------------

Sorry, [~jamestaylor], I made a mistake in my last comment.

It was caused by the group-by expression re-ordering in GroupByCompiler as 
follows:
{code:java}
Collections.sort(groupBys, new Comparator<Pair<Integer,Expression>>() {
    @Override
    public int compare(Pair<Integer,Expression> gb1, Pair<Integer,Expression> 
gb2) {
        Expression e1 = gb1.getSecond();
        Expression e2 = gb2.getSecond();
        PDataType t1 = e1.getDataType();
        PDataType t2 = e2.getDataType();
        boolean isFixed1 = t1.isFixedWidth();
        boolean isFixed2 = t2.isFixedWidth();
        boolean isFixedNullable1 = e1.isNullable() &&isFixed1;
        boolean isFixedNullable2 = e2.isNullable() && isFixed2;
        boolean oae1 = onlyAtEndType(e1);
        boolean oae2 = onlyAtEndType(e2);
        if (oae1 == oae2) {
            if (isFixedNullable1 == isFixedNullable2) {
                if (isFixed1 == isFixed2) {
                    // Not strictly necessary, but forces the order to match 
the schema
                    // column order (with PK columns before value columns).
                    //return o1.getColumnPosition() - o2.getColumnPosition();
                    return gb1.getFirst() - gb2.getFirst();
                } else if (isFixed1) {
                    return -1;
                } else {
                    return 1;
                }
            } else if (isFixedNullable1) {
                return 1;
            } else {
                return -1;
            }
        } else if (oae1) {
            return 1;
        } else {
            return -1;
        }
    }
});{code}

And it did not affect the ResultSet. It just changed the execution plan a 
little bit, with two expressions swapped. Can you verify that it was the right 
behavior after PHOENIX-2566? If yes, we can revert 
https://git-wip-us.apache.org/repos/asf?p=phoenix.git;a=blobdiff;f=phoenix-core/src/main/java/org/apache/phoenix/compile/TupleProjectionCompiler.java;h=fccded2a896855a2a01d727b992f954a1d3fa8ab;hp=d0b900c1a9c21609b89065307433a0d37b12b72a;hb=82ba1417fdd69a0ac57cbcf2f2327d4aa371bcd9;hpb=e126dd1dda5aa80e8296d3b0c84736b22b658999
 and change tests accordingly.

> Not nullable column impact on join query plans
> ----------------------------------------------
>
>                 Key: PHOENIX-4611
>                 URL: https://issues.apache.org/jira/browse/PHOENIX-4611
>             Project: Phoenix
>          Issue Type: Bug
>            Reporter: James Taylor
>            Priority: Major
>
> With PHOENIX-2566, there's a subtle change in projected tables in that a 
> column may end up being not nullable where as before it was nullable when the 
> family name is not null. I've kept the old behavior with 
> [this|https://git-wip-us.apache.org/repos/asf?p=phoenix.git;a=blobdiff;f=phoenix-core/src/main/java/org/apache/phoenix/compile/TupleProjectionCompiler.java;h=fccded2a896855a2a01d727b992f954a1d3fa8ab;hp=d0b900c1a9c21609b89065307433a0d37b12b72a;hb=82ba1417fdd69a0ac57cbcf2f2327d4aa371bcd9;hpb=e126dd1dda5aa80e8296d3b0c84736b22b658999]
>  commit, but would you mind confirming what the right thing to do is, 
> [~maryannxue]?
> Without this change, the explain plan changes in 
> SortMergeJoinMoreIT.testBug2894() and the assert fails. Looks like the 
> compiler ends up changing the row ordering.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to