phoenix-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Shuxiong Ye <yeshuxi...@gmail.com>
Subject Questions about test testOrderByOrderPreservingRev in QueryCompilerTest
Date Wed, 10 Jun 2015 16:58:21 GMT
Hi community,

I have a question about test  testOrderByOrderPreservingRev in
QueryCompilerTest.

    @Test
    public void testOrderByOrderPreservingRev() throws Exception {
        Connection conn = DriverManager.getConnection(getUrl());
        conn.createStatement().execute("CREATE TABLE t (k1 date not
null, k2 date not null, k3 date not null, v varchar, constraint pk
primary key(k1,k2 DESC,k3))");
        String[] queries = {
                "SELECT * FROM T ORDER BY INVERT(k1),k2",
                "SELECT * FROM T ORDER BY INVERT(k1)",
                 "SELECT * FROM T ORDER BY TRUNC(k1, 'DAY') DESC,
CEIL(k2, 'HOUR') DESC", // <---- I have a question here.
 "SELECT * FROM T ORDER BY k1 DESC",
                };
        String query;
        for (int i = 0; i < queries.length; i++) {
            query = queries[i];
            QueryPlan plan =
conn.createStatement().unwrap(PhoenixStatement.class).compileQuery(query);
            assertTrue("Expected order by to be compiled out: " +
query, plan.getOrderBy() == OrderBy.REV_ROW_KEY_ORDER_BY);
        }
    }

In the third query, why is CEIL(k2, 'HOUR') DESC instead of CEIL(k2,
'HOUR')?
In the primary key definition, "primary key(k1,k2 DESC,k3))", k2 is
descending.

When the order by clause is "TRUNC(k1, 'DAY') DESC, CEIL(k2, 'HOUR')", it
will be opposite with the primary key definition, "primary key(k1,k2
DESC,k3))", so the QueryPlan has an empty order by, for we can scan the
data forward. Is my understanding right?

see it in jira here [1].

Thanks.

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

Shuxiong Ye

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message