[1/2] phoenix git commit: PHOENIX-4712 When creating an index on a table, meta data cache of views related to the table isn't updated [Forced Update!]

2018-05-02 Thread pboado
Repository: phoenix
Updated Branches:
  refs/heads/4.x-cdh5.14 2b22c2986 -> c943a5715 (forced update)


PHOENIX-4712 When creating an index on a table, meta data cache of views 
related to the table isn't updated


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

Branch: refs/heads/4.x-cdh5.14
Commit: cf4ee4bd8a19584dea1030e1033c7c6d5b30a592
Parents: 6b5ff31
Author: Thomas D'Silva 
Authored: Tue May 1 21:32:45 2018 +0100
Committer: Pedro Boado 
Committed: Wed May 2 09:03:25 2018 +0100

--
 .../java/org/apache/phoenix/end2end/ViewIT.java | 46 
 .../apache/phoenix/schema/MetaDataClient.java   | 11 +++--
 2 files changed, 53 insertions(+), 4 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/cf4ee4bd/phoenix-core/src/it/java/org/apache/phoenix/end2end/ViewIT.java
--
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ViewIT.java 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ViewIT.java
index 5c0d100..279bbd7 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ViewIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ViewIT.java
@@ -33,6 +33,7 @@ import java.sql.DriverManager;
 import java.sql.PreparedStatement;
 import java.sql.ResultSet;
 import java.sql.SQLException;
+import java.sql.Statement;
 import java.util.List;
 import java.util.Properties;
 
@@ -894,6 +895,51 @@ public class ViewIT extends BaseViewIT {
 }
 }
 
+@Test
+public void testQueryWithSeparateConnectionForViewOnTableThatHasIndex() 
throws SQLException {
+try (Connection conn = DriverManager.getConnection(getUrl());
+Connection conn2 = DriverManager.getConnection(getUrl());
+Statement s = conn.createStatement();
+Statement s2 = conn2.createStatement()) {
+String tableName = generateUniqueName();
+String viewName = generateUniqueName();
+String indexName = generateUniqueName();
+helpTestQueryForViewOnTableThatHasIndex(s, s2, tableName, 
viewName, indexName);
+}
+}
+
+@Test
+public void testQueryForViewOnTableThatHasIndex() throws SQLException {
+try (Connection conn = DriverManager.getConnection(getUrl());
+Statement s = conn.createStatement()) {
+String tableName = generateUniqueName();
+String viewName = generateUniqueName();
+String indexName = generateUniqueName();
+helpTestQueryForViewOnTableThatHasIndex(s, s, tableName, viewName, 
indexName);
+}
+}
+
+private void helpTestQueryForViewOnTableThatHasIndex(Statement s1, 
Statement s2, String tableName, String viewName, String indexName)
+throws SQLException {
+// Create a table
+s1.execute("create table " + tableName + " (col1 varchar primary key, 
col2 varchar)");
+
+// Create a view on the table
+s1.execute("create view " + viewName + " (col3 varchar) as select * 
from " + tableName);
+s1.executeQuery("select * from " + viewName);
+// Create a index on the table
+s1.execute("create index " + indexName + " ON " + tableName + " 
(col2)");
+
+try (ResultSet rs =
+s2.executeQuery("explain select /*+ INDEX(" + viewName + " " + 
indexName
++ ") */ * from " + viewName + " where col2 = 'aaa'")) {
+String explainPlan = QueryUtil.getExplainPlan(rs);
+
+// check if the query uses the index
+assertTrue(explainPlan.contains(indexName));
+}
+}
+
 private void validate(String viewName, Connection tenantConn, String[] 
whereClauseArray,
 long[] expectedArray) throws SQLException {
 for (int i = 0; i < whereClauseArray.length; ++i) {

http://git-wip-us.apache.org/repos/asf/phoenix/blob/cf4ee4bd/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java 
b/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java
index 69d8a56..009289b 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java
@@ -682,7 +682,7 @@ public class MetaDataClient {
 // In this case, we update the parent table which 
may in turn pull
 // in indexes to add to this table.
   

[1/2] phoenix git commit: PHOENIX-4712 When creating an index on a table, meta data cache of views related to the table isn't updated [Forced Update!]

2018-05-02 Thread pboado
Repository: phoenix
Updated Branches:
  refs/heads/4.x-cdh5.13 d1a0df37a -> db0d7030d (forced update)


PHOENIX-4712 When creating an index on a table, meta data cache of views 
related to the table isn't updated


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

Branch: refs/heads/4.x-cdh5.13
Commit: cf4ee4bd8a19584dea1030e1033c7c6d5b30a592
Parents: 6b5ff31
Author: Thomas D'Silva 
Authored: Tue May 1 21:32:45 2018 +0100
Committer: Pedro Boado 
Committed: Wed May 2 09:03:25 2018 +0100

--
 .../java/org/apache/phoenix/end2end/ViewIT.java | 46 
 .../apache/phoenix/schema/MetaDataClient.java   | 11 +++--
 2 files changed, 53 insertions(+), 4 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/cf4ee4bd/phoenix-core/src/it/java/org/apache/phoenix/end2end/ViewIT.java
--
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ViewIT.java 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ViewIT.java
index 5c0d100..279bbd7 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ViewIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ViewIT.java
@@ -33,6 +33,7 @@ import java.sql.DriverManager;
 import java.sql.PreparedStatement;
 import java.sql.ResultSet;
 import java.sql.SQLException;
+import java.sql.Statement;
 import java.util.List;
 import java.util.Properties;
 
@@ -894,6 +895,51 @@ public class ViewIT extends BaseViewIT {
 }
 }
 
+@Test
+public void testQueryWithSeparateConnectionForViewOnTableThatHasIndex() 
throws SQLException {
+try (Connection conn = DriverManager.getConnection(getUrl());
+Connection conn2 = DriverManager.getConnection(getUrl());
+Statement s = conn.createStatement();
+Statement s2 = conn2.createStatement()) {
+String tableName = generateUniqueName();
+String viewName = generateUniqueName();
+String indexName = generateUniqueName();
+helpTestQueryForViewOnTableThatHasIndex(s, s2, tableName, 
viewName, indexName);
+}
+}
+
+@Test
+public void testQueryForViewOnTableThatHasIndex() throws SQLException {
+try (Connection conn = DriverManager.getConnection(getUrl());
+Statement s = conn.createStatement()) {
+String tableName = generateUniqueName();
+String viewName = generateUniqueName();
+String indexName = generateUniqueName();
+helpTestQueryForViewOnTableThatHasIndex(s, s, tableName, viewName, 
indexName);
+}
+}
+
+private void helpTestQueryForViewOnTableThatHasIndex(Statement s1, 
Statement s2, String tableName, String viewName, String indexName)
+throws SQLException {
+// Create a table
+s1.execute("create table " + tableName + " (col1 varchar primary key, 
col2 varchar)");
+
+// Create a view on the table
+s1.execute("create view " + viewName + " (col3 varchar) as select * 
from " + tableName);
+s1.executeQuery("select * from " + viewName);
+// Create a index on the table
+s1.execute("create index " + indexName + " ON " + tableName + " 
(col2)");
+
+try (ResultSet rs =
+s2.executeQuery("explain select /*+ INDEX(" + viewName + " " + 
indexName
++ ") */ * from " + viewName + " where col2 = 'aaa'")) {
+String explainPlan = QueryUtil.getExplainPlan(rs);
+
+// check if the query uses the index
+assertTrue(explainPlan.contains(indexName));
+}
+}
+
 private void validate(String viewName, Connection tenantConn, String[] 
whereClauseArray,
 long[] expectedArray) throws SQLException {
 for (int i = 0; i < whereClauseArray.length; ++i) {

http://git-wip-us.apache.org/repos/asf/phoenix/blob/cf4ee4bd/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java 
b/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java
index 69d8a56..009289b 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java
@@ -682,7 +682,7 @@ public class MetaDataClient {
 // In this case, we update the parent table which 
may in turn pull
 // in indexes to add to this table.
   

phoenix git commit: PHOENIX-4712 When creating an index on a table, meta data cache of views related to the table isn't updated

2018-05-02 Thread pboado
Repository: phoenix
Updated Branches:
  refs/heads/4.x-cdh5.11 6b5ff3177 -> cf4ee4bd8


PHOENIX-4712 When creating an index on a table, meta data cache of views 
related to the table isn't updated


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

Branch: refs/heads/4.x-cdh5.11
Commit: cf4ee4bd8a19584dea1030e1033c7c6d5b30a592
Parents: 6b5ff31
Author: Thomas D'Silva 
Authored: Tue May 1 21:32:45 2018 +0100
Committer: Pedro Boado 
Committed: Wed May 2 09:03:25 2018 +0100

--
 .../java/org/apache/phoenix/end2end/ViewIT.java | 46 
 .../apache/phoenix/schema/MetaDataClient.java   | 11 +++--
 2 files changed, 53 insertions(+), 4 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/cf4ee4bd/phoenix-core/src/it/java/org/apache/phoenix/end2end/ViewIT.java
--
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ViewIT.java 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ViewIT.java
index 5c0d100..279bbd7 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ViewIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ViewIT.java
@@ -33,6 +33,7 @@ import java.sql.DriverManager;
 import java.sql.PreparedStatement;
 import java.sql.ResultSet;
 import java.sql.SQLException;
+import java.sql.Statement;
 import java.util.List;
 import java.util.Properties;
 
@@ -894,6 +895,51 @@ public class ViewIT extends BaseViewIT {
 }
 }
 
+@Test
+public void testQueryWithSeparateConnectionForViewOnTableThatHasIndex() 
throws SQLException {
+try (Connection conn = DriverManager.getConnection(getUrl());
+Connection conn2 = DriverManager.getConnection(getUrl());
+Statement s = conn.createStatement();
+Statement s2 = conn2.createStatement()) {
+String tableName = generateUniqueName();
+String viewName = generateUniqueName();
+String indexName = generateUniqueName();
+helpTestQueryForViewOnTableThatHasIndex(s, s2, tableName, 
viewName, indexName);
+}
+}
+
+@Test
+public void testQueryForViewOnTableThatHasIndex() throws SQLException {
+try (Connection conn = DriverManager.getConnection(getUrl());
+Statement s = conn.createStatement()) {
+String tableName = generateUniqueName();
+String viewName = generateUniqueName();
+String indexName = generateUniqueName();
+helpTestQueryForViewOnTableThatHasIndex(s, s, tableName, viewName, 
indexName);
+}
+}
+
+private void helpTestQueryForViewOnTableThatHasIndex(Statement s1, 
Statement s2, String tableName, String viewName, String indexName)
+throws SQLException {
+// Create a table
+s1.execute("create table " + tableName + " (col1 varchar primary key, 
col2 varchar)");
+
+// Create a view on the table
+s1.execute("create view " + viewName + " (col3 varchar) as select * 
from " + tableName);
+s1.executeQuery("select * from " + viewName);
+// Create a index on the table
+s1.execute("create index " + indexName + " ON " + tableName + " 
(col2)");
+
+try (ResultSet rs =
+s2.executeQuery("explain select /*+ INDEX(" + viewName + " " + 
indexName
++ ") */ * from " + viewName + " where col2 = 'aaa'")) {
+String explainPlan = QueryUtil.getExplainPlan(rs);
+
+// check if the query uses the index
+assertTrue(explainPlan.contains(indexName));
+}
+}
+
 private void validate(String viewName, Connection tenantConn, String[] 
whereClauseArray,
 long[] expectedArray) throws SQLException {
 for (int i = 0; i < whereClauseArray.length; ++i) {

http://git-wip-us.apache.org/repos/asf/phoenix/blob/cf4ee4bd/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java 
b/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java
index 69d8a56..009289b 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java
@@ -682,7 +682,7 @@ public class MetaDataClient {
 // In this case, we update the parent table which 
may in turn pull
 // in indexes to add to this table.
   

[1/2] phoenix git commit: PHOENIX-4712 When creating an index on a table, meta data cache of views related to the table isn't updated [Forced Update!]

2018-05-02 Thread pboado
Repository: phoenix
Updated Branches:
  refs/heads/4.x-cdh5.12 5de0ec17e -> 719836e8f (forced update)


PHOENIX-4712 When creating an index on a table, meta data cache of views 
related to the table isn't updated


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

Branch: refs/heads/4.x-cdh5.12
Commit: cf4ee4bd8a19584dea1030e1033c7c6d5b30a592
Parents: 6b5ff31
Author: Thomas D'Silva 
Authored: Tue May 1 21:32:45 2018 +0100
Committer: Pedro Boado 
Committed: Wed May 2 09:03:25 2018 +0100

--
 .../java/org/apache/phoenix/end2end/ViewIT.java | 46 
 .../apache/phoenix/schema/MetaDataClient.java   | 11 +++--
 2 files changed, 53 insertions(+), 4 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/cf4ee4bd/phoenix-core/src/it/java/org/apache/phoenix/end2end/ViewIT.java
--
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ViewIT.java 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ViewIT.java
index 5c0d100..279bbd7 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ViewIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ViewIT.java
@@ -33,6 +33,7 @@ import java.sql.DriverManager;
 import java.sql.PreparedStatement;
 import java.sql.ResultSet;
 import java.sql.SQLException;
+import java.sql.Statement;
 import java.util.List;
 import java.util.Properties;
 
@@ -894,6 +895,51 @@ public class ViewIT extends BaseViewIT {
 }
 }
 
+@Test
+public void testQueryWithSeparateConnectionForViewOnTableThatHasIndex() 
throws SQLException {
+try (Connection conn = DriverManager.getConnection(getUrl());
+Connection conn2 = DriverManager.getConnection(getUrl());
+Statement s = conn.createStatement();
+Statement s2 = conn2.createStatement()) {
+String tableName = generateUniqueName();
+String viewName = generateUniqueName();
+String indexName = generateUniqueName();
+helpTestQueryForViewOnTableThatHasIndex(s, s2, tableName, 
viewName, indexName);
+}
+}
+
+@Test
+public void testQueryForViewOnTableThatHasIndex() throws SQLException {
+try (Connection conn = DriverManager.getConnection(getUrl());
+Statement s = conn.createStatement()) {
+String tableName = generateUniqueName();
+String viewName = generateUniqueName();
+String indexName = generateUniqueName();
+helpTestQueryForViewOnTableThatHasIndex(s, s, tableName, viewName, 
indexName);
+}
+}
+
+private void helpTestQueryForViewOnTableThatHasIndex(Statement s1, 
Statement s2, String tableName, String viewName, String indexName)
+throws SQLException {
+// Create a table
+s1.execute("create table " + tableName + " (col1 varchar primary key, 
col2 varchar)");
+
+// Create a view on the table
+s1.execute("create view " + viewName + " (col3 varchar) as select * 
from " + tableName);
+s1.executeQuery("select * from " + viewName);
+// Create a index on the table
+s1.execute("create index " + indexName + " ON " + tableName + " 
(col2)");
+
+try (ResultSet rs =
+s2.executeQuery("explain select /*+ INDEX(" + viewName + " " + 
indexName
++ ") */ * from " + viewName + " where col2 = 'aaa'")) {
+String explainPlan = QueryUtil.getExplainPlan(rs);
+
+// check if the query uses the index
+assertTrue(explainPlan.contains(indexName));
+}
+}
+
 private void validate(String viewName, Connection tenantConn, String[] 
whereClauseArray,
 long[] expectedArray) throws SQLException {
 for (int i = 0; i < whereClauseArray.length; ++i) {

http://git-wip-us.apache.org/repos/asf/phoenix/blob/cf4ee4bd/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java 
b/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java
index 69d8a56..009289b 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java
@@ -682,7 +682,7 @@ public class MetaDataClient {
 // In this case, we update the parent table which 
may in turn pull
 // in indexes to add to this table.
   

phoenix git commit: PHOENIX-4712 When creating an index on a table, meta data cache of views related to the table isn't updated

2018-05-01 Thread tdsilva
Repository: phoenix
Updated Branches:
  refs/heads/master de87cf50a -> 40ff0b95e


PHOENIX-4712 When creating an index on a table, meta data cache of views 
related to the table isn't updated


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

Branch: refs/heads/master
Commit: 40ff0b95e6d994e8dcf7a49a98bdc5a1bad2ef82
Parents: de87cf5
Author: Thomas D'Silva 
Authored: Tue May 1 13:32:45 2018 -0700
Committer: Thomas D'Silva 
Committed: Tue May 1 21:20:59 2018 -0700

--
 .../java/org/apache/phoenix/end2end/ViewIT.java | 46 
 .../apache/phoenix/schema/MetaDataClient.java   | 11 +++--
 2 files changed, 53 insertions(+), 4 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/40ff0b95/phoenix-core/src/it/java/org/apache/phoenix/end2end/ViewIT.java
--
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ViewIT.java 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ViewIT.java
index 5c0d100..279bbd7 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ViewIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ViewIT.java
@@ -33,6 +33,7 @@ import java.sql.DriverManager;
 import java.sql.PreparedStatement;
 import java.sql.ResultSet;
 import java.sql.SQLException;
+import java.sql.Statement;
 import java.util.List;
 import java.util.Properties;
 
@@ -894,6 +895,51 @@ public class ViewIT extends BaseViewIT {
 }
 }
 
+@Test
+public void testQueryWithSeparateConnectionForViewOnTableThatHasIndex() 
throws SQLException {
+try (Connection conn = DriverManager.getConnection(getUrl());
+Connection conn2 = DriverManager.getConnection(getUrl());
+Statement s = conn.createStatement();
+Statement s2 = conn2.createStatement()) {
+String tableName = generateUniqueName();
+String viewName = generateUniqueName();
+String indexName = generateUniqueName();
+helpTestQueryForViewOnTableThatHasIndex(s, s2, tableName, 
viewName, indexName);
+}
+}
+
+@Test
+public void testQueryForViewOnTableThatHasIndex() throws SQLException {
+try (Connection conn = DriverManager.getConnection(getUrl());
+Statement s = conn.createStatement()) {
+String tableName = generateUniqueName();
+String viewName = generateUniqueName();
+String indexName = generateUniqueName();
+helpTestQueryForViewOnTableThatHasIndex(s, s, tableName, viewName, 
indexName);
+}
+}
+
+private void helpTestQueryForViewOnTableThatHasIndex(Statement s1, 
Statement s2, String tableName, String viewName, String indexName)
+throws SQLException {
+// Create a table
+s1.execute("create table " + tableName + " (col1 varchar primary key, 
col2 varchar)");
+
+// Create a view on the table
+s1.execute("create view " + viewName + " (col3 varchar) as select * 
from " + tableName);
+s1.executeQuery("select * from " + viewName);
+// Create a index on the table
+s1.execute("create index " + indexName + " ON " + tableName + " 
(col2)");
+
+try (ResultSet rs =
+s2.executeQuery("explain select /*+ INDEX(" + viewName + " " + 
indexName
++ ") */ * from " + viewName + " where col2 = 'aaa'")) {
+String explainPlan = QueryUtil.getExplainPlan(rs);
+
+// check if the query uses the index
+assertTrue(explainPlan.contains(indexName));
+}
+}
+
 private void validate(String viewName, Connection tenantConn, String[] 
whereClauseArray,
 long[] expectedArray) throws SQLException {
 for (int i = 0; i < whereClauseArray.length; ++i) {

http://git-wip-us.apache.org/repos/asf/phoenix/blob/40ff0b95/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java 
b/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java
index 69d8a56..009289b 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java
@@ -682,7 +682,7 @@ public class MetaDataClient {
 // In this case, we update the parent table which 
may in turn pull
 // in indexes to add to this table.
 l

phoenix git commit: PHOENIX-4712 When creating an index on a table, meta data cache of views related to the table isn't updated

2018-05-01 Thread tdsilva
Repository: phoenix
Updated Branches:
  refs/heads/5.x-HBase-2.0 87564a864 -> 6db0cb04d


PHOENIX-4712 When creating an index on a table, meta data cache of views 
related to the table isn't updated


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

Branch: refs/heads/5.x-HBase-2.0
Commit: 6db0cb04df9633812365a6280a07a0a7a3caba6d
Parents: 87564a8
Author: Thomas D'Silva 
Authored: Tue May 1 13:32:45 2018 -0700
Committer: Thomas D'Silva 
Committed: Tue May 1 21:20:49 2018 -0700

--
 .../java/org/apache/phoenix/end2end/ViewIT.java | 46 
 .../apache/phoenix/schema/MetaDataClient.java   | 11 +++--
 2 files changed, 53 insertions(+), 4 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/6db0cb04/phoenix-core/src/it/java/org/apache/phoenix/end2end/ViewIT.java
--
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ViewIT.java 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ViewIT.java
index 4b64a09..e277c18 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ViewIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ViewIT.java
@@ -33,6 +33,7 @@ import java.sql.DriverManager;
 import java.sql.PreparedStatement;
 import java.sql.ResultSet;
 import java.sql.SQLException;
+import java.sql.Statement;
 import java.util.List;
 import java.util.Properties;
 
@@ -894,6 +895,51 @@ public class ViewIT extends BaseViewIT {
 }
 }
 
+@Test
+public void testQueryWithSeparateConnectionForViewOnTableThatHasIndex() 
throws SQLException {
+try (Connection conn = DriverManager.getConnection(getUrl());
+Connection conn2 = DriverManager.getConnection(getUrl());
+Statement s = conn.createStatement();
+Statement s2 = conn2.createStatement()) {
+String tableName = generateUniqueName();
+String viewName = generateUniqueName();
+String indexName = generateUniqueName();
+helpTestQueryForViewOnTableThatHasIndex(s, s2, tableName, 
viewName, indexName);
+}
+}
+
+@Test
+public void testQueryForViewOnTableThatHasIndex() throws SQLException {
+try (Connection conn = DriverManager.getConnection(getUrl());
+Statement s = conn.createStatement()) {
+String tableName = generateUniqueName();
+String viewName = generateUniqueName();
+String indexName = generateUniqueName();
+helpTestQueryForViewOnTableThatHasIndex(s, s, tableName, viewName, 
indexName);
+}
+}
+
+private void helpTestQueryForViewOnTableThatHasIndex(Statement s1, 
Statement s2, String tableName, String viewName, String indexName)
+throws SQLException {
+// Create a table
+s1.execute("create table " + tableName + " (col1 varchar primary key, 
col2 varchar)");
+
+// Create a view on the table
+s1.execute("create view " + viewName + " (col3 varchar) as select * 
from " + tableName);
+s1.executeQuery("select * from " + viewName);
+// Create a index on the table
+s1.execute("create index " + indexName + " ON " + tableName + " 
(col2)");
+
+try (ResultSet rs =
+s2.executeQuery("explain select /*+ INDEX(" + viewName + " " + 
indexName
++ ") */ * from " + viewName + " where col2 = 'aaa'")) {
+String explainPlan = QueryUtil.getExplainPlan(rs);
+
+// check if the query uses the index
+assertTrue(explainPlan.contains(indexName));
+}
+}
+
 private void validate(String viewName, Connection tenantConn, String[] 
whereClauseArray,
 long[] expectedArray) throws SQLException {
 for (int i = 0; i < whereClauseArray.length; ++i) {

http://git-wip-us.apache.org/repos/asf/phoenix/blob/6db0cb04/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java 
b/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java
index 2333acc..4997af9 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java
@@ -684,7 +684,7 @@ public class MetaDataClient {
 // In this case, we update the parent table which 
may in turn pull
 // in indexes to add to this table.

phoenix git commit: PHOENIX-4712 When creating an index on a table, meta data cache of views related to the table isn't updated

2018-05-01 Thread tdsilva
Repository: phoenix
Updated Branches:
  refs/heads/4.x-HBase-0.98 882c059eb -> 5b7b104ed


PHOENIX-4712 When creating an index on a table, meta data cache of views 
related to the table isn't updated


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

Branch: refs/heads/4.x-HBase-0.98
Commit: 5b7b104ed74ae7f4ef39cafc883e1da00e431503
Parents: 882c059
Author: Thomas D'Silva 
Authored: Tue May 1 13:32:45 2018 -0700
Committer: Thomas D'Silva 
Committed: Tue May 1 21:19:28 2018 -0700

--
 .../java/org/apache/phoenix/end2end/ViewIT.java | 46 
 .../apache/phoenix/schema/MetaDataClient.java   | 11 +++--
 2 files changed, 53 insertions(+), 4 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/5b7b104e/phoenix-core/src/it/java/org/apache/phoenix/end2end/ViewIT.java
--
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ViewIT.java 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ViewIT.java
index 5c0d100..279bbd7 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ViewIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ViewIT.java
@@ -33,6 +33,7 @@ import java.sql.DriverManager;
 import java.sql.PreparedStatement;
 import java.sql.ResultSet;
 import java.sql.SQLException;
+import java.sql.Statement;
 import java.util.List;
 import java.util.Properties;
 
@@ -894,6 +895,51 @@ public class ViewIT extends BaseViewIT {
 }
 }
 
+@Test
+public void testQueryWithSeparateConnectionForViewOnTableThatHasIndex() 
throws SQLException {
+try (Connection conn = DriverManager.getConnection(getUrl());
+Connection conn2 = DriverManager.getConnection(getUrl());
+Statement s = conn.createStatement();
+Statement s2 = conn2.createStatement()) {
+String tableName = generateUniqueName();
+String viewName = generateUniqueName();
+String indexName = generateUniqueName();
+helpTestQueryForViewOnTableThatHasIndex(s, s2, tableName, 
viewName, indexName);
+}
+}
+
+@Test
+public void testQueryForViewOnTableThatHasIndex() throws SQLException {
+try (Connection conn = DriverManager.getConnection(getUrl());
+Statement s = conn.createStatement()) {
+String tableName = generateUniqueName();
+String viewName = generateUniqueName();
+String indexName = generateUniqueName();
+helpTestQueryForViewOnTableThatHasIndex(s, s, tableName, viewName, 
indexName);
+}
+}
+
+private void helpTestQueryForViewOnTableThatHasIndex(Statement s1, 
Statement s2, String tableName, String viewName, String indexName)
+throws SQLException {
+// Create a table
+s1.execute("create table " + tableName + " (col1 varchar primary key, 
col2 varchar)");
+
+// Create a view on the table
+s1.execute("create view " + viewName + " (col3 varchar) as select * 
from " + tableName);
+s1.executeQuery("select * from " + viewName);
+// Create a index on the table
+s1.execute("create index " + indexName + " ON " + tableName + " 
(col2)");
+
+try (ResultSet rs =
+s2.executeQuery("explain select /*+ INDEX(" + viewName + " " + 
indexName
++ ") */ * from " + viewName + " where col2 = 'aaa'")) {
+String explainPlan = QueryUtil.getExplainPlan(rs);
+
+// check if the query uses the index
+assertTrue(explainPlan.contains(indexName));
+}
+}
+
 private void validate(String viewName, Connection tenantConn, String[] 
whereClauseArray,
 long[] expectedArray) throws SQLException {
 for (int i = 0; i < whereClauseArray.length; ++i) {

http://git-wip-us.apache.org/repos/asf/phoenix/blob/5b7b104e/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java 
b/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java
index 372371b..e69dac7 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java
@@ -677,7 +677,7 @@ public class MetaDataClient {
 // In this case, we update the parent table which 
may in turn pull
 // in indexes to add to this table.
  

phoenix git commit: PHOENIX-4712 When creating an index on a table, meta data cache of views related to the table isn't updated

2018-05-01 Thread tdsilva
Repository: phoenix
Updated Branches:
  refs/heads/4.x-HBase-1.2 cfac2daac -> e546e38f1


PHOENIX-4712 When creating an index on a table, meta data cache of views 
related to the table isn't updated


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

Branch: refs/heads/4.x-HBase-1.2
Commit: e546e38f13401a17ab287323cf72fba821a97683
Parents: cfac2da
Author: Thomas D'Silva 
Authored: Tue May 1 13:32:45 2018 -0700
Committer: Thomas D'Silva 
Committed: Tue May 1 21:19:47 2018 -0700

--
 .../java/org/apache/phoenix/end2end/ViewIT.java | 46 
 .../apache/phoenix/schema/MetaDataClient.java   | 11 +++--
 2 files changed, 53 insertions(+), 4 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/e546e38f/phoenix-core/src/it/java/org/apache/phoenix/end2end/ViewIT.java
--
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ViewIT.java 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ViewIT.java
index 5c0d100..279bbd7 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ViewIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ViewIT.java
@@ -33,6 +33,7 @@ import java.sql.DriverManager;
 import java.sql.PreparedStatement;
 import java.sql.ResultSet;
 import java.sql.SQLException;
+import java.sql.Statement;
 import java.util.List;
 import java.util.Properties;
 
@@ -894,6 +895,51 @@ public class ViewIT extends BaseViewIT {
 }
 }
 
+@Test
+public void testQueryWithSeparateConnectionForViewOnTableThatHasIndex() 
throws SQLException {
+try (Connection conn = DriverManager.getConnection(getUrl());
+Connection conn2 = DriverManager.getConnection(getUrl());
+Statement s = conn.createStatement();
+Statement s2 = conn2.createStatement()) {
+String tableName = generateUniqueName();
+String viewName = generateUniqueName();
+String indexName = generateUniqueName();
+helpTestQueryForViewOnTableThatHasIndex(s, s2, tableName, 
viewName, indexName);
+}
+}
+
+@Test
+public void testQueryForViewOnTableThatHasIndex() throws SQLException {
+try (Connection conn = DriverManager.getConnection(getUrl());
+Statement s = conn.createStatement()) {
+String tableName = generateUniqueName();
+String viewName = generateUniqueName();
+String indexName = generateUniqueName();
+helpTestQueryForViewOnTableThatHasIndex(s, s, tableName, viewName, 
indexName);
+}
+}
+
+private void helpTestQueryForViewOnTableThatHasIndex(Statement s1, 
Statement s2, String tableName, String viewName, String indexName)
+throws SQLException {
+// Create a table
+s1.execute("create table " + tableName + " (col1 varchar primary key, 
col2 varchar)");
+
+// Create a view on the table
+s1.execute("create view " + viewName + " (col3 varchar) as select * 
from " + tableName);
+s1.executeQuery("select * from " + viewName);
+// Create a index on the table
+s1.execute("create index " + indexName + " ON " + tableName + " 
(col2)");
+
+try (ResultSet rs =
+s2.executeQuery("explain select /*+ INDEX(" + viewName + " " + 
indexName
++ ") */ * from " + viewName + " where col2 = 'aaa'")) {
+String explainPlan = QueryUtil.getExplainPlan(rs);
+
+// check if the query uses the index
+assertTrue(explainPlan.contains(indexName));
+}
+}
+
 private void validate(String viewName, Connection tenantConn, String[] 
whereClauseArray,
 long[] expectedArray) throws SQLException {
 for (int i = 0; i < whereClauseArray.length; ++i) {

http://git-wip-us.apache.org/repos/asf/phoenix/blob/e546e38f/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java 
b/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java
index 69d8a56..009289b 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java
@@ -682,7 +682,7 @@ public class MetaDataClient {
 // In this case, we update the parent table which 
may in turn pull
 // in indexes to add to this table.

phoenix git commit: PHOENIX-4712 When creating an index on a table, meta data cache of views related to the table isn't updated

2018-05-01 Thread tdsilva
Repository: phoenix
Updated Branches:
  refs/heads/4.x-HBase-1.1 6e25a5f74 -> d5921d9fe


PHOENIX-4712 When creating an index on a table, meta data cache of views 
related to the table isn't updated


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

Branch: refs/heads/4.x-HBase-1.1
Commit: d5921d9fe90d60a24e9d7385e2d987ec80f8a8f7
Parents: 6e25a5f
Author: Thomas D'Silva 
Authored: Tue May 1 13:32:45 2018 -0700
Committer: Thomas D'Silva 
Committed: Tue May 1 21:19:37 2018 -0700

--
 .../java/org/apache/phoenix/end2end/ViewIT.java | 46 
 .../apache/phoenix/schema/MetaDataClient.java   | 11 +++--
 2 files changed, 53 insertions(+), 4 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/d5921d9f/phoenix-core/src/it/java/org/apache/phoenix/end2end/ViewIT.java
--
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ViewIT.java 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ViewIT.java
index 5c0d100..279bbd7 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ViewIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ViewIT.java
@@ -33,6 +33,7 @@ import java.sql.DriverManager;
 import java.sql.PreparedStatement;
 import java.sql.ResultSet;
 import java.sql.SQLException;
+import java.sql.Statement;
 import java.util.List;
 import java.util.Properties;
 
@@ -894,6 +895,51 @@ public class ViewIT extends BaseViewIT {
 }
 }
 
+@Test
+public void testQueryWithSeparateConnectionForViewOnTableThatHasIndex() 
throws SQLException {
+try (Connection conn = DriverManager.getConnection(getUrl());
+Connection conn2 = DriverManager.getConnection(getUrl());
+Statement s = conn.createStatement();
+Statement s2 = conn2.createStatement()) {
+String tableName = generateUniqueName();
+String viewName = generateUniqueName();
+String indexName = generateUniqueName();
+helpTestQueryForViewOnTableThatHasIndex(s, s2, tableName, 
viewName, indexName);
+}
+}
+
+@Test
+public void testQueryForViewOnTableThatHasIndex() throws SQLException {
+try (Connection conn = DriverManager.getConnection(getUrl());
+Statement s = conn.createStatement()) {
+String tableName = generateUniqueName();
+String viewName = generateUniqueName();
+String indexName = generateUniqueName();
+helpTestQueryForViewOnTableThatHasIndex(s, s, tableName, viewName, 
indexName);
+}
+}
+
+private void helpTestQueryForViewOnTableThatHasIndex(Statement s1, 
Statement s2, String tableName, String viewName, String indexName)
+throws SQLException {
+// Create a table
+s1.execute("create table " + tableName + " (col1 varchar primary key, 
col2 varchar)");
+
+// Create a view on the table
+s1.execute("create view " + viewName + " (col3 varchar) as select * 
from " + tableName);
+s1.executeQuery("select * from " + viewName);
+// Create a index on the table
+s1.execute("create index " + indexName + " ON " + tableName + " 
(col2)");
+
+try (ResultSet rs =
+s2.executeQuery("explain select /*+ INDEX(" + viewName + " " + 
indexName
++ ") */ * from " + viewName + " where col2 = 'aaa'")) {
+String explainPlan = QueryUtil.getExplainPlan(rs);
+
+// check if the query uses the index
+assertTrue(explainPlan.contains(indexName));
+}
+}
+
 private void validate(String viewName, Connection tenantConn, String[] 
whereClauseArray,
 long[] expectedArray) throws SQLException {
 for (int i = 0; i < whereClauseArray.length; ++i) {

http://git-wip-us.apache.org/repos/asf/phoenix/blob/d5921d9f/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java 
b/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java
index 7fecaad..c80b64a 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java
@@ -676,7 +676,7 @@ public class MetaDataClient {
 // In this case, we update the parent table which 
may in turn pull
 // in indexes to add to this table.

phoenix git commit: PHOENIX-4712 When creating an index on a table, meta data cache of views related to the table isn't updated

2018-05-01 Thread tdsilva
Repository: phoenix
Updated Branches:
  refs/heads/4.x-HBase-1.3 5c5153557 -> ab5200afe


PHOENIX-4712 When creating an index on a table, meta data cache of views 
related to the table isn't updated


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

Branch: refs/heads/4.x-HBase-1.3
Commit: ab5200afee0f99cbec2f69b7cec0c2643bb41fdd
Parents: 5c51535
Author: Thomas D'Silva 
Authored: Tue May 1 13:32:45 2018 -0700
Committer: Thomas D'Silva 
Committed: Tue May 1 21:19:06 2018 -0700

--
 .../java/org/apache/phoenix/end2end/ViewIT.java | 46 
 .../apache/phoenix/schema/MetaDataClient.java   | 11 +++--
 2 files changed, 53 insertions(+), 4 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/ab5200af/phoenix-core/src/it/java/org/apache/phoenix/end2end/ViewIT.java
--
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ViewIT.java 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ViewIT.java
index 5c0d100..279bbd7 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ViewIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ViewIT.java
@@ -33,6 +33,7 @@ import java.sql.DriverManager;
 import java.sql.PreparedStatement;
 import java.sql.ResultSet;
 import java.sql.SQLException;
+import java.sql.Statement;
 import java.util.List;
 import java.util.Properties;
 
@@ -894,6 +895,51 @@ public class ViewIT extends BaseViewIT {
 }
 }
 
+@Test
+public void testQueryWithSeparateConnectionForViewOnTableThatHasIndex() 
throws SQLException {
+try (Connection conn = DriverManager.getConnection(getUrl());
+Connection conn2 = DriverManager.getConnection(getUrl());
+Statement s = conn.createStatement();
+Statement s2 = conn2.createStatement()) {
+String tableName = generateUniqueName();
+String viewName = generateUniqueName();
+String indexName = generateUniqueName();
+helpTestQueryForViewOnTableThatHasIndex(s, s2, tableName, 
viewName, indexName);
+}
+}
+
+@Test
+public void testQueryForViewOnTableThatHasIndex() throws SQLException {
+try (Connection conn = DriverManager.getConnection(getUrl());
+Statement s = conn.createStatement()) {
+String tableName = generateUniqueName();
+String viewName = generateUniqueName();
+String indexName = generateUniqueName();
+helpTestQueryForViewOnTableThatHasIndex(s, s, tableName, viewName, 
indexName);
+}
+}
+
+private void helpTestQueryForViewOnTableThatHasIndex(Statement s1, 
Statement s2, String tableName, String viewName, String indexName)
+throws SQLException {
+// Create a table
+s1.execute("create table " + tableName + " (col1 varchar primary key, 
col2 varchar)");
+
+// Create a view on the table
+s1.execute("create view " + viewName + " (col3 varchar) as select * 
from " + tableName);
+s1.executeQuery("select * from " + viewName);
+// Create a index on the table
+s1.execute("create index " + indexName + " ON " + tableName + " 
(col2)");
+
+try (ResultSet rs =
+s2.executeQuery("explain select /*+ INDEX(" + viewName + " " + 
indexName
++ ") */ * from " + viewName + " where col2 = 'aaa'")) {
+String explainPlan = QueryUtil.getExplainPlan(rs);
+
+// check if the query uses the index
+assertTrue(explainPlan.contains(indexName));
+}
+}
+
 private void validate(String viewName, Connection tenantConn, String[] 
whereClauseArray,
 long[] expectedArray) throws SQLException {
 for (int i = 0; i < whereClauseArray.length; ++i) {

http://git-wip-us.apache.org/repos/asf/phoenix/blob/ab5200af/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java 
b/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java
index 69d8a56..009289b 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java
@@ -682,7 +682,7 @@ public class MetaDataClient {
 // In this case, we update the parent table which 
may in turn pull
 // in indexes to add to this table.