phoenix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jamestay...@apache.org
Subject [1/3] phoenix git commit: PHOENIX-2768 Add test for case sensitive table with index hint
Date Tue, 15 Mar 2016 23:49:17 GMT
Repository: phoenix
Updated Branches:
  refs/heads/4.x-HBase-0.98 f0b76dd80 -> 4ddf63ec9


PHOENIX-2768 Add test for case sensitive table with index hint


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

Branch: refs/heads/4.x-HBase-0.98
Commit: 0c93d2981ae1b1ed21bfeaa470216829cffda0d5
Parents: f0b76dd
Author: James Taylor <jtaylor@salesforce.com>
Authored: Mon Mar 14 20:33:03 2016 -0700
Committer: James Taylor <jtaylor@salesforce.com>
Committed: Tue Mar 15 16:36:28 2016 -0700

----------------------------------------------------------------------
 .../phoenix/compile/QueryOptimizerTest.java     | 28 ++++++++++++++++++++
 1 file changed, 28 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/0c93d298/phoenix-core/src/test/java/org/apache/phoenix/compile/QueryOptimizerTest.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/test/java/org/apache/phoenix/compile/QueryOptimizerTest.java
b/phoenix-core/src/test/java/org/apache/phoenix/compile/QueryOptimizerTest.java
index e528d3b..c3345ba 100644
--- a/phoenix-core/src/test/java/org/apache/phoenix/compile/QueryOptimizerTest.java
+++ b/phoenix-core/src/test/java/org/apache/phoenix/compile/QueryOptimizerTest.java
@@ -273,6 +273,34 @@ public class QueryOptimizerTest extends BaseConnectionlessQueryTest {
         PhoenixStatement stmt = conn.createStatement().unwrap(PhoenixStatement.class);
         QueryPlan plan = stmt.optimizeQuery("SELECT /*+ INDEX(t  idx1) */ k FROM t WHERE
v1 = 'foo' AND v2 = 'bar'");
         assertEquals("IDX1", plan.getTableRef().getTable().getTableName().getString());
+        plan = stmt.optimizeQuery("SELECT k FROM t WHERE v1 = 'foo' AND v2 = 'bar'");
+        assertEquals("IDX2", plan.getTableRef().getTable().getTableName().getString());
+    }
+
+    @Test
+    public void testChooseIndexFromCaseSensitiveHint() throws Exception {
+        Connection conn = DriverManager.getConnection(getUrl());
+        conn.createStatement().execute("CREATE TABLE \"t\" (k INTEGER NOT NULL PRIMARY KEY,
v1 VARCHAR, v2 VARCHAR) IMMUTABLE_ROWS=true");
+        conn.createStatement().execute("CREATE INDEX idx1 ON \"t\"(v1) INCLUDE(v2)");
+        conn.createStatement().execute("CREATE INDEX idx2 ON \"t\"(v1,v2)");
+        PhoenixStatement stmt = conn.createStatement().unwrap(PhoenixStatement.class);
+        QueryPlan plan = stmt.optimizeQuery("SELECT /*+ INDEX(\"t\" idx1) */ k FROM \"t\"
WHERE v1 = 'foo' AND v2 = 'bar'");
+        assertEquals("IDX1", plan.getTableRef().getTable().getTableName().getString());
+        plan = stmt.optimizeQuery("SELECT k FROM \"t\" WHERE v1 = 'foo' AND v2 = 'bar'");
+        assertEquals("IDX2", plan.getTableRef().getTable().getTableName().getString());
+    }
+
+    @Test
+    public void testChooseIndexFromCaseSensitiveHint2() throws Exception {
+        Connection conn = DriverManager.getConnection(getUrl());
+        conn.createStatement().execute("CREATE TABLE \"t\" (k INTEGER NOT NULL PRIMARY KEY,
v1 VARCHAR, v2 VARCHAR) IMMUTABLE_ROWS=true");
+        conn.createStatement().execute("CREATE INDEX \"idx1\" ON \"t\"(v1) INCLUDE(v2)");
+        conn.createStatement().execute("CREATE INDEX \"idx2\" ON \"t\"(v1,v2)");
+        PhoenixStatement stmt = conn.createStatement().unwrap(PhoenixStatement.class);
+        QueryPlan plan = stmt.optimizeQuery("SELECT /*+ INDEX(\"t\" \"idx1\") */ k FROM \"t\"
WHERE v1 = 'foo' AND v2 = 'bar'");
+        assertEquals("idx1", plan.getTableRef().getTable().getTableName().getString());
+        plan = stmt.optimizeQuery("SELECT k FROM \"t\" WHERE v1 = 'foo' AND v2 = 'bar'");
+        assertEquals("idx2", plan.getTableRef().getTable().getTableName().getString());
     }
 
     


Mime
View raw message