phoenix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jamestay...@apache.org
Subject [2/2] phoenix git commit: PHOENIX-4274 Test case for Hint query for index on view does not use include
Date Tue, 03 Oct 2017 22:09:46 GMT
PHOENIX-4274 Test case for Hint query for index on view does not use include


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

Branch: refs/heads/4.x-HBase-1.1
Commit: e40bbfff1150e56e1ecb7cd22c49cee298496c2b
Parents: 347304e
Author: James Taylor <jtaylor@salesforce.com>
Authored: Tue Oct 3 15:04:30 2017 -0700
Committer: James Taylor <jtaylor@salesforce.com>
Committed: Tue Oct 3 15:08:44 2017 -0700

----------------------------------------------------------------------
 .../phoenix/end2end/index/ViewIndexIT.java      | 33 +++++++++++++++++++-
 1 file changed, 32 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/e40bbfff/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/ViewIndexIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/ViewIndexIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/ViewIndexIT.java
index 8ea6c27..53bb550 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/ViewIndexIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/ViewIndexIT.java
@@ -44,7 +44,6 @@ import org.apache.phoenix.jdbc.PhoenixStatement;
 import org.apache.phoenix.query.KeyRange;
 import org.apache.phoenix.query.QueryServices;
 import org.apache.phoenix.schema.PNameFactory;
-import org.apache.phoenix.schema.PTableType;
 import org.apache.phoenix.schema.TableNotFoundException;
 import org.apache.phoenix.util.MetaDataUtil;
 import org.apache.phoenix.util.PhoenixRuntime;
@@ -52,6 +51,7 @@ import org.apache.phoenix.util.PropertiesUtil;
 import org.apache.phoenix.util.QueryUtil;
 import org.apache.phoenix.util.SchemaUtil;
 import org.apache.phoenix.util.TestUtil;
+import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.junit.runners.Parameterized;
@@ -413,4 +413,35 @@ public class ViewIndexIT extends ParallelStatsDisabledIT {
             conn.close();
         }
     }
+    
+    @Test
+    public void testHintForIndexOnViewWithInclude() throws Exception {
+        testHintForIndexOnView(true);
+    }
+    
+    @Ignore("PHOENIX-4274 Hint query for index on view does not use include")
+    @Test
+    public void testHintForIndexOnViewWithoutInclude() throws Exception {
+        testHintForIndexOnView(false);        
+    }
+    
+    private void testHintForIndexOnView(boolean includeColumns) throws Exception {
+        Properties props = new Properties();
+        Connection conn1 = DriverManager.getConnection(getUrl(), props);
+        conn1.setAutoCommit(true);
+        String tableName=generateUniqueName();
+        String viewName=generateUniqueName();
+        String indexName=generateUniqueName();
+        conn1.createStatement().execute(
+          "CREATE TABLE "+tableName+" (k VARCHAR PRIMARY KEY, v1 VARCHAR, v2 VARCHAR) UPDATE_CACHE_FREQUENCY=1000000");
+        conn1.createStatement().execute("upsert into "+tableName+" values ('row1', 'value1',
'key1')");
+        conn1.createStatement().execute(
+          "CREATE VIEW "+viewName+" (v3 VARCHAR, v4 VARCHAR) AS SELECT * FROM "+tableName+"
WHERE v1 = 'value1'");
+        conn1.createStatement().execute("CREATE INDEX " + indexName + " ON " + viewName +
"(v3)" + (includeColumns ? " INCLUDE(v4)" : ""));
+        PhoenixStatement stmt = conn1.createStatement().unwrap(PhoenixStatement.class);
+        ResultSet rs = stmt.executeQuery("SELECT /*+ INDEX(" + viewName + " " + indexName
+ ") */ v1 FROM " + viewName + " WHERE v3 = 'foo' ORDER BY v4");
+        assertFalse(rs.next());
+        assertEquals(indexName, stmt.getQueryPlan().getContext().getCurrentTable().getTable().getName().getString());
+    }
+    
 }


Mime
View raw message