phoenix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From els...@apache.org
Subject [43/50] [abbrv] phoenix git commit: PHOENIX-3534 Support multi region SYSTEM.CATALOG table (Thomas D'Silva and Rahul Gidwani)
Date Wed, 25 Jul 2018 22:35:06 GMT
http://git-wip-us.apache.org/repos/asf/phoenix/blob/d56fd3c9/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/MutableIndexIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/MutableIndexIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/MutableIndexIT.java
index 12e0dbf..45536e2 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/MutableIndexIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/MutableIndexIT.java
@@ -34,8 +34,6 @@ import java.util.Collection;
 import java.util.List;
 import java.util.Properties;
 
-import jline.internal.Log;
-
 import org.apache.hadoop.hbase.TableName;
 import org.apache.hadoop.hbase.client.Admin;
 import org.apache.hadoop.hbase.client.Put;
@@ -72,25 +70,27 @@ import org.junit.runners.Parameterized.Parameters;
 
 import com.google.common.primitives.Doubles;
 
+import jline.internal.Log;
+
 @RunWith(Parameterized.class)
 public class MutableIndexIT extends ParallelStatsDisabledIT {
     
     protected final boolean localIndex;
     private final String tableDDLOptions;
-	
+    
     public MutableIndexIT(Boolean localIndex, String txProvider, Boolean columnEncoded) {
-		this.localIndex = localIndex;
-		StringBuilder optionBuilder = new StringBuilder();
-		if (txProvider != null) {
-			optionBuilder.append("TRANSACTIONAL=true," + PhoenixDatabaseMetaData.TRANSACTION_PROVIDER + "='" + txProvider + "'");
-		}
-		if (!columnEncoded) {
+        this.localIndex = localIndex;
+        StringBuilder optionBuilder = new StringBuilder();
+        if (txProvider != null) {
+            optionBuilder.append("TRANSACTIONAL=true," + PhoenixDatabaseMetaData.TRANSACTION_PROVIDER + "='" + txProvider + "'");
+        }
+        if (!columnEncoded) {
             if (optionBuilder.length()!=0)
                 optionBuilder.append(",");
             optionBuilder.append("COLUMN_ENCODED_BYTES=0");
         }
-		this.tableDDLOptions = optionBuilder.toString();
-	}
+        this.tableDDLOptions = optionBuilder.toString();
+    }
     
     private static Connection getConnection(Properties props) throws SQLException {
         props.setProperty(QueryServices.INDEX_MUTATE_BATCH_SIZE_THRESHOLD_ATTRIB, Integer.toString(1));
@@ -103,7 +103,7 @@ public class MutableIndexIT extends ParallelStatsDisabledIT {
         return getConnection(props);
     }
     
-	@Parameters(name="MutableIndexIT_localIndex={0},transactional={1},columnEncoded={2}") // name is used by failsafe as file name in reports
+    @Parameters(name="MutableIndexIT_localIndex={0},transactional={1},columnEncoded={2}") // name is used by failsafe as file name in reports
     public static Collection<Object[]> data() {
         return Arrays.asList(new Object[][] { 
                 { false, null, false }, { false, null, true },
@@ -118,16 +118,16 @@ public class MutableIndexIT extends ParallelStatsDisabledIT {
     @Test
     public void testCoveredColumnUpdates() throws Exception {
         try (Connection conn = getConnection()) {
-	        conn.setAutoCommit(false);
-			String tableName = "TBL_" + generateUniqueName();
-			String indexName = "IDX_" + generateUniqueName();
-			String fullTableName = SchemaUtil.getTableName(TestUtil.DEFAULT_SCHEMA_NAME, tableName);
-			String fullIndexName = SchemaUtil.getTableName(TestUtil.DEFAULT_SCHEMA_NAME, indexName);
+            conn.setAutoCommit(false);
+            String tableName = "TBL_" + generateUniqueName();
+            String indexName = "IDX_" + generateUniqueName();
+            String fullTableName = SchemaUtil.getTableName(TestUtil.DEFAULT_SCHEMA_NAME, tableName);
+            String fullIndexName = SchemaUtil.getTableName(TestUtil.DEFAULT_SCHEMA_NAME, indexName);
 
-			TestUtil.createMultiCFTestTable(conn, fullTableName, tableDDLOptions);
+            TestUtil.createMultiCFTestTable(conn, fullTableName, tableDDLOptions);
             populateMultiCFTestTable(fullTableName);
             conn.createStatement().execute("CREATE " + (localIndex ? " LOCAL " : "") + " INDEX " + indexName + " ON " + fullTableName 
-            		+ " (char_col1 ASC, int_col1 ASC) INCLUDE (long_col1, long_col2)");
+                    + " (char_col1 ASC, int_col1 ASC) INCLUDE (long_col1, long_col2)");
             
             String query = "SELECT char_col1, int_col1, long_col2 from " + fullTableName;
             ResultSet rs = conn.createStatement().executeQuery("EXPLAIN " + query);
@@ -200,7 +200,7 @@ public class MutableIndexIT extends ParallelStatsDisabledIT {
                 query = "SELECT b.* from " + fullTableName + " where int_col1 = 4";
                 rs = conn.createStatement().executeQuery("EXPLAIN " + query);
                 assertEquals("CLIENT PARALLEL 1-WAY RANGE SCAN OVER " + fullTableName +" [1]\n" +
-                		"    SERVER FILTER BY TO_INTEGER(\"INT_COL1\") = 4\nCLIENT MERGE SORT", QueryUtil.getExplainPlan(rs));
+                        "    SERVER FILTER BY TO_INTEGER(\"INT_COL1\") = 4\nCLIENT MERGE SORT", QueryUtil.getExplainPlan(rs));
                 rs = conn.createStatement().executeQuery(query);
                 assertTrue(rs.next());
                 assertEquals("varchar_b", rs.getString(1));
@@ -215,219 +215,219 @@ public class MutableIndexIT extends ParallelStatsDisabledIT {
     
     @Test
     public void testCoveredColumns() throws Exception {
-		String tableName = "TBL_" + generateUniqueName();
-		String indexName = "IDX_" + generateUniqueName();
-		String fullTableName = SchemaUtil.getTableName(TestUtil.DEFAULT_SCHEMA_NAME, tableName);
-		String fullIndexName = SchemaUtil.getTableName(TestUtil.DEFAULT_SCHEMA_NAME, indexName);
+        String tableName = "TBL_" + generateUniqueName();
+        String indexName = "IDX_" + generateUniqueName();
+        String fullTableName = SchemaUtil.getTableName(TestUtil.DEFAULT_SCHEMA_NAME, tableName);
+        String fullIndexName = SchemaUtil.getTableName(TestUtil.DEFAULT_SCHEMA_NAME, indexName);
         try (Connection conn = getConnection()) {
 
-	        conn.setAutoCommit(false);
-	        String query;
-	        ResultSet rs;
-	        conn.createStatement().execute("CREATE TABLE " + fullTableName + " (k VARCHAR NOT NULL PRIMARY KEY, v1 VARCHAR, v2 VARCHAR)" + tableDDLOptions);
-	        query = "SELECT * FROM " + fullTableName;
-	        rs = conn.createStatement().executeQuery(query);
-	        assertFalse(rs.next());
-	        
-	        conn.createStatement().execute("CREATE " + (localIndex ? " LOCAL " : "") + " INDEX " + indexName + " ON " + fullTableName + " (v1) INCLUDE (v2)");
-	        query = "SELECT * FROM " + fullIndexName;
-	        rs = conn.createStatement().executeQuery(query);
-	        assertFalse(rs.next());
-	
-	        PreparedStatement stmt = conn.prepareStatement("UPSERT INTO " + fullTableName + " VALUES(?,?,?)");
-	        stmt.setString(1,"a");
-	        stmt.setString(2, "x");
-	        stmt.setString(3, "1");
-	        stmt.execute();
-	        conn.commit();
-	        
-	        query = "SELECT * FROM " + fullIndexName;
-	        rs = conn.createStatement().executeQuery(query);
-	        assertTrue(rs.next());
-	        assertEquals("x",rs.getString(1));
-	        assertEquals("a",rs.getString(2));
-	        assertEquals("1",rs.getString(3));
-	        assertFalse(rs.next());
-	
-	        stmt = conn.prepareStatement("UPSERT INTO " + fullTableName + "(k,v2) VALUES(?,?)");
-	        stmt.setString(1,"a");
-	        stmt.setString(2, null);
-	        stmt.execute();
-	        conn.commit();
-	        
-	        query = "SELECT * FROM " + fullIndexName;
-	        rs = conn.createStatement().executeQuery(query);
-	        assertTrue(rs.next());
-	        assertEquals("x",rs.getString(1));
-	        assertEquals("a",rs.getString(2));
-	        assertNull(rs.getString(3));
-	        assertFalse(rs.next());
-	
-	        query = "SELECT * FROM " + fullTableName;
-	        rs = conn.createStatement().executeQuery("EXPLAIN " + query);
-	        if(localIndex) {
-	            assertEquals("CLIENT PARALLEL 1-WAY RANGE SCAN OVER " + fullTableName+" [1]\nCLIENT MERGE SORT", QueryUtil.getExplainPlan(rs));            
-	        } else {
-	            assertEquals("CLIENT PARALLEL 1-WAY FULL SCAN OVER " + fullIndexName, QueryUtil.getExplainPlan(rs));
-	        }
-	
-	        rs = conn.createStatement().executeQuery(query);
-	        assertTrue(rs.next());
-	        assertEquals("a",rs.getString(1));
-	        assertEquals("x",rs.getString(2));
-	        assertNull(rs.getString(3));
-	        assertFalse(rs.next());
-	
-	        stmt = conn.prepareStatement("UPSERT INTO " + fullTableName + "(k,v2) VALUES(?,?)");
-	        stmt.setString(1,"a");
-	        stmt.setString(2,"3");
-	        stmt.execute();
-	        conn.commit();
-	        
-	        query = "SELECT * FROM " + fullTableName;
-	        rs = conn.createStatement().executeQuery("EXPLAIN " + query);
-	        if(localIndex) {
-	            assertEquals("CLIENT PARALLEL 1-WAY RANGE SCAN OVER " + fullTableName + " [1]\nCLIENT MERGE SORT", QueryUtil.getExplainPlan(rs));            
-	        } else {
-	            assertEquals("CLIENT PARALLEL 1-WAY FULL SCAN OVER " + fullIndexName, QueryUtil.getExplainPlan(rs));
-	        }
-	        
-	        rs = conn.createStatement().executeQuery(query);
-	        assertTrue(rs.next());
-	        assertEquals("a",rs.getString(1));
-	        assertEquals("x",rs.getString(2));
-	        assertEquals("3",rs.getString(3));
-	        assertFalse(rs.next());
-	
-	        stmt = conn.prepareStatement("UPSERT INTO " + fullTableName + "(k,v2) VALUES(?,?)");
-	        stmt.setString(1,"a");
-	        stmt.setString(2,"4");
-	        stmt.execute();
-	        conn.commit();
-	        
-	        query = "SELECT * FROM " + fullTableName;
-	        rs = conn.createStatement().executeQuery("EXPLAIN " + query);
-	        if(localIndex) {
-	            assertEquals("CLIENT PARALLEL 1-WAY RANGE SCAN OVER " + fullTableName+" [1]\nCLIENT MERGE SORT", QueryUtil.getExplainPlan(rs));            
-	        } else {
-	            assertEquals("CLIENT PARALLEL 1-WAY FULL SCAN OVER " + fullIndexName, QueryUtil.getExplainPlan(rs));
-	        }
-	        
-	        rs = conn.createStatement().executeQuery(query);
-	        assertTrue(rs.next());
-	        assertEquals("a",rs.getString(1));
-	        assertEquals("x",rs.getString(2));
-	        assertEquals("4",rs.getString(3));
-	        assertFalse(rs.next());
+            conn.setAutoCommit(false);
+            String query;
+            ResultSet rs;
+            conn.createStatement().execute("CREATE TABLE " + fullTableName + " (k VARCHAR NOT NULL PRIMARY KEY, v1 VARCHAR, v2 VARCHAR)" + tableDDLOptions);
+            query = "SELECT * FROM " + fullTableName;
+            rs = conn.createStatement().executeQuery(query);
+            assertFalse(rs.next());
+            
+            conn.createStatement().execute("CREATE " + (localIndex ? " LOCAL " : "") + " INDEX " + indexName + " ON " + fullTableName + " (v1) INCLUDE (v2)");
+            query = "SELECT * FROM " + fullIndexName;
+            rs = conn.createStatement().executeQuery(query);
+            assertFalse(rs.next());
+    
+            PreparedStatement stmt = conn.prepareStatement("UPSERT INTO " + fullTableName + " VALUES(?,?,?)");
+            stmt.setString(1,"a");
+            stmt.setString(2, "x");
+            stmt.setString(3, "1");
+            stmt.execute();
+            conn.commit();
+            
+            query = "SELECT * FROM " + fullIndexName;
+            rs = conn.createStatement().executeQuery(query);
+            assertTrue(rs.next());
+            assertEquals("x",rs.getString(1));
+            assertEquals("a",rs.getString(2));
+            assertEquals("1",rs.getString(3));
+            assertFalse(rs.next());
+    
+            stmt = conn.prepareStatement("UPSERT INTO " + fullTableName + "(k,v2) VALUES(?,?)");
+            stmt.setString(1,"a");
+            stmt.setString(2, null);
+            stmt.execute();
+            conn.commit();
+            
+            query = "SELECT * FROM " + fullIndexName;
+            rs = conn.createStatement().executeQuery(query);
+            assertTrue(rs.next());
+            assertEquals("x",rs.getString(1));
+            assertEquals("a",rs.getString(2));
+            assertNull(rs.getString(3));
+            assertFalse(rs.next());
+    
+            query = "SELECT * FROM " + fullTableName;
+            rs = conn.createStatement().executeQuery("EXPLAIN " + query);
+            if(localIndex) {
+                assertEquals("CLIENT PARALLEL 1-WAY RANGE SCAN OVER " + fullTableName+" [1]\nCLIENT MERGE SORT", QueryUtil.getExplainPlan(rs));            
+            } else {
+                assertEquals("CLIENT PARALLEL 1-WAY FULL SCAN OVER " + fullIndexName, QueryUtil.getExplainPlan(rs));
+            }
+    
+            rs = conn.createStatement().executeQuery(query);
+            assertTrue(rs.next());
+            assertEquals("a",rs.getString(1));
+            assertEquals("x",rs.getString(2));
+            assertNull(rs.getString(3));
+            assertFalse(rs.next());
+    
+            stmt = conn.prepareStatement("UPSERT INTO " + fullTableName + "(k,v2) VALUES(?,?)");
+            stmt.setString(1,"a");
+            stmt.setString(2,"3");
+            stmt.execute();
+            conn.commit();
+            
+            query = "SELECT * FROM " + fullTableName;
+            rs = conn.createStatement().executeQuery("EXPLAIN " + query);
+            if(localIndex) {
+                assertEquals("CLIENT PARALLEL 1-WAY RANGE SCAN OVER " + fullTableName + " [1]\nCLIENT MERGE SORT", QueryUtil.getExplainPlan(rs));            
+            } else {
+                assertEquals("CLIENT PARALLEL 1-WAY FULL SCAN OVER " + fullIndexName, QueryUtil.getExplainPlan(rs));
+            }
+            
+            rs = conn.createStatement().executeQuery(query);
+            assertTrue(rs.next());
+            assertEquals("a",rs.getString(1));
+            assertEquals("x",rs.getString(2));
+            assertEquals("3",rs.getString(3));
+            assertFalse(rs.next());
+    
+            stmt = conn.prepareStatement("UPSERT INTO " + fullTableName + "(k,v2) VALUES(?,?)");
+            stmt.setString(1,"a");
+            stmt.setString(2,"4");
+            stmt.execute();
+            conn.commit();
+            
+            query = "SELECT * FROM " + fullTableName;
+            rs = conn.createStatement().executeQuery("EXPLAIN " + query);
+            if(localIndex) {
+                assertEquals("CLIENT PARALLEL 1-WAY RANGE SCAN OVER " + fullTableName+" [1]\nCLIENT MERGE SORT", QueryUtil.getExplainPlan(rs));            
+            } else {
+                assertEquals("CLIENT PARALLEL 1-WAY FULL SCAN OVER " + fullIndexName, QueryUtil.getExplainPlan(rs));
+            }
+            
+            rs = conn.createStatement().executeQuery(query);
+            assertTrue(rs.next());
+            assertEquals("a",rs.getString(1));
+            assertEquals("x",rs.getString(2));
+            assertEquals("4",rs.getString(3));
+            assertFalse(rs.next());
         }
     }
 
     @Test
     public void testCompoundIndexKey() throws Exception {
-		String tableName = "TBL_" + generateUniqueName();
-		String indexName = "IDX_" + generateUniqueName();
-		String fullTableName = SchemaUtil.getTableName(TestUtil.DEFAULT_SCHEMA_NAME, tableName);
-		String fullIndexName = SchemaUtil.getTableName(TestUtil.DEFAULT_SCHEMA_NAME, indexName);
+        String tableName = "TBL_" + generateUniqueName();
+        String indexName = "IDX_" + generateUniqueName();
+        String fullTableName = SchemaUtil.getTableName(TestUtil.DEFAULT_SCHEMA_NAME, tableName);
+        String fullIndexName = SchemaUtil.getTableName(TestUtil.DEFAULT_SCHEMA_NAME, indexName);
         try (Connection conn = getConnection()) {
-	        conn.setAutoCommit(false);
-	        String query;
-	        ResultSet rs;
-	        // make sure that the tables are empty, but reachable
-	        conn.createStatement().execute("CREATE TABLE " + fullTableName + " (k VARCHAR NOT NULL PRIMARY KEY, v1 VARCHAR, v2 VARCHAR)" + tableDDLOptions);
-	        query = "SELECT * FROM " + fullTableName;
-	        rs = conn.createStatement().executeQuery(query);
-	        assertFalse(rs.next());
-	        conn.createStatement().execute("CREATE " + (localIndex ? " LOCAL " : "") + " INDEX " + indexName + " ON " + fullTableName + " (v1, v2)");
-	        query = "SELECT * FROM " + fullIndexName;
-	        rs = conn.createStatement().executeQuery(query);
-	        assertFalse(rs.next());
-	
-	        // load some data into the table
-	        PreparedStatement stmt = conn.prepareStatement("UPSERT INTO " + fullTableName + " VALUES(?,?,?)");
-	        stmt.setString(1,"a");
-	        stmt.setString(2, "x");
-	        stmt.setString(3, "1");
-	        stmt.execute();
-	        conn.commit();
-	        
-	        query = "SELECT * FROM " + fullIndexName;
-	        rs = conn.createStatement().executeQuery(query);
-	        assertTrue(rs.next());
-	        assertEquals("x",rs.getString(1));
-	        assertEquals("1",rs.getString(2));
-	        assertEquals("a",rs.getString(3));
-	        assertFalse(rs.next());
-	
-	        stmt = conn.prepareStatement("UPSERT INTO " + fullTableName + " VALUES(?,?,?)");
-	        stmt.setString(1,"a");
-	        stmt.setString(2, "y");
-	        stmt.setString(3, null);
-	        stmt.execute();
-	        conn.commit();
-	        
-	        query = "SELECT * FROM " + fullIndexName;
-	        rs = conn.createStatement().executeQuery(query);
-	        assertTrue(rs.next());
-	        assertEquals("y",rs.getString(1));
-	        assertNull(rs.getString(2));
-	        assertEquals("a",rs.getString(3));
-	        assertFalse(rs.next());
-	
-	        query = "SELECT * FROM " + fullTableName;
-	        rs = conn.createStatement().executeQuery("EXPLAIN " + query);
-	        if (localIndex) {
-	            assertEquals("CLIENT PARALLEL 1-WAY RANGE SCAN OVER " + fullTableName+" [1]\n"
-	                    + "    SERVER FILTER BY FIRST KEY ONLY\n"
-	                    + "CLIENT MERGE SORT", QueryUtil.getExplainPlan(rs));
-	        } else {
-	            assertEquals("CLIENT PARALLEL 1-WAY FULL SCAN OVER " + fullIndexName + "\n"
-	                       + "    SERVER FILTER BY FIRST KEY ONLY", QueryUtil.getExplainPlan(rs));
-	        }
-	        //make sure the data table looks like what we expect
-	        rs = conn.createStatement().executeQuery(query);
-	        assertTrue(rs.next());
-	        assertEquals("a",rs.getString(1));
-	        assertEquals("y",rs.getString(2));
-	        assertNull(rs.getString(3));
-	        assertFalse(rs.next());
-	        
-	        // Upsert new row with null leading index column
-	        stmt.setString(1,"b");
-	        stmt.setString(2, null);
-	        stmt.setString(3, "3");
-	        stmt.execute();
-	        conn.commit();
-	        
-	        query = "SELECT * FROM " + fullIndexName;
-	        rs = conn.createStatement().executeQuery(query);
-	        assertTrue(rs.next());
-	        assertEquals(null,rs.getString(1));
-	        assertEquals("3",rs.getString(2));
-	        assertEquals("b",rs.getString(3));
-	        assertTrue(rs.next());
-	        assertEquals("y",rs.getString(1));
-	        assertNull(rs.getString(2));
-	        assertEquals("a",rs.getString(3));
-	        assertFalse(rs.next());
-	
-	        // Update row with null leading index column to have a value
-	        stmt = conn.prepareStatement("UPSERT INTO " + fullTableName + " VALUES(?,?)");
-	        stmt.setString(1,"b");
-	        stmt.setString(2, "z");
-	        stmt.execute();
-	        conn.commit();
-	        
-	        query = "SELECT * FROM " + fullIndexName;
-	        rs = conn.createStatement().executeQuery(query);
-	        assertTrue(rs.next());
-	        assertEquals("y",rs.getString(1));
-	        assertNull(rs.getString(2));
-	        assertEquals("a",rs.getString(3));
-	        assertTrue(rs.next());
-	        assertEquals("z",rs.getString(1));
-	        assertEquals("3",rs.getString(2));
-	        assertEquals("b",rs.getString(3));
-	        assertFalse(rs.next());
+            conn.setAutoCommit(false);
+            String query;
+            ResultSet rs;
+            // make sure that the tables are empty, but reachable
+            conn.createStatement().execute("CREATE TABLE " + fullTableName + " (k VARCHAR NOT NULL PRIMARY KEY, v1 VARCHAR, v2 VARCHAR)" + tableDDLOptions);
+            query = "SELECT * FROM " + fullTableName;
+            rs = conn.createStatement().executeQuery(query);
+            assertFalse(rs.next());
+            conn.createStatement().execute("CREATE " + (localIndex ? " LOCAL " : "") + " INDEX " + indexName + " ON " + fullTableName + " (v1, v2)");
+            query = "SELECT * FROM " + fullIndexName;
+            rs = conn.createStatement().executeQuery(query);
+            assertFalse(rs.next());
+    
+            // load some data into the table
+            PreparedStatement stmt = conn.prepareStatement("UPSERT INTO " + fullTableName + " VALUES(?,?,?)");
+            stmt.setString(1,"a");
+            stmt.setString(2, "x");
+            stmt.setString(3, "1");
+            stmt.execute();
+            conn.commit();
+            
+            query = "SELECT * FROM " + fullIndexName;
+            rs = conn.createStatement().executeQuery(query);
+            assertTrue(rs.next());
+            assertEquals("x",rs.getString(1));
+            assertEquals("1",rs.getString(2));
+            assertEquals("a",rs.getString(3));
+            assertFalse(rs.next());
+    
+            stmt = conn.prepareStatement("UPSERT INTO " + fullTableName + " VALUES(?,?,?)");
+            stmt.setString(1,"a");
+            stmt.setString(2, "y");
+            stmt.setString(3, null);
+            stmt.execute();
+            conn.commit();
+            
+            query = "SELECT * FROM " + fullIndexName;
+            rs = conn.createStatement().executeQuery(query);
+            assertTrue(rs.next());
+            assertEquals("y",rs.getString(1));
+            assertNull(rs.getString(2));
+            assertEquals("a",rs.getString(3));
+            assertFalse(rs.next());
+    
+            query = "SELECT * FROM " + fullTableName;
+            rs = conn.createStatement().executeQuery("EXPLAIN " + query);
+            if (localIndex) {
+                assertEquals("CLIENT PARALLEL 1-WAY RANGE SCAN OVER " + fullTableName+" [1]\n"
+                        + "    SERVER FILTER BY FIRST KEY ONLY\n"
+                        + "CLIENT MERGE SORT", QueryUtil.getExplainPlan(rs));
+            } else {
+                assertEquals("CLIENT PARALLEL 1-WAY FULL SCAN OVER " + fullIndexName + "\n"
+                           + "    SERVER FILTER BY FIRST KEY ONLY", QueryUtil.getExplainPlan(rs));
+            }
+            //make sure the data table looks like what we expect
+            rs = conn.createStatement().executeQuery(query);
+            assertTrue(rs.next());
+            assertEquals("a",rs.getString(1));
+            assertEquals("y",rs.getString(2));
+            assertNull(rs.getString(3));
+            assertFalse(rs.next());
+            
+            // Upsert new row with null leading index column
+            stmt.setString(1,"b");
+            stmt.setString(2, null);
+            stmt.setString(3, "3");
+            stmt.execute();
+            conn.commit();
+            
+            query = "SELECT * FROM " + fullIndexName;
+            rs = conn.createStatement().executeQuery(query);
+            assertTrue(rs.next());
+            assertEquals(null,rs.getString(1));
+            assertEquals("3",rs.getString(2));
+            assertEquals("b",rs.getString(3));
+            assertTrue(rs.next());
+            assertEquals("y",rs.getString(1));
+            assertNull(rs.getString(2));
+            assertEquals("a",rs.getString(3));
+            assertFalse(rs.next());
+    
+            // Update row with null leading index column to have a value
+            stmt = conn.prepareStatement("UPSERT INTO " + fullTableName + " VALUES(?,?)");
+            stmt.setString(1,"b");
+            stmt.setString(2, "z");
+            stmt.execute();
+            conn.commit();
+            
+            query = "SELECT * FROM " + fullIndexName;
+            rs = conn.createStatement().executeQuery(query);
+            assertTrue(rs.next());
+            assertEquals("y",rs.getString(1));
+            assertNull(rs.getString(2));
+            assertEquals("a",rs.getString(3));
+            assertTrue(rs.next());
+            assertEquals("z",rs.getString(1));
+            assertEquals("3",rs.getString(2));
+            assertEquals("b",rs.getString(3));
+            assertFalse(rs.next());
         }
 
     }
@@ -442,166 +442,166 @@ public class MutableIndexIT extends ParallelStatsDisabledIT {
      */
     @Test
     public void testMultipleUpdatesToSingleRow() throws Exception {
-		String tableName = "TBL_" + generateUniqueName();
-		String indexName = "IDX_" + generateUniqueName();
-		String fullTableName = SchemaUtil.getTableName(TestUtil.DEFAULT_SCHEMA_NAME, tableName);
-		String fullIndexName = SchemaUtil.getTableName(TestUtil.DEFAULT_SCHEMA_NAME, indexName);
+        String tableName = "TBL_" + generateUniqueName();
+        String indexName = "IDX_" + generateUniqueName();
+        String fullTableName = SchemaUtil.getTableName(TestUtil.DEFAULT_SCHEMA_NAME, tableName);
+        String fullIndexName = SchemaUtil.getTableName(TestUtil.DEFAULT_SCHEMA_NAME, indexName);
         try (Connection conn = getConnection()) {
-	        conn.setAutoCommit(false);
-	        String query;
-	        ResultSet rs;
-	        // make sure that the tables are empty, but reachable
-	        conn.createStatement().execute(
-	          "CREATE TABLE " + fullTableName
-	              + " (k VARCHAR NOT NULL PRIMARY KEY, v1 VARCHAR, v2 VARCHAR)" + tableDDLOptions);
-	        query = "SELECT * FROM " + fullTableName;
-	        rs = conn.createStatement().executeQuery(query);
-	        assertFalse(rs.next());
-	
-	        conn.createStatement().execute("CREATE " + (localIndex ? " LOCAL " : "") + " INDEX " + indexName + " ON " + fullTableName + " (v1, v2)");
-	        query = "SELECT * FROM " + fullIndexName;
-	        rs = conn.createStatement().executeQuery(query);
-	        assertFalse(rs.next());
-	    
-	        // load some data into the table
-	        PreparedStatement stmt =
-	            conn.prepareStatement("UPSERT INTO " + fullTableName + " VALUES(?,?,?)");
-	        stmt.setString(1, "a");
-	        stmt.setString(2, "x");
-	        stmt.setString(3, "1");
-	        stmt.execute();
-	        conn.commit();
-	        
-	        // make sure the index is working as expected
-	        query = "SELECT * FROM " + fullIndexName;
-	        rs = conn.createStatement().executeQuery(query);
-	        assertTrue(rs.next());
-	        assertEquals("x", rs.getString(1));
-	        assertEquals("1", rs.getString(2));
-	        assertEquals("a", rs.getString(3));
-	        assertFalse(rs.next());
-	      
-	        // do multiple updates to the same row, in the same batch
-	        stmt = conn.prepareStatement("UPSERT INTO " + fullTableName + "(k, v1) VALUES(?,?)");
-	        stmt.setString(1, "a");
-	        stmt.setString(2, "y");
-	        stmt.execute();
-	        stmt = conn.prepareStatement("UPSERT INTO " + fullTableName + "(k,v2) VALUES(?,?)");
-	        stmt.setString(1, "a");
-	        stmt.setString(2, null);
-	        stmt.execute();
-	        conn.commit();
-	    
-	        query = "SELECT * FROM " + fullIndexName;
-	        rs = conn.createStatement().executeQuery(query);
-	        assertTrue(rs.next());
-	        assertEquals("y", rs.getString(1));
-	        assertNull(rs.getString(2));
-	        assertEquals("a", rs.getString(3));
-	        assertFalse(rs.next());
-	    
-	        query = "SELECT * FROM " + fullTableName;
-	        rs = conn.createStatement().executeQuery("EXPLAIN " + query);
-	        if(localIndex) {
-	            assertEquals("CLIENT PARALLEL 1-WAY RANGE SCAN OVER " + fullTableName+" [1]\n"
-	                    + "    SERVER FILTER BY FIRST KEY ONLY\n"
-	                    + "CLIENT MERGE SORT",
-	                QueryUtil.getExplainPlan(rs));
-	        } else {
-	            assertEquals("CLIENT PARALLEL 1-WAY FULL SCAN OVER " + fullIndexName + "\n"
-	                    + "    SERVER FILTER BY FIRST KEY ONLY",
-	                QueryUtil.getExplainPlan(rs));
-	        }
-	    
-	        // check that the data table matches as expected
-	        rs = conn.createStatement().executeQuery(query);
-	        assertTrue(rs.next());
-	        assertEquals("a", rs.getString(1));
-	        assertEquals("y", rs.getString(2));
-	        assertNull(rs.getString(3));
-	        assertFalse(rs.next());
+            conn.setAutoCommit(false);
+            String query;
+            ResultSet rs;
+            // make sure that the tables are empty, but reachable
+            conn.createStatement().execute(
+              "CREATE TABLE " + fullTableName
+                  + " (k VARCHAR NOT NULL PRIMARY KEY, v1 VARCHAR, v2 VARCHAR)" + tableDDLOptions);
+            query = "SELECT * FROM " + fullTableName;
+            rs = conn.createStatement().executeQuery(query);
+            assertFalse(rs.next());
+    
+            conn.createStatement().execute("CREATE " + (localIndex ? " LOCAL " : "") + " INDEX " + indexName + " ON " + fullTableName + " (v1, v2)");
+            query = "SELECT * FROM " + fullIndexName;
+            rs = conn.createStatement().executeQuery(query);
+            assertFalse(rs.next());
+        
+            // load some data into the table
+            PreparedStatement stmt =
+                conn.prepareStatement("UPSERT INTO " + fullTableName + " VALUES(?,?,?)");
+            stmt.setString(1, "a");
+            stmt.setString(2, "x");
+            stmt.setString(3, "1");
+            stmt.execute();
+            conn.commit();
+            
+            // make sure the index is working as expected
+            query = "SELECT * FROM " + fullIndexName;
+            rs = conn.createStatement().executeQuery(query);
+            assertTrue(rs.next());
+            assertEquals("x", rs.getString(1));
+            assertEquals("1", rs.getString(2));
+            assertEquals("a", rs.getString(3));
+            assertFalse(rs.next());
+          
+            // do multiple updates to the same row, in the same batch
+            stmt = conn.prepareStatement("UPSERT INTO " + fullTableName + "(k, v1) VALUES(?,?)");
+            stmt.setString(1, "a");
+            stmt.setString(2, "y");
+            stmt.execute();
+            stmt = conn.prepareStatement("UPSERT INTO " + fullTableName + "(k,v2) VALUES(?,?)");
+            stmt.setString(1, "a");
+            stmt.setString(2, null);
+            stmt.execute();
+            conn.commit();
+        
+            query = "SELECT * FROM " + fullIndexName;
+            rs = conn.createStatement().executeQuery(query);
+            assertTrue(rs.next());
+            assertEquals("y", rs.getString(1));
+            assertNull(rs.getString(2));
+            assertEquals("a", rs.getString(3));
+            assertFalse(rs.next());
+        
+            query = "SELECT * FROM " + fullTableName;
+            rs = conn.createStatement().executeQuery("EXPLAIN " + query);
+            if(localIndex) {
+                assertEquals("CLIENT PARALLEL 1-WAY RANGE SCAN OVER " + fullTableName+" [1]\n"
+                        + "    SERVER FILTER BY FIRST KEY ONLY\n"
+                        + "CLIENT MERGE SORT",
+                    QueryUtil.getExplainPlan(rs));
+            } else {
+                assertEquals("CLIENT PARALLEL 1-WAY FULL SCAN OVER " + fullIndexName + "\n"
+                        + "    SERVER FILTER BY FIRST KEY ONLY",
+                    QueryUtil.getExplainPlan(rs));
+            }
+        
+            // check that the data table matches as expected
+            rs = conn.createStatement().executeQuery(query);
+            assertTrue(rs.next());
+            assertEquals("a", rs.getString(1));
+            assertEquals("y", rs.getString(2));
+            assertNull(rs.getString(3));
+            assertFalse(rs.next());
         }
     }
     
     @Test
     public void testUpsertingNullForIndexedColumns() throws Exception {
-		String tableName = "TBL_" + generateUniqueName();
-		String indexName = "IDX_" + generateUniqueName();
-		String fullIndexName = SchemaUtil.getTableName(TestUtil.DEFAULT_SCHEMA_NAME, indexName);
-        String testTableName = tableName + "_" + System.currentTimeMillis();
+        String tableName = "TBL_" + generateUniqueName();
+        String indexName = "IDX_" + generateUniqueName();
+        String fullIndexName = SchemaUtil.getTableName(TestUtil.DEFAULT_SCHEMA_NAME, indexName);
+        String testTableName = SchemaUtil.getTableName(TestUtil.DEFAULT_SCHEMA_NAME, tableName + "_" + System.currentTimeMillis());
         try (Connection conn = getConnection()) {
-	        conn.setAutoCommit(false);
-	        ResultSet rs;
-    		Statement stmt = conn.createStatement();
-    		stmt.execute("CREATE TABLE " + testTableName + "(v1 VARCHAR PRIMARY KEY, v2 DOUBLE, v3 VARCHAR) "+tableDDLOptions);
-    		stmt.execute("CREATE " + (localIndex ? "LOCAL" : "") + " INDEX " + indexName + " ON " + testTableName + "  (v2) INCLUDE(v3)");
-    		
-    		//create a row with value null for indexed column v2
-    		stmt.executeUpdate("upsert into " + testTableName + " values('cc1', null, 'abc')");
-    		conn.commit();
-    		
-    		//assert values in index table 
-    		rs = stmt.executeQuery("select * from " + fullIndexName);
-    		assertTrue(rs.next());
-    		assertEquals(0, Doubles.compare(0, rs.getDouble(1)));
-    		assertTrue(rs.wasNull());
-    		assertEquals("cc1", rs.getString(2));
-    		assertEquals("abc", rs.getString(3));
-    		assertFalse(rs.next());
-    		
-    		//assert values in data table
-    		rs = stmt.executeQuery("select v1, v2, v3 from " + testTableName);
-    		assertTrue(rs.next());
-    		assertEquals("cc1", rs.getString(1));
-    		assertEquals(0, Doubles.compare(0, rs.getDouble(2)));
-    		assertTrue(rs.wasNull());
-    		assertEquals("abc", rs.getString(3));
-    		assertFalse(rs.next());
-    		
-    		//update the previously null value for indexed column v2 to a non-null value 1.23
-    		stmt.executeUpdate("upsert into " + testTableName + " values('cc1', 1.23, 'abc')");
-    		conn.commit();
-    		
-    		//assert values in data table
-    		rs = stmt.executeQuery("select /*+ NO_INDEX */ v1, v2, v3 from " + testTableName);
-    		assertTrue(rs.next());
-    		assertEquals("cc1", rs.getString(1));
-    		assertEquals(0, Doubles.compare(1.23, rs.getDouble(2)));
-    		assertEquals("abc", rs.getString(3));
-    		assertFalse(rs.next());
-    		
-    		//assert values in index table 
-    		rs = stmt.executeQuery("select * from " + indexName);
-    		assertTrue(rs.next());
-    		assertEquals(0, Doubles.compare(1.23, rs.getDouble(1)));
-    		assertEquals("cc1", rs.getString(2));
-    		assertEquals("abc", rs.getString(3));
-    		assertFalse(rs.next());
-    		
-    		//update the value for indexed column v2 back to null
-    		stmt.executeUpdate("upsert into " + testTableName + " values('cc1', null, 'abc')");
-    		conn.commit();
-    		
-    		//assert values in index table 
-    		rs = stmt.executeQuery("select * from " + indexName);
-    		assertTrue(rs.next());
-    		assertEquals(0, Doubles.compare(0, rs.getDouble(1)));
-    		assertTrue(rs.wasNull());
-    		assertEquals("cc1", rs.getString(2));
-    		assertEquals("abc", rs.getString(3));
-    		assertFalse(rs.next());
-    		
-    		//assert values in data table
-    		rs = stmt.executeQuery("select v1, v2, v3 from " + testTableName);
-    		assertTrue(rs.next());
-    		assertEquals("cc1", rs.getString(1));
-    		assertEquals(0, Doubles.compare(0, rs.getDouble(2)));
-    		assertEquals("abc", rs.getString(3));
-    		assertFalse(rs.next());
-    	} 
+            conn.setAutoCommit(false);
+            ResultSet rs;
+            Statement stmt = conn.createStatement();
+            stmt.execute("CREATE TABLE " + testTableName + "(v1 VARCHAR PRIMARY KEY, v2 DOUBLE, v3 VARCHAR) "+tableDDLOptions);
+            stmt.execute("CREATE " + (localIndex ? "LOCAL" : "") + " INDEX " + indexName + " ON " + testTableName + "  (v2) INCLUDE(v3)");
+            
+            //create a row with value null for indexed column v2
+            stmt.executeUpdate("upsert into " + testTableName + " values('cc1', null, 'abc')");
+            conn.commit();
+            
+            //assert values in index table 
+            rs = stmt.executeQuery("select * from " + fullIndexName);
+            assertTrue(rs.next());
+            assertEquals(0, Doubles.compare(0, rs.getDouble(1)));
+            assertTrue(rs.wasNull());
+            assertEquals("cc1", rs.getString(2));
+            assertEquals("abc", rs.getString(3));
+            assertFalse(rs.next());
+            
+            //assert values in data table
+            rs = stmt.executeQuery("select v1, v2, v3 from " + testTableName);
+            assertTrue(rs.next());
+            assertEquals("cc1", rs.getString(1));
+            assertEquals(0, Doubles.compare(0, rs.getDouble(2)));
+            assertTrue(rs.wasNull());
+            assertEquals("abc", rs.getString(3));
+            assertFalse(rs.next());
+            
+            //update the previously null value for indexed column v2 to a non-null value 1.23
+            stmt.executeUpdate("upsert into " + testTableName + " values('cc1', 1.23, 'abc')");
+            conn.commit();
+            
+            //assert values in data table
+            rs = stmt.executeQuery("select /*+ NO_INDEX */ v1, v2, v3 from " + testTableName);
+            assertTrue(rs.next());
+            assertEquals("cc1", rs.getString(1));
+            assertEquals(0, Doubles.compare(1.23, rs.getDouble(2)));
+            assertEquals("abc", rs.getString(3));
+            assertFalse(rs.next());
+            
+            //assert values in index table 
+            rs = stmt.executeQuery("select * from " + fullIndexName);
+            assertTrue(rs.next());
+            assertEquals(0, Doubles.compare(1.23, rs.getDouble(1)));
+            assertEquals("cc1", rs.getString(2));
+            assertEquals("abc", rs.getString(3));
+            assertFalse(rs.next());
+            
+            //update the value for indexed column v2 back to null
+            stmt.executeUpdate("upsert into " + testTableName + " values('cc1', null, 'abc')");
+            conn.commit();
+            
+            //assert values in index table 
+            rs = stmt.executeQuery("select * from " + fullIndexName);
+            assertTrue(rs.next());
+            assertEquals(0, Doubles.compare(0, rs.getDouble(1)));
+            assertTrue(rs.wasNull());
+            assertEquals("cc1", rs.getString(2));
+            assertEquals("abc", rs.getString(3));
+            assertFalse(rs.next());
+            
+            //assert values in data table
+            rs = stmt.executeQuery("select v1, v2, v3 from " + testTableName);
+            assertTrue(rs.next());
+            assertEquals("cc1", rs.getString(1));
+            assertEquals(0, Doubles.compare(0, rs.getDouble(2)));
+            assertEquals("abc", rs.getString(3));
+            assertFalse(rs.next());
+        } 
     }
     
-	
+    
     private void assertImmutableRows(Connection conn, String fullTableName, boolean expectedValue) throws SQLException {
         PhoenixConnection pconn = conn.unwrap(PhoenixConnection.class);
         assertEquals(expectedValue, pconn.getTable(new PTableKey(pconn.getTenantId(), fullTableName)).isImmutableRows());
@@ -611,25 +611,25 @@ public class MutableIndexIT extends ParallelStatsDisabledIT {
     public void testAlterTableWithImmutability() throws Exception {
         String query;
         ResultSet rs;
-		String tableName = "TBL_" + generateUniqueName();
-		String fullTableName = SchemaUtil.getTableName(TestUtil.DEFAULT_SCHEMA_NAME, tableName);
+        String tableName = "TBL_" + generateUniqueName();
+        String fullTableName = SchemaUtil.getTableName(TestUtil.DEFAULT_SCHEMA_NAME, tableName);
 
         try (Connection conn = getConnection()) {
-	        conn.setAutoCommit(false);
-	        conn.createStatement().execute(
-	            "CREATE TABLE " + fullTableName +" (k VARCHAR NOT NULL PRIMARY KEY, v VARCHAR) " + tableDDLOptions);
-	        
-	        query = "SELECT * FROM " + fullTableName;
-	        rs = conn.createStatement().executeQuery(query);
-	        assertFalse(rs.next());
-	
-	        assertImmutableRows(conn,fullTableName, false);
-	        conn.createStatement().execute("ALTER TABLE " + fullTableName +" SET IMMUTABLE_ROWS=true");
-	        assertImmutableRows(conn,fullTableName, true);
-	        
-	        
-	        conn.createStatement().execute("ALTER TABLE " + fullTableName +" SET immutable_rows=false");
-	        assertImmutableRows(conn,fullTableName, false);
+            conn.setAutoCommit(false);
+            conn.createStatement().execute(
+                "CREATE TABLE " + fullTableName +" (k VARCHAR NOT NULL PRIMARY KEY, v VARCHAR) " + tableDDLOptions);
+            
+            query = "SELECT * FROM " + fullTableName;
+            rs = conn.createStatement().executeQuery(query);
+            assertFalse(rs.next());
+    
+            assertImmutableRows(conn,fullTableName, false);
+            conn.createStatement().execute("ALTER TABLE " + fullTableName +" SET IMMUTABLE_ROWS=true");
+            assertImmutableRows(conn,fullTableName, true);
+            
+            
+            conn.createStatement().execute("ALTER TABLE " + fullTableName +" SET immutable_rows=false");
+            assertImmutableRows(conn,fullTableName, false);
         }
     }
 
@@ -710,10 +710,10 @@ public class MutableIndexIT extends ParallelStatsDisabledIT {
     
   @Test
   public void testTenantSpecificConnection() throws Exception {
-	  String tableName = "TBL_" + generateUniqueName();
-	  String indexName = "IDX_" + generateUniqueName();
-	  String fullTableName = SchemaUtil.getTableName(TestUtil.DEFAULT_SCHEMA_NAME, tableName);
-	  Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
+      String tableName = "TBL_" + generateUniqueName();
+      String indexName = "IDX_" + generateUniqueName();
+      String fullTableName = SchemaUtil.getTableName(TestUtil.DEFAULT_SCHEMA_NAME, tableName);
+      Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
       try (Connection conn = getConnection()) {
           conn.setAutoCommit(false);
           // create data table
@@ -745,46 +745,6 @@ public class MutableIndexIT extends ParallelStatsDisabledIT {
       }
   }
 
-  @Test
-  public void testUpsertingDeletedRowShouldGiveProperDataWithIndexes() throws Exception {
-      testUpsertingDeletedRowShouldGiveProperDataWithIndexes(false);
-  }
-
-  @Test
-  public void testUpsertingDeletedRowShouldGiveProperDataWithMultiCFIndexes() throws Exception {
-      testUpsertingDeletedRowShouldGiveProperDataWithIndexes(true);
-  }
-
-  private void testUpsertingDeletedRowShouldGiveProperDataWithIndexes(boolean multiCf) throws Exception {
-      String tableName = "TBL_" + generateUniqueName();
-      String indexName = "IDX_" + generateUniqueName();
-      String columnFamily1 = "cf1";
-      String columnFamily2 = "cf2";
-      String fullTableName = SchemaUtil.getTableName(TestUtil.DEFAULT_SCHEMA_NAME, tableName);
-      try (Connection conn = getConnection()) {
-            conn.createStatement().execute(
-                "create table " + fullTableName + " (id integer primary key, "
-                        + (multiCf ? columnFamily1 : "") + "f float, "
-                        + (multiCf ? columnFamily2 : "") + "s varchar)" + tableDDLOptions);
-            conn.createStatement().execute(
-                "create index " + indexName + " on " + fullTableName + " ("
-                        + (multiCf ? columnFamily1 : "") + "f) include ("+(multiCf ? columnFamily2 : "") +"s)");
-            conn.createStatement().execute(
-                "upsert into " + fullTableName + " values (1, 0.5, 'foo')");
-          conn.commit();
-          conn.createStatement().execute("delete from  " + fullTableName + " where id = 1");
-          conn.commit();
-            conn.createStatement().execute(
-                "upsert into  " + fullTableName + " values (1, 0.5, 'foo')");
-          conn.commit();
-          ResultSet rs = conn.createStatement().executeQuery("select * from "+indexName);
-          assertTrue(rs.next());
-          assertEquals(1, rs.getInt(2));
-          assertEquals(0.5F, rs.getFloat(1), 0.0);
-          assertEquals("foo", rs.getString(3));
-      } 
-  }
-
   // Tests that if major compaction is run on a table with a disabled index,
   // deleted cells are kept
   @Test
@@ -866,6 +826,48 @@ public class MutableIndexIT extends ParallelStatsDisabledIT {
       }
   }
 
+
+  @Test
+  public void testUpsertingDeletedRowShouldGiveProperDataWithIndexes() throws Exception {
+      testUpsertingDeletedRowShouldGiveProperDataWithIndexes(false);
+  }
+
+  @Test
+  public void testUpsertingDeletedRowShouldGiveProperDataWithMultiCFIndexes() throws Exception {
+      testUpsertingDeletedRowShouldGiveProperDataWithIndexes(true);
+  }
+
+  private void testUpsertingDeletedRowShouldGiveProperDataWithIndexes(boolean multiCf) throws Exception {
+      String tableName = "TBL_" + generateUniqueName();
+      String indexName = "IDX_" + generateUniqueName();
+      String columnFamily1 = "cf1";
+      String columnFamily2 = "cf2";
+      String fullTableName = SchemaUtil.getTableName(TestUtil.DEFAULT_SCHEMA_NAME, tableName);
+      String fullIndexName = SchemaUtil.getTableName(TestUtil.DEFAULT_SCHEMA_NAME, indexName);
+      try (Connection conn = getConnection()) {
+            conn.createStatement().execute(
+                "create table " + fullTableName + " (id integer primary key, "
+                        + (multiCf ? columnFamily1 : "") + "f float, "
+                        + (multiCf ? columnFamily2 : "") + "s varchar)" + tableDDLOptions);
+            conn.createStatement().execute(
+                "create index " + indexName + " on " + fullTableName + " ("
+                        + (multiCf ? columnFamily1 : "") + "f) include ("+(multiCf ? columnFamily2 : "") +"s)");
+            conn.createStatement().execute(
+                "upsert into " + fullTableName + " values (1, 0.5, 'foo')");
+          conn.commit();
+          conn.createStatement().execute("delete from  " + fullTableName + " where id = 1");
+          conn.commit();
+            conn.createStatement().execute(
+                "upsert into  " + fullTableName + " values (1, 0.5, 'foo')");
+          conn.commit();
+          ResultSet rs = conn.createStatement().executeQuery("select * from "+fullIndexName);
+          assertTrue(rs.next());
+          assertEquals(1, rs.getInt(2));
+          assertEquals(0.5F, rs.getFloat(1), 0.0);
+          assertEquals("foo", rs.getString(3));
+      } 
+  }
+
 private void upsertRow(String dml, Connection tenantConn, int i) throws SQLException {
     PreparedStatement stmt = tenantConn.prepareStatement(dml);
       stmt.setString(1, "00000000000000" + String.valueOf(i));

http://git-wip-us.apache.org/repos/asf/phoenix/blob/d56fd3c9/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 8ffd798..3ce6ae5 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
@@ -39,7 +39,7 @@ import java.util.Properties;
 
 import org.apache.hadoop.hbase.util.Bytes;
 import org.apache.phoenix.compile.QueryPlan;
-import org.apache.phoenix.end2end.ParallelStatsDisabledIT;
+import org.apache.phoenix.end2end.SplitSystemCatalogIT;
 import org.apache.phoenix.jdbc.PhoenixDatabaseMetaData;
 import org.apache.phoenix.jdbc.PhoenixStatement;
 import org.apache.phoenix.query.KeyRange;
@@ -59,7 +59,7 @@ import org.junit.runners.Parameterized;
 import org.junit.runners.Parameterized.Parameters;
 
 @RunWith(Parameterized.class)
-public class ViewIndexIT extends ParallelStatsDisabledIT {
+public class ViewIndexIT extends SplitSystemCatalogIT {
     private boolean isNamespaceMapped;
 
     @Parameters(name = "ViewIndexIT_isNamespaceMapped={0}") // name is used by failsafe as file name in reports
@@ -108,10 +108,11 @@ public class ViewIndexIT extends ParallelStatsDisabledIT {
     public void testDeleteViewIndexSequences() throws Exception {
         String schemaName = generateUniqueName();
         String tableName = generateUniqueName();
+        String viewSchemaName = generateUniqueName();
         String fullTableName = SchemaUtil.getTableName(schemaName, tableName);
         String indexName = "IND_" + generateUniqueName();
         String viewName = "VIEW_" + generateUniqueName();
-        String fullViewName = SchemaUtil.getTableName(schemaName, viewName);
+        String fullViewName = SchemaUtil.getTableName(viewSchemaName, viewName);
 
         createBaseTable(schemaName, tableName, false, null, null);
         Connection conn1 = getConnection();
@@ -138,13 +139,12 @@ public class ViewIndexIT extends ParallelStatsDisabledIT {
     
     @Test
     public void testMultiTenantViewLocalIndex() throws Exception {
-        String schemaName = generateUniqueName();
-        String tableName =  generateUniqueName();
-        String indexName = "IND_" + generateUniqueName();
-        String viewName = "VIEW_" + generateUniqueName();
-        String fullTableName = SchemaUtil.getTableName(schemaName, tableName);
+        String tableName = generateUniqueName();
+		String indexName = "IND_" + generateUniqueName();
+        String fullTableName = SchemaUtil.getTableName(SCHEMA1, tableName);
+        String fullViewName = SchemaUtil.getTableName(SCHEMA2, generateUniqueName());
         
-        createBaseTable(schemaName, tableName, true, null, null);
+        createBaseTable(SCHEMA1, tableName, true, null, null);
         Connection conn = DriverManager.getConnection(getUrl());
         PreparedStatement stmt = conn.prepareStatement(
                 "UPSERT INTO " + fullTableName
@@ -178,14 +178,14 @@ public class ViewIndexIT extends ParallelStatsDisabledIT {
         Properties props  = PropertiesUtil.deepCopy(TestUtil.TEST_PROPERTIES);
         props.setProperty("TenantId", "10");
         Connection conn1 = DriverManager.getConnection(getUrl(), props);
-        conn1.createStatement().execute("CREATE VIEW " + viewName
+        conn1.createStatement().execute("CREATE VIEW " + fullViewName
                 + " AS select * from " + fullTableName);
         conn1.createStatement().execute("CREATE LOCAL INDEX "
                 + indexName + " ON "
-                + viewName + "(v2)");
+                + fullViewName + "(v2)");
         conn1.commit();
         
-        String sql = "SELECT * FROM " + viewName + " WHERE v2 = 100";
+        String sql = "SELECT * FROM " + fullViewName + " WHERE v2 = 100";
         ResultSet rs = conn1.prepareStatement("EXPLAIN " + sql).executeQuery();
         assertEquals(
                 "CLIENT PARALLEL 1-WAY RANGE SCAN OVER " + SchemaUtil.getPhysicalTableName(Bytes.toBytes(fullTableName), isNamespaceMapped) + " [1,'10',100]\n" +
@@ -208,7 +208,8 @@ public class ViewIndexIT extends ParallelStatsDisabledIT {
 
         // Confirm that when view index used, the GUIDE_POSTS_WIDTH from the data physical table
         // was used
-        sql = "SELECT * FROM " + viewName + " WHERE v2 >= 100";
+        sql = "SELECT * FROM " + fullViewName + " WHERE v2 >= 100";
+        rs = conn1.prepareStatement("EXPLAIN " + sql).executeQuery();
         stmt = conn1.prepareStatement(sql);
         stmt.executeQuery();
         QueryPlan plan = stmt.unwrap(PhoenixStatement.class).getQueryPlan();
@@ -218,9 +219,10 @@ public class ViewIndexIT extends ParallelStatsDisabledIT {
     
     @Test
     public void testCreatingIndexOnGlobalView() throws Exception {
-        String baseTable =  generateUniqueName();
-        String globalView = generateUniqueName();
+        String baseTable =  SchemaUtil.getTableName(SCHEMA1, generateUniqueName());
+        String globalView = SchemaUtil.getTableName(SCHEMA2, generateUniqueName());
         String globalViewIdx =  generateUniqueName();
+        String fullIndexName = SchemaUtil.getTableName(SCHEMA2, globalViewIdx);
         try (Connection conn = DriverManager.getConnection(getUrl())) {
             conn.createStatement().execute("CREATE IMMUTABLE TABLE " + baseTable + " (TENANT_ID CHAR(15) NOT NULL, PK2 DATE NOT NULL, PK3 INTEGER NOT NULL, KV1 VARCHAR, KV2 VARCHAR, KV3 CHAR(15) CONSTRAINT PK PRIMARY KEY(TENANT_ID, PK2 ROW_TIMESTAMP, PK3)) MULTI_TENANT=true");
             conn.createStatement().execute("CREATE VIEW " + globalView + " AS SELECT * FROM " + baseTable);
@@ -264,7 +266,7 @@ public class ViewIndexIT extends ParallelStatsDisabledIT {
             stmt.setString(2, "KV3");
             ResultSet rs = stmt.executeQuery();
             QueryPlan plan = stmt.unwrap(PhoenixStatement.class).getQueryPlan();
-            assertTrue(plan.getTableRef().getTable().getName().getString().equals(globalViewIdx));
+            assertEquals(fullIndexName, plan.getTableRef().getTable().getName().getString());
             assertTrue(rs.next());
             assertEquals("KV1", rs.getString(1));
             assertFalse(rs.next());
@@ -287,7 +289,7 @@ public class ViewIndexIT extends ParallelStatsDisabledIT {
             stmt.setString(2, "KV3");
             rs = stmt.executeQuery();
             plan = stmt.unwrap(PhoenixStatement.class).getQueryPlan();
-            assertTrue(plan.getTableRef().getTable().getName().getString().equals(globalViewIdx));
+            assertEquals(fullIndexName, plan.getTableRef().getTable().getName().getString());
             assertEquals(6, plan.getSplits().size());
         }
     }
@@ -319,14 +321,17 @@ public class ViewIndexIT extends ParallelStatsDisabledIT {
     @Test
     public void testUpdateOnTenantViewWithGlobalView() throws Exception {
         Connection conn = getConnection();
-        String baseSchemaName = "PLATFORM_ENTITY";
+        String baseSchemaName = generateUniqueName();
+        String viewSchemaName = generateUniqueName();
+        String tsViewSchemaName = generateUniqueName();
         String baseTableName = generateUniqueName();
         String baseFullName = SchemaUtil.getTableName(baseSchemaName, baseTableName);
         String viewTableName = "V_" + generateUniqueName();
-        String viewFullName = SchemaUtil.getTableName(baseSchemaName, viewTableName);
+        String viewFullName = SchemaUtil.getTableName(viewSchemaName, viewTableName);
         String indexName = "I_" + generateUniqueName();
         String tsViewTableName = "TSV_" + generateUniqueName();
-        String tsViewFullName = SchemaUtil.getTableName(baseSchemaName, tsViewTableName);
+        String tsViewFullName = SchemaUtil.getTableName(tsViewSchemaName, tsViewTableName);
+        String tenantId = "tenant1";
         try {
             if (isNamespaceMapped) {
                 conn.createStatement().execute("CREATE SCHEMA IF NOT EXISTS " + baseSchemaName);
@@ -348,7 +353,7 @@ public class ViewIndexIT extends ParallelStatsDisabledIT {
                     "CREATE INDEX " + indexName + " \n" + "ON " + viewFullName + " (TEXT1 DESC, INT1)\n"
                             + "INCLUDE (CREATED_BY, DOUBLE1, IS_BOOLEAN, CREATED_DATE)");
             Properties tsProps = PropertiesUtil.deepCopy(TEST_PROPERTIES);
-            tsProps.setProperty(PhoenixRuntime.TENANT_ID_ATTRIB, "123451234512345");
+            tsProps.setProperty(PhoenixRuntime.TENANT_ID_ATTRIB, tenantId);
             Connection tsConn = DriverManager.getConnection(getUrl(), tsProps);
             tsConn.createStatement().execute("CREATE VIEW " + tsViewFullName + " AS SELECT * FROM " + viewFullName);
             tsConn.createStatement().execute("UPSERT INTO " + tsViewFullName + "(INT1,DOUBLE1,IS_BOOLEAN,TEXT1) VALUES (1,1.0, true, 'a')");
@@ -430,9 +435,10 @@ public class ViewIndexIT extends ParallelStatsDisabledIT {
         Properties props = new Properties();
         Connection conn1 = DriverManager.getConnection(getUrl(), props);
         conn1.setAutoCommit(true);
-        String tableName=generateUniqueName();
-        String viewName=generateUniqueName();
-        String indexName=generateUniqueName();
+        String tableName = SchemaUtil.getTableName(SCHEMA1, generateUniqueName());
+        String viewName = SchemaUtil.getTableName(SCHEMA2, generateUniqueName());
+        String indexName = generateUniqueName();
+        String fullIndexName = SchemaUtil.getTableName(SCHEMA2, indexName);
         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')");
@@ -440,19 +446,21 @@ public class ViewIndexIT extends ParallelStatsDisabledIT {
           "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");
+        ResultSet rs = stmt.executeQuery("SELECT /*+ INDEX(" + viewName + " " + fullIndexName + ") */ v1 FROM " + viewName + " WHERE v3 = 'foo' ORDER BY v4");
         assertFalse(rs.next());
-        assertEquals(indexName, stmt.getQueryPlan().getContext().getCurrentTable().getTable().getName().getString());
+        assertEquals(fullIndexName, stmt.getQueryPlan().getContext().getCurrentTable().getTable().getName().getString());
     }
 
     @Test
     public void testCreatingIndexOnViewBuiltOnTableWithOnlyNamedColumnFamilies() throws Exception {
         try (Connection c = getConnection(); Statement s = c.createStatement()) {
-            String tableName = generateUniqueName();
-            String viewName = generateUniqueName();
-            String indexName = generateUniqueName();
-
+            String tableName = SchemaUtil.getTableName(SCHEMA1, generateUniqueName());
+            String viewName = SchemaUtil.getTableName(SCHEMA2, generateUniqueName());
+            String indexName=generateUniqueName();
             c.setAutoCommit(true);
+            if (isNamespaceMapped) {
+                c.createStatement().execute("CREATE SCHEMA IF NOT EXISTS " + SCHEMA1);
+            }
             s.execute("CREATE TABLE " + tableName + " (COL1 VARCHAR PRIMARY KEY, CF.COL2 VARCHAR)");
             s.executeUpdate("UPSERT INTO " + tableName + " VALUES ('AAA', 'BBB')");
             s.execute("CREATE VIEW " + viewName + " AS SELECT * FROM " + tableName);

http://git-wip-us.apache.org/repos/asf/phoenix/blob/d56fd3c9/phoenix-core/src/it/java/org/apache/phoenix/execute/PartialCommitIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/execute/PartialCommitIT.java b/phoenix-core/src/it/java/org/apache/phoenix/execute/PartialCommitIT.java
index 58dcceb..235f20f 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/execute/PartialCommitIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/execute/PartialCommitIT.java
@@ -28,6 +28,7 @@ import static org.junit.Assert.fail;
 
 import java.io.IOException;
 import java.sql.Connection;
+import java.sql.DriverManager;
 import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.sql.Statement;
@@ -61,6 +62,7 @@ import org.apache.phoenix.query.QueryServices;
 import org.apache.phoenix.schema.TableRef;
 import org.apache.phoenix.util.PhoenixRuntime;
 import org.apache.phoenix.util.ReadOnlyProps;
+import org.apache.phoenix.util.SchemaUtil;
 import org.junit.After;
 import org.junit.AfterClass;
 import org.junit.Before;
@@ -287,7 +289,7 @@ public class PartialCommitIT extends BaseOwnClusterIT {
         PhoenixConnection phxCon = new PhoenixConnection(con.unwrap(PhoenixConnection.class));
         final Map<TableRef, MultiRowMutationState> mutations = Maps.newTreeMap(new TableRefComparator());
         // passing a null mutation state forces the connection.newMutationState() to be used to create the MutationState
-        return new PhoenixConnection(phxCon, null) {
+        return new PhoenixConnection(phxCon, (MutationState)null) {
             @Override
             protected MutationState newMutationState(int maxSize, int maxSizeBytes) {
                 return new MutationState(maxSize, maxSizeBytes, this, mutations, false, null);

http://git-wip-us.apache.org/repos/asf/phoenix/blob/d56fd3c9/phoenix-core/src/it/java/org/apache/phoenix/replication/SystemCatalogWALEntryFilterIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/replication/SystemCatalogWALEntryFilterIT.java b/phoenix-core/src/it/java/org/apache/phoenix/replication/SystemCatalogWALEntryFilterIT.java
index ae8b797..85a677a 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/replication/SystemCatalogWALEntryFilterIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/replication/SystemCatalogWALEntryFilterIT.java
@@ -41,7 +41,6 @@ import org.apache.phoenix.mapreduce.util.ConnectionUtil;
 import org.apache.phoenix.schema.PTable;
 import org.apache.phoenix.util.PhoenixRuntime;
 import org.apache.phoenix.util.ReadOnlyProps;
-import org.apache.phoenix.util.SchemaUtil;
 import org.apache.phoenix.util.TestUtil;
 import org.junit.AfterClass;
 import org.junit.Assert;
@@ -127,63 +126,36 @@ public class SystemCatalogWALEntryFilterIT extends ParallelStatsDisabledIT {
 
     //now create WAL.Entry objects that refer to cells in those view rows in System.Catalog
 
-    Get tenantViewGet = getTenantViewGet(catalogTable, TENANT_BYTES, TENANT_VIEW_NAME);
-    Get nonTenantViewGet = getTenantViewGet(catalogTable,
-        DEFAULT_TENANT_BYTES, NONTENANT_VIEW_NAME);
+    Get tenantGet = getGet(catalogTable, TENANT_BYTES, TENANT_VIEW_NAME);
+    Get nonTenantGet = getGet(catalogTable, DEFAULT_TENANT_BYTES, NONTENANT_VIEW_NAME);
 
-    Get tenantLinkGet = getParentChildLinkGet(catalogTable, TENANT_BYTES, TENANT_VIEW_NAME);
-    Get nonTenantLinkGet = getParentChildLinkGet(catalogTable,
-        DEFAULT_TENANT_BYTES, NONTENANT_VIEW_NAME);
-
-    WAL.Entry nonTenantViewEntry = getEntry(systemCatalogTableName, nonTenantViewGet);
-    WAL.Entry tenantViewEntry = getEntry(systemCatalogTableName, tenantViewGet);
-
-    WAL.Entry nonTenantLinkEntry = getEntry(systemCatalogTableName, nonTenantLinkGet);
-    WAL.Entry tenantLinkEntry = getEntry(systemCatalogTableName, tenantLinkGet);
+    WAL.Entry nonTenantEntry = getEntry(systemCatalogTableName, nonTenantGet);
+    WAL.Entry tenantEntry = getEntry(systemCatalogTableName, tenantGet);
 
     //verify that the tenant view WAL.Entry passes the filter and the non-tenant view does not
     SystemCatalogWALEntryFilter filter = new SystemCatalogWALEntryFilter();
-    Assert.assertNull(filter.filter(nonTenantViewEntry));
-    WAL.Entry filteredTenantEntry = filter.filter(tenantViewEntry);
+    Assert.assertNull(filter.filter(nonTenantEntry));
+    WAL.Entry filteredTenantEntry = filter.filter(tenantEntry);
     Assert.assertNotNull("Tenant view was filtered when it shouldn't be!", filteredTenantEntry);
-    Assert.assertEquals(tenantViewEntry.getEdit().size(),
-        filter.filter(tenantViewEntry).getEdit().size());
+    Assert.assertEquals(tenantEntry.getEdit().size(),
+        filter.filter(tenantEntry).getEdit().size());
 
     //now check that a WAL.Entry with cells from both a tenant and a non-tenant
     //catalog row only allow the tenant cells through
     WALEdit comboEdit = new WALEdit();
-    comboEdit.getCells().addAll(nonTenantViewEntry.getEdit().getCells());
-    comboEdit.getCells().addAll(tenantViewEntry.getEdit().getCells());
+    comboEdit.getCells().addAll(nonTenantEntry.getEdit().getCells());
+    comboEdit.getCells().addAll(tenantEntry.getEdit().getCells());
     WAL.Entry comboEntry = new WAL.Entry(walKey, comboEdit);
 
-    Assert.assertEquals(tenantViewEntry.getEdit().size() + nonTenantViewEntry.getEdit().size()
+    Assert.assertEquals(tenantEntry.getEdit().size() + nonTenantEntry.getEdit().size()
         , comboEntry.getEdit().size());
-    Assert.assertEquals(tenantViewEntry.getEdit().size(),
+    Assert.assertEquals(tenantEntry.getEdit().size(),
         filter.filter(comboEntry).getEdit().size());
-
-    //now check that the parent-child links (which have the tenant_id of the view's parent,
-    // but are a part of the view's metadata) are migrated in the tenant case
-    // but not the non-tenant. The view's tenant_id is in th System.Catalog.COLUMN_NAME field
-
-    Assert.assertNull("Non-tenant parent-child link was not filtered " +
-        "when it should be!", filter.filter(nonTenantLinkEntry));
-    Assert.assertNotNull("Tenant parent-child link was filtered when it should not be!",
-        filter.filter(tenantLinkEntry));
-    Assert.assertEquals(tenantLinkEntry.getEdit().size(),
-        filter.filter(tenantLinkEntry).getEdit().size());
-    //add the parent-child link to the tenant view WAL entry,
-    //since they'll usually be together and they both need to
-    //be replicated
-
-    tenantViewEntry.getEdit().getCells().addAll(tenantLinkEntry.getEdit().getCells());
-    Assert.assertEquals(tenantViewEntry.getEdit().size(), tenantViewEntry.getEdit().size());
-
-
   }
 
-  public Get getTenantViewGet(PTable catalogTable, byte[] tenantBytes, String viewName) {
+  public Get getGet(PTable catalogTable, byte[] tenantId, String viewName) {
     byte[][] tenantKeyParts = new byte[5][];
-    tenantKeyParts[0] = tenantBytes;
+    tenantKeyParts[0] = tenantId;
     tenantKeyParts[1] = Bytes.toBytes(SCHEMA_NAME.toUpperCase());
     tenantKeyParts[2] = Bytes.toBytes(viewName.toUpperCase());
     tenantKeyParts[3] = Bytes.toBytes(VIEW_COLUMN_NAME);
@@ -195,28 +167,6 @@ public class SystemCatalogWALEntryFilterIT extends ParallelStatsDisabledIT {
     return new Get(key.copyBytes());
   }
 
-  public Get getParentChildLinkGet(PTable catalogTable, byte[] tenantBytes, String viewName) {
-    /* For parent-child link, the system.catalog key becomes
-      1. Parent tenant id
-      2. Parent Schema
-      3. Parent Table name
-      4. View tenant_id
-      5. Combined view SCHEMA.TABLENAME
-     */
-    byte[][] tenantKeyParts = new byte[5][];
-    tenantKeyParts[0] = null; //null tenant_id
-    tenantKeyParts[1] = null; //null parent schema
-    tenantKeyParts[2] = Bytes.toBytes(TestUtil.ENTITY_HISTORY_TABLE_NAME);
-    tenantKeyParts[3] = tenantBytes;
-    tenantKeyParts[4] = Bytes.toBytes(SchemaUtil.getTableName(SCHEMA_NAME.toUpperCase(), viewName.toUpperCase()));
-    ImmutableBytesWritable key = new ImmutableBytesWritable();
-    catalogTable.newKey(key, tenantKeyParts);
-    //the backing byte array of key might have extra space at the end.
-    // need to just slice "the good parts" which we do by calling copyBytes
-    return new Get(key.copyBytes());
-
-  }
-
   public WAL.Entry getEntry(TableName tableName, Get get) throws IOException {
     WAL.Entry entry = null;
     try(Connection conn = ConnectionFactory.createConnection(getUtility().getConfiguration())){

http://git-wip-us.apache.org/repos/asf/phoenix/blob/d56fd3c9/phoenix-core/src/it/java/org/apache/phoenix/rpc/UpdateCacheIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/rpc/UpdateCacheIT.java b/phoenix-core/src/it/java/org/apache/phoenix/rpc/UpdateCacheIT.java
index e6a2f7d..2211d58 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/rpc/UpdateCacheIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/rpc/UpdateCacheIT.java
@@ -41,6 +41,7 @@ import org.apache.phoenix.query.ConnectionQueryServices;
 import org.apache.phoenix.query.QueryConstants;
 import org.apache.phoenix.schema.MetaDataClient;
 import org.apache.phoenix.schema.PName;
+import org.apache.phoenix.schema.PTable;
 import org.apache.phoenix.schema.types.PVarchar;
 import org.apache.phoenix.util.PropertiesUtil;
 import org.apache.phoenix.util.SchemaUtil;
@@ -160,7 +161,9 @@ public class UpdateCacheIT extends ParallelStatsDisabledIT {
 			conn.commit();
             int numUpsertRpcs = expectedRPCs[0];
 			// verify only 0 or 1 rpc to fetch table metadata, 
-            verify(connectionQueryServices, times(numUpsertRpcs)).getTable((PName)isNull(), eq(PVarchar.INSTANCE.toBytes(schemaName)), eq(PVarchar.INSTANCE.toBytes(tableName)), anyLong(), anyLong());
+            verify(connectionQueryServices, times(numUpsertRpcs)).getTable((PName) isNull(),
+                eq(PVarchar.INSTANCE.toBytes(schemaName)), eq(PVarchar.INSTANCE.toBytes(tableName)),
+                anyLong(), anyLong(), eq(false), eq(false), (PTable)isNull());
             reset(connectionQueryServices);
             
             ResultSet rs = conn.createStatement().executeQuery(selectSql);
@@ -186,7 +189,9 @@ public class UpdateCacheIT extends ParallelStatsDisabledIT {
             // for transactional tables : verify *only* one rpc occurs
 	        // for non-transactional, system tables : verify no rpc occurs
             int numRpcs = expectedRPCs[1]; 
-            verify(connectionQueryServices, times(numRpcs)).getTable((PName)isNull(), eq(PVarchar.INSTANCE.toBytes(schemaName)), eq(PVarchar.INSTANCE.toBytes(tableName)), anyLong(), anyLong());
+            verify(connectionQueryServices, times(numRpcs)).getTable((PName) isNull(),
+                eq(PVarchar.INSTANCE.toBytes(schemaName)), eq(PVarchar.INSTANCE.toBytes(tableName)),
+                anyLong(), anyLong(), eq(false), eq(false), (PTable)isNull());
 		}
         finally {
         	conn.close();

http://git-wip-us.apache.org/repos/asf/phoenix/blob/d56fd3c9/phoenix-core/src/main/java/org/apache/phoenix/compile/ColumnNameTrackingExpressionCompiler.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/compile/ColumnNameTrackingExpressionCompiler.java b/phoenix-core/src/main/java/org/apache/phoenix/compile/ColumnNameTrackingExpressionCompiler.java
new file mode 100644
index 0000000..f1bba07
--- /dev/null
+++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/ColumnNameTrackingExpressionCompiler.java
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.phoenix.compile;
+
+import java.sql.SQLException;
+import java.util.List;
+
+import org.apache.phoenix.parse.ColumnParseNode;
+import org.apache.phoenix.parse.StatelessTraverseAllParseNodeVisitor;
+
+import com.google.common.collect.Lists;
+
+public class ColumnNameTrackingExpressionCompiler extends StatelessTraverseAllParseNodeVisitor {
+
+    private List<String> dataColumnNames = Lists.newArrayListWithExpectedSize(10);
+
+    public void reset() {
+        this.getDataColumnNames().clear();
+    }
+
+    @Override
+    public Void visit(ColumnParseNode node) throws SQLException {
+        getDataColumnNames().add(node.getName());
+        return null;
+    }
+
+    public List<String> getDataColumnNames() {
+        return dataColumnNames;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/phoenix/blob/d56fd3c9/phoenix-core/src/main/java/org/apache/phoenix/compile/CreateTableCompiler.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/compile/CreateTableCompiler.java b/phoenix-core/src/main/java/org/apache/phoenix/compile/CreateTableCompiler.java
index 4e5580a..d67899c 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/compile/CreateTableCompiler.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/CreateTableCompiler.java
@@ -204,7 +204,7 @@ public class CreateTableCompiler {
         };
     }
     
-    private static class ColumnTrackingExpressionCompiler extends ExpressionCompiler {
+    public static class ColumnTrackingExpressionCompiler extends ExpressionCompiler {
         private final BitSet isColumnReferenced;
         
         public ColumnTrackingExpressionCompiler(StatementContext context, BitSet isColumnReferenced) {

http://git-wip-us.apache.org/repos/asf/phoenix/blob/d56fd3c9/phoenix-core/src/main/java/org/apache/phoenix/compile/FromCompiler.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/compile/FromCompiler.java b/phoenix-core/src/main/java/org/apache/phoenix/compile/FromCompiler.java
index 1341ecc..285b549 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/compile/FromCompiler.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/FromCompiler.java
@@ -31,6 +31,9 @@ import org.apache.hadoop.hbase.client.Table;
 import org.apache.hadoop.hbase.util.Bytes;
 import org.apache.phoenix.coprocessor.MetaDataProtocol;
 import org.apache.phoenix.coprocessor.MetaDataProtocol.MetaDataMutationResult;
+import org.apache.phoenix.coprocessor.MetaDataProtocol.MutationCode;
+import org.apache.phoenix.exception.SQLExceptionCode;
+import org.apache.phoenix.exception.SQLExceptionInfo;
 import org.apache.phoenix.expression.Expression;
 import org.apache.phoenix.jdbc.PhoenixConnection;
 import org.apache.phoenix.parse.AliasedNode;
@@ -272,7 +275,8 @@ public class FromCompiler {
             Expression sourceExpression = projector.getColumnProjector(column.getPosition()).getExpression();
             PColumnImpl projectedColumn = new PColumnImpl(column.getName(), column.getFamilyName(),
                     sourceExpression.getDataType(), sourceExpression.getMaxLength(), sourceExpression.getScale(), sourceExpression.isNullable(),
-                    column.getPosition(), sourceExpression.getSortOrder(), column.getArraySize(), column.getViewConstant(), column.isViewReferenced(), column.getExpressionStr(), column.isRowTimestamp(), column.isDynamic(), column.getColumnQualifierBytes());
+                    column.getPosition(), sourceExpression.getSortOrder(), column.getArraySize(), column.getViewConstant(), column.isViewReferenced(), column.getExpressionStr(), column.isRowTimestamp(), column.isDynamic(), column.getColumnQualifierBytes(),
+                column.getTimestamp());
             projectedColumns.add(projectedColumn);
         }
         PTable t = PTableImpl.makePTable(table, projectedColumns);
@@ -573,8 +577,9 @@ public class FromCompiler {
                 MetaDataMutationResult result = client.updateCache(tenantId, schemaName, tableName, alwaysHitServer);
                 timeStamp = TransactionUtil.getResolvedTimestamp(connection, result);
                 theTable = result.getTable();
+                MutationCode mutationCode = result.getMutationCode();
                 if (theTable == null) {
-                    throw new TableNotFoundException(schemaName, tableName, timeStamp);
+					throw new TableNotFoundException(schemaName, tableName, timeStamp);
                 }
             } else {
                 try {
@@ -710,7 +715,8 @@ public class FromCompiler {
                         familyName = PNameFactory.newName(family);
                     }
                     allcolumns.add(new PColumnImpl(name, familyName, dynColumn.getDataType(), dynColumn.getMaxLength(),
-                            dynColumn.getScale(), dynColumn.isNull(), position, dynColumn.getSortOrder(), dynColumn.getArraySize(), null, false, dynColumn.getExpression(), false, true, Bytes.toBytes(dynColumn.getColumnDefName().getColumnName())));
+                            dynColumn.getScale(), dynColumn.isNull(), position, dynColumn.getSortOrder(), dynColumn.getArraySize(), null, false, dynColumn.getExpression(), false, true, Bytes.toBytes(dynColumn.getColumnDefName().getColumnName()),
+                        HConstants.LATEST_TIMESTAMP));
                     position++;
                 }
                 theTable = PTableImpl.makePTable(theTable, allcolumns);
@@ -815,7 +821,8 @@ public class FromCompiler {
                 PName name = PNameFactory.newName(alias);
                 PColumnImpl column = new PColumnImpl(PNameFactory.newName(alias),
                         PNameFactory.newName(QueryConstants.DEFAULT_COLUMN_FAMILY),
-                        null, 0, 0, true, position++, SortOrder.ASC, null, null, false, null, false, false, name.getBytes());
+                        null, 0, 0, true, position++, SortOrder.ASC, null, null, false, null, false, false, name.getBytes(),
+                    HConstants.LATEST_TIMESTAMP);
                 columns.add(column);
             }
             PTable t = PTableImpl.makePTable(null, PName.EMPTY_NAME, PName.EMPTY_NAME, PTableType.SUBQUERY, null,

http://git-wip-us.apache.org/repos/asf/phoenix/blob/d56fd3c9/phoenix-core/src/main/java/org/apache/phoenix/compile/ListJarsQueryPlan.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/compile/ListJarsQueryPlan.java b/phoenix-core/src/main/java/org/apache/phoenix/compile/ListJarsQueryPlan.java
index 2f149d7..d38f77d 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/compile/ListJarsQueryPlan.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/ListJarsQueryPlan.java
@@ -84,7 +84,7 @@ public class ListJarsQueryPlan implements QueryPlan {
         PColumn column =
                 new PColumnImpl(colName, null,
                         PVarchar.INSTANCE, null, null, false, 0, SortOrder.getDefault(), 0, null,
-                        false, null, false, false, colName.getBytes());
+                        false, null, false, false, colName.getBytes(), HConstants.LATEST_TIMESTAMP);
         List<PColumn> columns = new ArrayList<PColumn>();
         columns.add(column);
         Expression expression =

http://git-wip-us.apache.org/repos/asf/phoenix/blob/d56fd3c9/phoenix-core/src/main/java/org/apache/phoenix/compile/TraceQueryPlan.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/compile/TraceQueryPlan.java b/phoenix-core/src/main/java/org/apache/phoenix/compile/TraceQueryPlan.java
index 5a3a2ed..60178c8 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/compile/TraceQueryPlan.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/TraceQueryPlan.java
@@ -81,7 +81,7 @@ public class TraceQueryPlan implements QueryPlan {
         PColumn column =
                 new PColumnImpl(PNameFactory.newName(MetricInfo.TRACE.columnName), null,
                         PLong.INSTANCE, null, null, false, 0, SortOrder.getDefault(), 0, null,
-                        false, null, false, false, colName.getBytes());
+                        false, null, false, false, colName.getBytes(), HConstants.LATEST_TIMESTAMP);
         List<PColumn> columns = new ArrayList<PColumn>();
         columns.add(column);
         Expression expression =

http://git-wip-us.apache.org/repos/asf/phoenix/blob/d56fd3c9/phoenix-core/src/main/java/org/apache/phoenix/compile/UnionCompiler.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/compile/UnionCompiler.java b/phoenix-core/src/main/java/org/apache/phoenix/compile/UnionCompiler.java
index 9ca92f9..c94634b 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/compile/UnionCompiler.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/UnionCompiler.java
@@ -92,7 +92,7 @@ public class UnionCompiler {
                 UNION_FAMILY_NAME, targetTypes.get(i).getType(), targetTypes.get(i).getMaxLength(),
                 targetTypes.get(i).getScale(), colProj.getExpression().isNullable(), i,
                 targetTypes.get(i).getSortOrder(), 500, null, false,
-                colProj.getExpression().toString(), false, false, colName.getBytes());
+                colProj.getExpression().toString(), false, false, colName.getBytes(), HConstants.LATEST_TIMESTAMP);
             projectedColumns.add(projectedColumn);
         }
         Long scn = statement.getConnection().getSCN();

http://git-wip-us.apache.org/repos/asf/phoenix/blob/d56fd3c9/phoenix-core/src/main/java/org/apache/phoenix/compile/UpsertCompiler.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/compile/UpsertCompiler.java b/phoenix-core/src/main/java/org/apache/phoenix/compile/UpsertCompiler.java
index 6fd6e72..af4a1dc 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/compile/UpsertCompiler.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/UpsertCompiler.java
@@ -787,7 +787,7 @@ public class UpsertCompiler {
                 LinkedHashSet<PColumn> updateColumns = Sets.newLinkedHashSetWithExpectedSize(nColumns + 1);
                 updateColumns.add(new PColumnImpl(
                         table.getPKColumns().get(position).getName(), // Use first PK column name as we know it won't conflict with others
-                        null, PVarbinary.INSTANCE, null, null, false, position, SortOrder.getDefault(), 0, null, false, null, false, false, null));
+                        null, PVarbinary.INSTANCE, null, null, false, position, SortOrder.getDefault(), 0, null, false, null, false, false, null, table.getPKColumns().get(position).getTimestamp()));
                 position++;
                 for (Pair<ColumnName,ParseNode> columnPair : onDupKeyPairs) {
                     ColumnName colName = columnPair.getFirst();


Mime
View raw message