[4/7] phoenix git commit: PHOENIX-4546 Projected table cannot be read through ProjectedColumnExpression

2018-02-11 Thread pboado
PHOENIX-4546 Projected table cannot be read through ProjectedColumnExpression


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

Branch: refs/heads/4.x-cdh5.11.2
Commit: 3ef7b1f021cd931b848d54ff494525b7756fd466
Parents: 2121729
Author: Ankit Singhal 
Authored: Thu Feb 8 07:05:21 2018 +
Committer: Pedro Boado 
Committed: Sun Feb 11 15:55:46 2018 +

--
 .../org/apache/phoenix/end2end/DeleteIT.java| 36 
 .../compile/TupleProjectionCompiler.java| 32 -
 2 files changed, 60 insertions(+), 8 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/3ef7b1f0/phoenix-core/src/it/java/org/apache/phoenix/end2end/DeleteIT.java
--
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/DeleteIT.java 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/DeleteIT.java
index e111e7a..498aeff 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/DeleteIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/DeleteIT.java
@@ -710,6 +710,41 @@ public class DeleteIT extends ParallelStatsDisabledIT {
 public void testClientSideDeleteAutoCommitOn() throws Exception {
 testDeleteCount(true, 1000);
 }
+
+@Test
+public void testPointDeleteWithMultipleImmutableIndexes() throws Exception 
{
+testPointDeleteWithMultipleImmutableIndexes(false);
+}
+
+@Test
+public void testPointDeleteWithMultipleImmutableIndexesAfterAlter() throws 
Exception {
+testPointDeleteWithMultipleImmutableIndexes(true);
+}
+
+private void testPointDeleteWithMultipleImmutableIndexes(boolean 
alterTable) throws Exception {
+String tableName = generateUniqueName();
+String commands = "CREATE TABLE IF NOT EXISTS " + tableName
++ " (ID INTEGER PRIMARY KEY,double_id DOUBLE,varchar_id 
VARCHAR (30)) "
++ (alterTable ? ";ALTER TABLE " + tableName + " set " : "") + 
"IMMUTABLE_ROWS=true;"
++ "CREATE INDEX IF NOT EXISTS index_column_varchar_id ON " + 
tableName + "(varchar_id);"
++ "CREATE INDEX IF NOT EXISTS index_column_double_id ON " + 
tableName + "(double_id);" + "UPSERT INTO "
++ tableName + " VALUES (900,0.5,'Sample text extra');" ;
+try (Connection conn = DriverManager.getConnection(getUrl())) {
+conn.setAutoCommit(true);
+Statement stm = conn.createStatement();
+for (String sql : commands.split(";")) {
+stm.execute(sql);
+}
+ResultSet rs = stm.executeQuery("select id,varchar_id,double_id 
from " + tableName + " WHERE ID=900");
+assertTrue(rs.next());
+assertEquals(900, rs.getInt(1));
+assertEquals("Sample text extra", rs.getString(2));
+assertEquals(0.5, rs.getDouble(3),0.01);
+stm.execute("DELETE FROM " + tableName + " WHERE ID=900");
+assertDeleted(conn, tableName, "index_column_varchar_id", 
"index_column_double_id", null);
+stm.close();
+}
+}
 
 private void testDeleteCount(boolean autoCommit, Integer limit) throws 
Exception {
 String tableName = generateUniqueName();
@@ -735,6 +770,7 @@ public class DeleteIT extends ParallelStatsDisabledIT {
 }
 
 }
+
 
 @Test
 public void 
testClientSideDeleteShouldNotFailWhenSameColumnPresentInMultipleIndexes()

http://git-wip-us.apache.org/repos/asf/phoenix/blob/3ef7b1f0/phoenix-core/src/main/java/org/apache/phoenix/compile/TupleProjectionCompiler.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/compile/TupleProjectionCompiler.java
 
b/phoenix-core/src/main/java/org/apache/phoenix/compile/TupleProjectionCompiler.java
index 9883de6..d0b900c 100644
--- 
a/phoenix-core/src/main/java/org/apache/phoenix/compile/TupleProjectionCompiler.java
+++ 
b/phoenix-core/src/main/java/org/apache/phoenix/compile/TupleProjectionCompiler.java
@@ -22,6 +22,7 @@ import java.sql.SQLException;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashSet;
+import java.util.LinkedHashSet;
 import java.util.List;
 import java.util.Set;
 
@@ -103,6 +104,10 @@ public class TupleProjectionCompiler {
 for (PColumn column : 
parentTableRef.getTable().getColumnFamily(familyName).getColumns()) {
 NODE_FACTORY.column(null, '"' + 

phoenix git commit: PHOENIX-4546 Projected table cannot be read through ProjectedColumnExpression

2018-02-07 Thread ankit
Repository: phoenix
Updated Branches:
  refs/heads/4.x-HBase-1.3 8ba8d7b6a -> 507f2b8ee


PHOENIX-4546 Projected table cannot be read through ProjectedColumnExpression


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

Branch: refs/heads/4.x-HBase-1.3
Commit: 507f2b8eee29cc5247e18103f64508034580f38c
Parents: 8ba8d7b
Author: Ankit Singhal 
Authored: Thu Feb 8 12:46:09 2018 +0530
Committer: Ankit Singhal 
Committed: Thu Feb 8 12:46:09 2018 +0530

--
 .../org/apache/phoenix/end2end/DeleteIT.java| 36 
 .../compile/TupleProjectionCompiler.java| 32 -
 2 files changed, 60 insertions(+), 8 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/507f2b8e/phoenix-core/src/it/java/org/apache/phoenix/end2end/DeleteIT.java
--
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/DeleteIT.java 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/DeleteIT.java
index e111e7a..498aeff 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/DeleteIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/DeleteIT.java
@@ -710,6 +710,41 @@ public class DeleteIT extends ParallelStatsDisabledIT {
 public void testClientSideDeleteAutoCommitOn() throws Exception {
 testDeleteCount(true, 1000);
 }
+
+@Test
+public void testPointDeleteWithMultipleImmutableIndexes() throws Exception 
{
+testPointDeleteWithMultipleImmutableIndexes(false);
+}
+
+@Test
+public void testPointDeleteWithMultipleImmutableIndexesAfterAlter() throws 
Exception {
+testPointDeleteWithMultipleImmutableIndexes(true);
+}
+
+private void testPointDeleteWithMultipleImmutableIndexes(boolean 
alterTable) throws Exception {
+String tableName = generateUniqueName();
+String commands = "CREATE TABLE IF NOT EXISTS " + tableName
++ " (ID INTEGER PRIMARY KEY,double_id DOUBLE,varchar_id 
VARCHAR (30)) "
++ (alterTable ? ";ALTER TABLE " + tableName + " set " : "") + 
"IMMUTABLE_ROWS=true;"
++ "CREATE INDEX IF NOT EXISTS index_column_varchar_id ON " + 
tableName + "(varchar_id);"
++ "CREATE INDEX IF NOT EXISTS index_column_double_id ON " + 
tableName + "(double_id);" + "UPSERT INTO "
++ tableName + " VALUES (900,0.5,'Sample text extra');" ;
+try (Connection conn = DriverManager.getConnection(getUrl())) {
+conn.setAutoCommit(true);
+Statement stm = conn.createStatement();
+for (String sql : commands.split(";")) {
+stm.execute(sql);
+}
+ResultSet rs = stm.executeQuery("select id,varchar_id,double_id 
from " + tableName + " WHERE ID=900");
+assertTrue(rs.next());
+assertEquals(900, rs.getInt(1));
+assertEquals("Sample text extra", rs.getString(2));
+assertEquals(0.5, rs.getDouble(3),0.01);
+stm.execute("DELETE FROM " + tableName + " WHERE ID=900");
+assertDeleted(conn, tableName, "index_column_varchar_id", 
"index_column_double_id", null);
+stm.close();
+}
+}
 
 private void testDeleteCount(boolean autoCommit, Integer limit) throws 
Exception {
 String tableName = generateUniqueName();
@@ -735,6 +770,7 @@ public class DeleteIT extends ParallelStatsDisabledIT {
 }
 
 }
+
 
 @Test
 public void 
testClientSideDeleteShouldNotFailWhenSameColumnPresentInMultipleIndexes()

http://git-wip-us.apache.org/repos/asf/phoenix/blob/507f2b8e/phoenix-core/src/main/java/org/apache/phoenix/compile/TupleProjectionCompiler.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/compile/TupleProjectionCompiler.java
 
b/phoenix-core/src/main/java/org/apache/phoenix/compile/TupleProjectionCompiler.java
index 9883de6..d0b900c 100644
--- 
a/phoenix-core/src/main/java/org/apache/phoenix/compile/TupleProjectionCompiler.java
+++ 
b/phoenix-core/src/main/java/org/apache/phoenix/compile/TupleProjectionCompiler.java
@@ -22,6 +22,7 @@ import java.sql.SQLException;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashSet;
+import java.util.LinkedHashSet;
 import java.util.List;
 import java.util.Set;
 
@@ -103,6 +104,10 @@ public class TupleProjectionCompiler {
 for (PColumn column : 

phoenix git commit: PHOENIX-4546 Projected table cannot be read through ProjectedColumnExpression

2018-02-07 Thread ankit
Repository: phoenix
Updated Branches:
  refs/heads/4.x-HBase-0.98 907e90932 -> 76573d67b


PHOENIX-4546 Projected table cannot be read through ProjectedColumnExpression


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

Branch: refs/heads/4.x-HBase-0.98
Commit: 76573d67be22114986dd2943b70b821e32c2d26b
Parents: 907e909
Author: Ankit Singhal 
Authored: Thu Feb 8 12:41:56 2018 +0530
Committer: Ankit Singhal 
Committed: Thu Feb 8 12:41:56 2018 +0530

--
 .../org/apache/phoenix/end2end/DeleteIT.java| 36 
 .../compile/TupleProjectionCompiler.java| 32 -
 2 files changed, 60 insertions(+), 8 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/76573d67/phoenix-core/src/it/java/org/apache/phoenix/end2end/DeleteIT.java
--
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/DeleteIT.java 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/DeleteIT.java
index e111e7a..498aeff 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/DeleteIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/DeleteIT.java
@@ -710,6 +710,41 @@ public class DeleteIT extends ParallelStatsDisabledIT {
 public void testClientSideDeleteAutoCommitOn() throws Exception {
 testDeleteCount(true, 1000);
 }
+
+@Test
+public void testPointDeleteWithMultipleImmutableIndexes() throws Exception 
{
+testPointDeleteWithMultipleImmutableIndexes(false);
+}
+
+@Test
+public void testPointDeleteWithMultipleImmutableIndexesAfterAlter() throws 
Exception {
+testPointDeleteWithMultipleImmutableIndexes(true);
+}
+
+private void testPointDeleteWithMultipleImmutableIndexes(boolean 
alterTable) throws Exception {
+String tableName = generateUniqueName();
+String commands = "CREATE TABLE IF NOT EXISTS " + tableName
++ " (ID INTEGER PRIMARY KEY,double_id DOUBLE,varchar_id 
VARCHAR (30)) "
++ (alterTable ? ";ALTER TABLE " + tableName + " set " : "") + 
"IMMUTABLE_ROWS=true;"
++ "CREATE INDEX IF NOT EXISTS index_column_varchar_id ON " + 
tableName + "(varchar_id);"
++ "CREATE INDEX IF NOT EXISTS index_column_double_id ON " + 
tableName + "(double_id);" + "UPSERT INTO "
++ tableName + " VALUES (900,0.5,'Sample text extra');" ;
+try (Connection conn = DriverManager.getConnection(getUrl())) {
+conn.setAutoCommit(true);
+Statement stm = conn.createStatement();
+for (String sql : commands.split(";")) {
+stm.execute(sql);
+}
+ResultSet rs = stm.executeQuery("select id,varchar_id,double_id 
from " + tableName + " WHERE ID=900");
+assertTrue(rs.next());
+assertEquals(900, rs.getInt(1));
+assertEquals("Sample text extra", rs.getString(2));
+assertEquals(0.5, rs.getDouble(3),0.01);
+stm.execute("DELETE FROM " + tableName + " WHERE ID=900");
+assertDeleted(conn, tableName, "index_column_varchar_id", 
"index_column_double_id", null);
+stm.close();
+}
+}
 
 private void testDeleteCount(boolean autoCommit, Integer limit) throws 
Exception {
 String tableName = generateUniqueName();
@@ -735,6 +770,7 @@ public class DeleteIT extends ParallelStatsDisabledIT {
 }
 
 }
+
 
 @Test
 public void 
testClientSideDeleteShouldNotFailWhenSameColumnPresentInMultipleIndexes()

http://git-wip-us.apache.org/repos/asf/phoenix/blob/76573d67/phoenix-core/src/main/java/org/apache/phoenix/compile/TupleProjectionCompiler.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/compile/TupleProjectionCompiler.java
 
b/phoenix-core/src/main/java/org/apache/phoenix/compile/TupleProjectionCompiler.java
index 9883de6..d0b900c 100644
--- 
a/phoenix-core/src/main/java/org/apache/phoenix/compile/TupleProjectionCompiler.java
+++ 
b/phoenix-core/src/main/java/org/apache/phoenix/compile/TupleProjectionCompiler.java
@@ -22,6 +22,7 @@ import java.sql.SQLException;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashSet;
+import java.util.LinkedHashSet;
 import java.util.List;
 import java.util.Set;
 
@@ -103,6 +104,10 @@ public class TupleProjectionCompiler {
 for (PColumn column : 

phoenix git commit: PHOENIX-4546 Projected table cannot be read through ProjectedColumnExpression

2018-02-07 Thread ankit
Repository: phoenix
Updated Branches:
  refs/heads/4.x-HBase-1.1 08d48b130 -> 330972e71


PHOENIX-4546 Projected table cannot be read through ProjectedColumnExpression


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

Branch: refs/heads/4.x-HBase-1.1
Commit: 330972e71fb400d679f1a14646e76d91262c613e
Parents: 08d48b1
Author: Ankit Singhal 
Authored: Thu Feb 8 12:39:36 2018 +0530
Committer: Ankit Singhal 
Committed: Thu Feb 8 12:39:36 2018 +0530

--
 .../org/apache/phoenix/end2end/DeleteIT.java| 35 
 .../compile/TupleProjectionCompiler.java| 32 +-
 2 files changed, 59 insertions(+), 8 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/330972e7/phoenix-core/src/it/java/org/apache/phoenix/end2end/DeleteIT.java
--
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/DeleteIT.java 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/DeleteIT.java
index 9eac0af..6e4cb2a 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/DeleteIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/DeleteIT.java
@@ -709,6 +709,41 @@ public class DeleteIT extends ParallelStatsDisabledIT {
 public void testClientSideDeleteAutoCommitOn() throws Exception {
 testDeleteCount(true, 1000);
 }
+
+@Test
+public void testPointDeleteWithMultipleImmutableIndexes() throws Exception 
{
+testPointDeleteWithMultipleImmutableIndexes(false);
+}
+
+@Test
+public void testPointDeleteWithMultipleImmutableIndexesAfterAlter() throws 
Exception {
+testPointDeleteWithMultipleImmutableIndexes(true);
+}
+
+private void testPointDeleteWithMultipleImmutableIndexes(boolean 
alterTable) throws Exception {
+String tableName = generateUniqueName();
+String commands = "CREATE TABLE IF NOT EXISTS " + tableName
++ " (ID INTEGER PRIMARY KEY,double_id DOUBLE,varchar_id 
VARCHAR (30)) "
++ (alterTable ? ";ALTER TABLE " + tableName + " set " : "") + 
"IMMUTABLE_ROWS=true;"
++ "CREATE INDEX IF NOT EXISTS index_column_varchar_id ON " + 
tableName + "(varchar_id);"
++ "CREATE INDEX IF NOT EXISTS index_column_double_id ON " + 
tableName + "(double_id);" + "UPSERT INTO "
++ tableName + " VALUES (900,0.5,'Sample text extra');" ;
+try (Connection conn = DriverManager.getConnection(getUrl())) {
+conn.setAutoCommit(true);
+Statement stm = conn.createStatement();
+for (String sql : commands.split(";")) {
+stm.execute(sql);
+}
+ResultSet rs = stm.executeQuery("select id,varchar_id,double_id 
from " + tableName + " WHERE ID=900");
+assertTrue(rs.next());
+assertEquals(900, rs.getInt(1));
+assertEquals("Sample text extra", rs.getString(2));
+assertEquals(0.5, rs.getDouble(3),0.01);
+stm.execute("DELETE FROM " + tableName + " WHERE ID=900");
+assertDeleted(conn, tableName, "index_column_varchar_id", 
"index_column_double_id", null);
+stm.close();
+}
+}
 
 private void testDeleteCount(boolean autoCommit, Integer limit) throws 
Exception {
 String tableName = generateUniqueName();

http://git-wip-us.apache.org/repos/asf/phoenix/blob/330972e7/phoenix-core/src/main/java/org/apache/phoenix/compile/TupleProjectionCompiler.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/compile/TupleProjectionCompiler.java
 
b/phoenix-core/src/main/java/org/apache/phoenix/compile/TupleProjectionCompiler.java
index 9883de6..d0b900c 100644
--- 
a/phoenix-core/src/main/java/org/apache/phoenix/compile/TupleProjectionCompiler.java
+++ 
b/phoenix-core/src/main/java/org/apache/phoenix/compile/TupleProjectionCompiler.java
@@ -22,6 +22,7 @@ import java.sql.SQLException;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashSet;
+import java.util.LinkedHashSet;
 import java.util.List;
 import java.util.Set;
 
@@ -103,6 +104,10 @@ public class TupleProjectionCompiler {
 for (PColumn column : 
parentTableRef.getTable().getColumnFamily(familyName).getColumns()) {
 NODE_FACTORY.column(null, '"' + 
IndexUtil.getIndexColumnName(column) + '"', null).accept(visitor);
 }
+}else{
+for 

phoenix git commit: PHOENIX-4546 Projected table cannot be read through ProjectedColumnExpression

2018-02-07 Thread ankit
Repository: phoenix
Updated Branches:
  refs/heads/master 073392e35 -> d5a74df8c


PHOENIX-4546 Projected table cannot be read through ProjectedColumnExpression


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

Branch: refs/heads/master
Commit: d5a74df8cc0b68af31eaccafee57e23b042f2b04
Parents: 073392e
Author: Ankit Singhal 
Authored: Thu Feb 8 12:37:46 2018 +0530
Committer: Ankit Singhal 
Committed: Thu Feb 8 12:37:46 2018 +0530

--
 .../org/apache/phoenix/end2end/DeleteIT.java| 36 
 .../compile/TupleProjectionCompiler.java| 32 -
 2 files changed, 60 insertions(+), 8 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/d5a74df8/phoenix-core/src/it/java/org/apache/phoenix/end2end/DeleteIT.java
--
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/DeleteIT.java 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/DeleteIT.java
index e111e7a..498aeff 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/DeleteIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/DeleteIT.java
@@ -710,6 +710,41 @@ public class DeleteIT extends ParallelStatsDisabledIT {
 public void testClientSideDeleteAutoCommitOn() throws Exception {
 testDeleteCount(true, 1000);
 }
+
+@Test
+public void testPointDeleteWithMultipleImmutableIndexes() throws Exception 
{
+testPointDeleteWithMultipleImmutableIndexes(false);
+}
+
+@Test
+public void testPointDeleteWithMultipleImmutableIndexesAfterAlter() throws 
Exception {
+testPointDeleteWithMultipleImmutableIndexes(true);
+}
+
+private void testPointDeleteWithMultipleImmutableIndexes(boolean 
alterTable) throws Exception {
+String tableName = generateUniqueName();
+String commands = "CREATE TABLE IF NOT EXISTS " + tableName
++ " (ID INTEGER PRIMARY KEY,double_id DOUBLE,varchar_id 
VARCHAR (30)) "
++ (alterTable ? ";ALTER TABLE " + tableName + " set " : "") + 
"IMMUTABLE_ROWS=true;"
++ "CREATE INDEX IF NOT EXISTS index_column_varchar_id ON " + 
tableName + "(varchar_id);"
++ "CREATE INDEX IF NOT EXISTS index_column_double_id ON " + 
tableName + "(double_id);" + "UPSERT INTO "
++ tableName + " VALUES (900,0.5,'Sample text extra');" ;
+try (Connection conn = DriverManager.getConnection(getUrl())) {
+conn.setAutoCommit(true);
+Statement stm = conn.createStatement();
+for (String sql : commands.split(";")) {
+stm.execute(sql);
+}
+ResultSet rs = stm.executeQuery("select id,varchar_id,double_id 
from " + tableName + " WHERE ID=900");
+assertTrue(rs.next());
+assertEquals(900, rs.getInt(1));
+assertEquals("Sample text extra", rs.getString(2));
+assertEquals(0.5, rs.getDouble(3),0.01);
+stm.execute("DELETE FROM " + tableName + " WHERE ID=900");
+assertDeleted(conn, tableName, "index_column_varchar_id", 
"index_column_double_id", null);
+stm.close();
+}
+}
 
 private void testDeleteCount(boolean autoCommit, Integer limit) throws 
Exception {
 String tableName = generateUniqueName();
@@ -735,6 +770,7 @@ public class DeleteIT extends ParallelStatsDisabledIT {
 }
 
 }
+
 
 @Test
 public void 
testClientSideDeleteShouldNotFailWhenSameColumnPresentInMultipleIndexes()

http://git-wip-us.apache.org/repos/asf/phoenix/blob/d5a74df8/phoenix-core/src/main/java/org/apache/phoenix/compile/TupleProjectionCompiler.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/compile/TupleProjectionCompiler.java
 
b/phoenix-core/src/main/java/org/apache/phoenix/compile/TupleProjectionCompiler.java
index 9883de6..d0b900c 100644
--- 
a/phoenix-core/src/main/java/org/apache/phoenix/compile/TupleProjectionCompiler.java
+++ 
b/phoenix-core/src/main/java/org/apache/phoenix/compile/TupleProjectionCompiler.java
@@ -22,6 +22,7 @@ import java.sql.SQLException;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashSet;
+import java.util.LinkedHashSet;
 import java.util.List;
 import java.util.Set;
 
@@ -103,6 +104,10 @@ public class TupleProjectionCompiler {
 for (PColumn column : 
parentTableRef.getTable().getColumnFamily(familyName).getColumns()) {
  

phoenix git commit: PHOENIX-4546 Projected table cannot be read through ProjectedColumnExpression

2018-02-07 Thread ankit
Repository: phoenix
Updated Branches:
  refs/heads/4.x-HBase-1.2 524a82870 -> 2eb97b2ba


PHOENIX-4546 Projected table cannot be read through ProjectedColumnExpression


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

Branch: refs/heads/4.x-HBase-1.2
Commit: 2eb97b2ba51b5369454e715311b2b2935402fdf7
Parents: 524a828
Author: Ankit Singhal 
Authored: Thu Feb 8 12:35:21 2018 +0530
Committer: Ankit Singhal 
Committed: Thu Feb 8 12:35:21 2018 +0530

--
 .../org/apache/phoenix/end2end/DeleteIT.java| 36 
 .../compile/TupleProjectionCompiler.java| 32 -
 2 files changed, 60 insertions(+), 8 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/2eb97b2b/phoenix-core/src/it/java/org/apache/phoenix/end2end/DeleteIT.java
--
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/DeleteIT.java 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/DeleteIT.java
index e111e7a..498aeff 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/DeleteIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/DeleteIT.java
@@ -710,6 +710,41 @@ public class DeleteIT extends ParallelStatsDisabledIT {
 public void testClientSideDeleteAutoCommitOn() throws Exception {
 testDeleteCount(true, 1000);
 }
+
+@Test
+public void testPointDeleteWithMultipleImmutableIndexes() throws Exception 
{
+testPointDeleteWithMultipleImmutableIndexes(false);
+}
+
+@Test
+public void testPointDeleteWithMultipleImmutableIndexesAfterAlter() throws 
Exception {
+testPointDeleteWithMultipleImmutableIndexes(true);
+}
+
+private void testPointDeleteWithMultipleImmutableIndexes(boolean 
alterTable) throws Exception {
+String tableName = generateUniqueName();
+String commands = "CREATE TABLE IF NOT EXISTS " + tableName
++ " (ID INTEGER PRIMARY KEY,double_id DOUBLE,varchar_id 
VARCHAR (30)) "
++ (alterTable ? ";ALTER TABLE " + tableName + " set " : "") + 
"IMMUTABLE_ROWS=true;"
++ "CREATE INDEX IF NOT EXISTS index_column_varchar_id ON " + 
tableName + "(varchar_id);"
++ "CREATE INDEX IF NOT EXISTS index_column_double_id ON " + 
tableName + "(double_id);" + "UPSERT INTO "
++ tableName + " VALUES (900,0.5,'Sample text extra');" ;
+try (Connection conn = DriverManager.getConnection(getUrl())) {
+conn.setAutoCommit(true);
+Statement stm = conn.createStatement();
+for (String sql : commands.split(";")) {
+stm.execute(sql);
+}
+ResultSet rs = stm.executeQuery("select id,varchar_id,double_id 
from " + tableName + " WHERE ID=900");
+assertTrue(rs.next());
+assertEquals(900, rs.getInt(1));
+assertEquals("Sample text extra", rs.getString(2));
+assertEquals(0.5, rs.getDouble(3),0.01);
+stm.execute("DELETE FROM " + tableName + " WHERE ID=900");
+assertDeleted(conn, tableName, "index_column_varchar_id", 
"index_column_double_id", null);
+stm.close();
+}
+}
 
 private void testDeleteCount(boolean autoCommit, Integer limit) throws 
Exception {
 String tableName = generateUniqueName();
@@ -735,6 +770,7 @@ public class DeleteIT extends ParallelStatsDisabledIT {
 }
 
 }
+
 
 @Test
 public void 
testClientSideDeleteShouldNotFailWhenSameColumnPresentInMultipleIndexes()

http://git-wip-us.apache.org/repos/asf/phoenix/blob/2eb97b2b/phoenix-core/src/main/java/org/apache/phoenix/compile/TupleProjectionCompiler.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/compile/TupleProjectionCompiler.java
 
b/phoenix-core/src/main/java/org/apache/phoenix/compile/TupleProjectionCompiler.java
index 9883de6..d0b900c 100644
--- 
a/phoenix-core/src/main/java/org/apache/phoenix/compile/TupleProjectionCompiler.java
+++ 
b/phoenix-core/src/main/java/org/apache/phoenix/compile/TupleProjectionCompiler.java
@@ -22,6 +22,7 @@ import java.sql.SQLException;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashSet;
+import java.util.LinkedHashSet;
 import java.util.List;
 import java.util.Set;
 
@@ -103,6 +104,10 @@ public class TupleProjectionCompiler {
 for (PColumn column : 

phoenix git commit: PHOENIX-4546 Projected table cannot be read through ProjectedColumnExpression

2018-02-07 Thread ankit
Repository: phoenix
Updated Branches:
  refs/heads/5.x-HBase-2.0 bfa6e71e5 -> d1ad1f585


PHOENIX-4546 Projected table cannot be read through ProjectedColumnExpression


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

Branch: refs/heads/5.x-HBase-2.0
Commit: d1ad1f585d5a12dedee94288c7abd419bf7365d5
Parents: bfa6e71
Author: Ankit Singhal 
Authored: Thu Feb 8 12:32:09 2018 +0530
Committer: Ankit Singhal 
Committed: Thu Feb 8 12:32:09 2018 +0530

--
 .../org/apache/phoenix/end2end/DeleteIT.java| 36 
 .../compile/TupleProjectionCompiler.java| 32 -
 2 files changed, 60 insertions(+), 8 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/d1ad1f58/phoenix-core/src/it/java/org/apache/phoenix/end2end/DeleteIT.java
--
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/DeleteIT.java 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/DeleteIT.java
index e111e7a..498aeff 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/DeleteIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/DeleteIT.java
@@ -710,6 +710,41 @@ public class DeleteIT extends ParallelStatsDisabledIT {
 public void testClientSideDeleteAutoCommitOn() throws Exception {
 testDeleteCount(true, 1000);
 }
+
+@Test
+public void testPointDeleteWithMultipleImmutableIndexes() throws Exception 
{
+testPointDeleteWithMultipleImmutableIndexes(false);
+}
+
+@Test
+public void testPointDeleteWithMultipleImmutableIndexesAfterAlter() throws 
Exception {
+testPointDeleteWithMultipleImmutableIndexes(true);
+}
+
+private void testPointDeleteWithMultipleImmutableIndexes(boolean 
alterTable) throws Exception {
+String tableName = generateUniqueName();
+String commands = "CREATE TABLE IF NOT EXISTS " + tableName
++ " (ID INTEGER PRIMARY KEY,double_id DOUBLE,varchar_id 
VARCHAR (30)) "
++ (alterTable ? ";ALTER TABLE " + tableName + " set " : "") + 
"IMMUTABLE_ROWS=true;"
++ "CREATE INDEX IF NOT EXISTS index_column_varchar_id ON " + 
tableName + "(varchar_id);"
++ "CREATE INDEX IF NOT EXISTS index_column_double_id ON " + 
tableName + "(double_id);" + "UPSERT INTO "
++ tableName + " VALUES (900,0.5,'Sample text extra');" ;
+try (Connection conn = DriverManager.getConnection(getUrl())) {
+conn.setAutoCommit(true);
+Statement stm = conn.createStatement();
+for (String sql : commands.split(";")) {
+stm.execute(sql);
+}
+ResultSet rs = stm.executeQuery("select id,varchar_id,double_id 
from " + tableName + " WHERE ID=900");
+assertTrue(rs.next());
+assertEquals(900, rs.getInt(1));
+assertEquals("Sample text extra", rs.getString(2));
+assertEquals(0.5, rs.getDouble(3),0.01);
+stm.execute("DELETE FROM " + tableName + " WHERE ID=900");
+assertDeleted(conn, tableName, "index_column_varchar_id", 
"index_column_double_id", null);
+stm.close();
+}
+}
 
 private void testDeleteCount(boolean autoCommit, Integer limit) throws 
Exception {
 String tableName = generateUniqueName();
@@ -735,6 +770,7 @@ public class DeleteIT extends ParallelStatsDisabledIT {
 }
 
 }
+
 
 @Test
 public void 
testClientSideDeleteShouldNotFailWhenSameColumnPresentInMultipleIndexes()

http://git-wip-us.apache.org/repos/asf/phoenix/blob/d1ad1f58/phoenix-core/src/main/java/org/apache/phoenix/compile/TupleProjectionCompiler.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/compile/TupleProjectionCompiler.java
 
b/phoenix-core/src/main/java/org/apache/phoenix/compile/TupleProjectionCompiler.java
index 9883de6..d0b900c 100644
--- 
a/phoenix-core/src/main/java/org/apache/phoenix/compile/TupleProjectionCompiler.java
+++ 
b/phoenix-core/src/main/java/org/apache/phoenix/compile/TupleProjectionCompiler.java
@@ -22,6 +22,7 @@ import java.sql.SQLException;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashSet;
+import java.util.LinkedHashSet;
 import java.util.List;
 import java.util.Set;
 
@@ -103,6 +104,10 @@ public class TupleProjectionCompiler {
 for (PColumn column :