phoenix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From maryann...@apache.org
Subject phoenix git commit: PHOENIX-3029 Child/parent optimization cannot work with DESC columns
Date Wed, 06 Jul 2016 17:07:48 GMT
Repository: phoenix
Updated Branches:
  refs/heads/4.x-HBase-1.1 0faa90d3d -> c0f59b46d


PHOENIX-3029 Child/parent optimization cannot work with DESC columns


Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/c0f59b46
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/c0f59b46
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/c0f59b46

Branch: refs/heads/4.x-HBase-1.1
Commit: c0f59b46dac771904a4ac266c62855aad49a383b
Parents: 0faa90d
Author: maryannxue <maryann.xue@gmail.com>
Authored: Wed Jul 6 13:07:38 2016 -0400
Committer: maryannxue <maryann.xue@gmail.com>
Committed: Wed Jul 6 13:07:38 2016 -0400

----------------------------------------------------------------------
 .../apache/phoenix/end2end/HashJoinMoreIT.java  | 98 ++++++++++++--------
 .../apache/phoenix/compile/WhereOptimizer.java  |  8 +-
 2 files changed, 65 insertions(+), 41 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/c0f59b46/phoenix-core/src/it/java/org/apache/phoenix/end2end/HashJoinMoreIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/HashJoinMoreIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/HashJoinMoreIT.java
index 481e4af..c27db6b 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/HashJoinMoreIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/HashJoinMoreIT.java
@@ -881,45 +881,63 @@ public class HashJoinMoreIT extends BaseHBaseManagedTimeIT {
         Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
         Connection conn = DriverManager.getConnection(getUrl(), props);
         conn.setAutoCommit(true);
-        
-        conn.createStatement().execute("CREATE TABLE test2961 (\n" + 
-                "ACCOUNT_ID VARCHAR NOT NULL,\n" + 
-                "BUCKET_ID VARCHAR NOT NULL,\n" + 
-                "OBJECT_ID VARCHAR NOT NULL,\n" + 
-                "OBJECT_VERSION VARCHAR NOT NULL,\n" + 
-                "LOC VARCHAR,\n" + 
-                "CONSTRAINT PK PRIMARY KEY (ACCOUNT_ID, BUCKET_ID, OBJECT_ID, OBJECT_VERSION
DESC))");
-        conn.createStatement().execute("UPSERT INTO test2961  (ACCOUNT_ID, BUCKET_ID, OBJECT_ID,
OBJECT_VERSION, LOC) VALUES ('acct1', 'bucket1', 'obj1', '1111', 'loc1')");
-        ResultSet rs = conn.createStatement().executeQuery("select ACCOUNT_ID, BUCKET_ID,
OBJECT_VERSION  from test2961  WHERE ACCOUNT_ID = 'acct1' and BUCKET_ID = 'bucket1' and OBJECT_VERSION
= '1111'");
-        assertTrue(rs.next());
-        rs = conn.createStatement().executeQuery("select ACCOUNT_ID, BUCKET_ID, OBJECT_VERSION
 from test2961  WHERE ACCOUNT_ID = 'acct1' and BUCKET_ID = 'bucket1' and OBJECT_ID = 'obj1'");
-        assertTrue(rs.next());
-        rs = conn.createStatement().executeQuery("select ACCOUNT_ID, BUCKET_ID, OBJECT_VERSION
 from test2961  WHERE ACCOUNT_ID = 'acct1' and BUCKET_ID = 'bucket1' and OBJECT_VERSION =
'1111'  and OBJECT_ID = 'obj1'");
-        assertTrue(rs.next());
-
-        conn.createStatement().execute("UPSERT INTO test2961  (ACCOUNT_ID, BUCKET_ID, OBJECT_ID,
OBJECT_VERSION, LOC) VALUES ('acct1', 'bucket1', 'obj1', '2222', 'loc1')");
-        rs = conn.createStatement().executeQuery("SELECT  OBJ.ACCOUNT_ID, OBJ.BUCKET_ID,
OBJ.OBJECT_ID, OBJ.OBJECT_VERSION, OBJ.LOC "
-                + "FROM ( SELECT ACCOUNT_ID, BUCKET_ID, OBJECT_ID, MAX(OBJECT_VERSION) AS
MAXVER"
-                + "       FROM test2961 GROUP BY ACCOUNT_ID, BUCKET_ID, OBJECT_ID) AS X "
-                + "       INNER JOIN test2961 AS OBJ ON X.ACCOUNT_ID = OBJ.ACCOUNT_ID AND
X.BUCKET_ID = OBJ.BUCKET_ID AND X.OBJECT_ID = OBJ.OBJECT_ID AND X.MAXVER = OBJ.OBJECT_VERSION");
-        assertTrue(rs.next());
-        assertEquals("2222", rs.getString(4));
-        assertFalse(rs.next());
-        
-        rs = conn.createStatement().executeQuery("SELECT  OBJ.ACCOUNT_ID, OBJ.BUCKET_ID,
OBJ.OBJECT_ID, OBJ.OBJECT_VERSION, OBJ.LOC "
-                + "FROM ( SELECT ACCOUNT_ID, BUCKET_ID, OBJECT_ID, MAX(OBJECT_VERSION) AS
MAXVER "
-                + "       FROM test2961 GROUP BY ACCOUNT_ID, BUCKET_ID, OBJECT_ID) AS X "
-                + "       INNER JOIN test2961 AS OBJ ON X.ACCOUNT_ID = OBJ.ACCOUNT_ID AND
X.OBJECT_ID = OBJ.OBJECT_ID AND X.MAXVER = OBJ.OBJECT_VERSION");
-        assertTrue(rs.next());
-        assertEquals("2222", rs.getString(4));
-        assertFalse(rs.next());
-        
-        rs = conn.createStatement().executeQuery("SELECT  OBJ.ACCOUNT_ID, OBJ.BUCKET_ID,
OBJ.OBJECT_ID, OBJ.OBJECT_VERSION, OBJ.LOC "
-                + "FROM ( SELECT ACCOUNT_ID, BUCKET_ID, OBJECT_ID, MAX(OBJECT_VERSION) AS
MAXVER "
-                + "       FROM test2961 GROUP BY ACCOUNT_ID, BUCKET_ID, OBJECT_ID) AS X "
-                + "       INNER JOIN test2961 AS OBJ ON X.ACCOUNT_ID = OBJ.ACCOUNT_ID AND
X.BUCKET_ID = OBJ.BUCKET_ID AND  X.MAXVER = OBJ.OBJECT_VERSION");
-        assertTrue(rs.next());
-        assertEquals("2222", rs.getString(4));
-        assertFalse(rs.next());
+        try {
+            conn.createStatement().execute("CREATE TABLE test2961 (\n" + 
+                    "ACCOUNT_ID VARCHAR NOT NULL,\n" + 
+                    "BUCKET_ID VARCHAR NOT NULL,\n" + 
+                    "OBJECT_ID VARCHAR NOT NULL,\n" + 
+                    "OBJECT_VERSION VARCHAR NOT NULL,\n" + 
+                    "LOC VARCHAR,\n" + 
+                    "CONSTRAINT PK PRIMARY KEY (ACCOUNT_ID, BUCKET_ID, OBJECT_ID, OBJECT_VERSION
DESC))");
+            conn.createStatement().execute("UPSERT INTO test2961  (ACCOUNT_ID, BUCKET_ID,
OBJECT_ID, OBJECT_VERSION, LOC) VALUES ('acct1', 'bucket1', 'obj1', '1111', 'loc1')");
+            ResultSet rs = conn.createStatement().executeQuery("select ACCOUNT_ID, BUCKET_ID,
OBJECT_VERSION  from test2961  WHERE ACCOUNT_ID = 'acct1' and BUCKET_ID = 'bucket1' and OBJECT_VERSION
= '1111'");
+            assertTrue(rs.next());
+            rs = conn.createStatement().executeQuery("select ACCOUNT_ID, BUCKET_ID, OBJECT_VERSION
 from test2961  WHERE ACCOUNT_ID = 'acct1' and BUCKET_ID = 'bucket1' and OBJECT_ID = 'obj1'");
+            assertTrue(rs.next());
+            rs = conn.createStatement().executeQuery("select ACCOUNT_ID, BUCKET_ID, OBJECT_VERSION
 from test2961  WHERE ACCOUNT_ID = 'acct1' and BUCKET_ID = 'bucket1' and OBJECT_VERSION =
'1111'  and OBJECT_ID = 'obj1'");
+            assertTrue(rs.next());
+
+            conn.createStatement().execute("UPSERT INTO test2961  (ACCOUNT_ID, BUCKET_ID,
OBJECT_ID, OBJECT_VERSION, LOC) VALUES ('acct1', 'bucket1', 'obj1', '2222', 'loc1')");
+            rs = conn.createStatement().executeQuery("SELECT  OBJ.ACCOUNT_ID, OBJ.BUCKET_ID,
OBJ.OBJECT_ID, OBJ.OBJECT_VERSION, OBJ.LOC "
+                    + "FROM ( SELECT ACCOUNT_ID, BUCKET_ID, OBJECT_ID, MAX(OBJECT_VERSION)
AS MAXVER"
+                    + "       FROM test2961 GROUP BY ACCOUNT_ID, BUCKET_ID, OBJECT_ID) AS
X "
+                    + "       INNER JOIN test2961 AS OBJ ON X.ACCOUNT_ID = OBJ.ACCOUNT_ID
AND X.BUCKET_ID = OBJ.BUCKET_ID AND X.OBJECT_ID = OBJ.OBJECT_ID AND X.MAXVER = OBJ.OBJECT_VERSION");
+            assertTrue(rs.next());
+            assertEquals("2222", rs.getString(4));
+            assertFalse(rs.next());
+
+            rs = conn.createStatement().executeQuery("SELECT  OBJ.ACCOUNT_ID, OBJ.BUCKET_ID,
OBJ.OBJECT_ID, OBJ.OBJECT_VERSION, OBJ.LOC "
+                    + "FROM ( SELECT ACCOUNT_ID, BUCKET_ID, OBJECT_ID, MAX(OBJECT_VERSION)
AS MAXVER "
+                    + "       FROM test2961 GROUP BY ACCOUNT_ID, BUCKET_ID, OBJECT_ID) AS
X "
+                    + "       INNER JOIN test2961 AS OBJ ON X.ACCOUNT_ID = OBJ.ACCOUNT_ID
AND X.OBJECT_ID = OBJ.OBJECT_ID AND X.MAXVER = OBJ.OBJECT_VERSION");
+            assertTrue(rs.next());
+            assertEquals("2222", rs.getString(4));
+            assertFalse(rs.next());
+
+            rs = conn.createStatement().executeQuery("SELECT  OBJ.ACCOUNT_ID, OBJ.BUCKET_ID,
OBJ.OBJECT_ID, OBJ.OBJECT_VERSION, OBJ.LOC "
+                    + "FROM ( SELECT ACCOUNT_ID, BUCKET_ID, OBJECT_ID, MAX(OBJECT_VERSION)
AS MAXVER "
+                    + "       FROM test2961 GROUP BY ACCOUNT_ID, BUCKET_ID, OBJECT_ID) AS
X "
+                    + "       INNER JOIN test2961 AS OBJ ON X.ACCOUNT_ID = OBJ.ACCOUNT_ID
AND X.BUCKET_ID = OBJ.BUCKET_ID AND  X.MAXVER = OBJ.OBJECT_VERSION");
+            assertTrue(rs.next());
+            assertEquals("2222", rs.getString(4));
+            assertFalse(rs.next());
+
+            conn.createStatement().execute("UPSERT INTO test2961  (ACCOUNT_ID, BUCKET_ID,
OBJECT_ID, OBJECT_VERSION, LOC) VALUES ('acct1', 'bucket1', 'obj2', '1111', 'loc1')");
+            conn.createStatement().execute("UPSERT INTO test2961  (ACCOUNT_ID, BUCKET_ID,
OBJECT_ID, OBJECT_VERSION, LOC) VALUES ('acct1', 'bucket1', 'obj3', '1111', 'loc1')");
+            String q = "SELECT  OBJ.ACCOUNT_ID, OBJ.BUCKET_ID, OBJ.OBJECT_ID, OBJ.OBJECT_VERSION,
OBJ.LOC "
+                    + "FROM ( SELECT ACCOUNT_ID, BUCKET_ID, OBJECT_ID, MAX(OBJECT_VERSION)
AS MAXVER "
+                    + "       FROM test2961 GROUP BY ACCOUNT_ID, BUCKET_ID, OBJECT_ID) AS
X "
+                    + "       INNER JOIN test2961 AS OBJ ON X.ACCOUNT_ID = OBJ.ACCOUNT_ID
AND X.BUCKET_ID = OBJ.BUCKET_ID AND X.OBJECT_ID = OBJ.OBJECT_ID AND  X.MAXVER = OBJ.OBJECT_VERSION";
+            rs = conn.createStatement().executeQuery(q);
+            assertTrue(rs.next());
+            assertEquals("2222", rs.getString(4));
+            assertTrue(rs.next());
+            assertEquals("1111", rs.getString(4));
+            assertTrue(rs.next());
+            assertEquals("1111", rs.getString(4));
+            assertFalse(rs.next());
+        } finally {
+            conn.close();
+        }
     }
 }

http://git-wip-us.apache.org/repos/asf/phoenix/blob/c0f59b46/phoenix-core/src/main/java/org/apache/phoenix/compile/WhereOptimizer.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/compile/WhereOptimizer.java b/phoenix-core/src/main/java/org/apache/phoenix/compile/WhereOptimizer.java
index 8c2a216..f49aa52 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/compile/WhereOptimizer.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/WhereOptimizer.java
@@ -325,8 +325,14 @@ public class WhereOptimizer {
         final List<Integer> pkPositions = Lists.newArrayList();
         PTable table = context.getCurrentTable().getTable();
         for (int i = 0; i < expressions.size(); i++) {
+            Expression expression = expressions.get(i);
+            // TODO this is a temporary fix for PHOENIX-3029.
+            if (expression instanceof CoerceExpression
+                    && expression.getSortOrder() != expression.getChildren().get(0).getSortOrder())
{
+                continue;
+            }
             KeyExpressionVisitor visitor = new KeyExpressionVisitor(context, table);
-            KeyExpressionVisitor.KeySlots keySlots = expressions.get(i).accept(visitor);
+            KeyExpressionVisitor.KeySlots keySlots = expression.accept(visitor);
             int minPkPos = Integer.MAX_VALUE; 
             if (keySlots != null) {
                 Iterator<KeyExpressionVisitor.KeySlot> iterator = keySlots.iterator();


Mime
View raw message