gjacoby126 commented on a change in pull request #499: Phoenix 4703 ALTER INDEX 
REBUILD ALL 
URL: https://github.com/apache/phoenix/pull/499#discussion_r281388622
 
 

 ##########
 File path: 
phoenix-core/src/it/java/org/apache/phoenix/end2end/index/IndexMetadataIT.java
 ##########
 @@ -610,7 +613,84 @@ public void testAsyncRebuildTimestamp() throws Exception {
                 "order by table_name" );
         assertFalse(rs.next());
     }
-    
+
+    @Test
+    public void testAsyncRebuildAll() throws Exception {
+        Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
+        Connection conn = DriverManager.getConnection(getUrl(), props);
+        conn.setAutoCommit(true);
+        String testTable = generateUniqueName();
+
+
+        String ddl = "create table " + testTable  + " (k varchar primary key, 
v4 varchar)";
+        Statement stmt = conn.createStatement();
+        stmt.execute(ddl);
+
+        PreparedStatement upsertStmt = conn.prepareStatement("UPSERT INTO " + 
testTable + " VALUES(?, ?)");
+        upsertStmt.setString(1, "key1");
+        upsertStmt.setString(2, "val1");
+        upsertStmt.execute();
+
+        String indexName = "R_ASYNCIND_" + generateUniqueName();
+        ddl = "CREATE INDEX " + indexName + " ON " + testTable  + " (k, v4)";
+        stmt.execute(ddl);
+
+        // Check that index value is same as table
+        String val = getIndexValue(conn, indexName, 2);
+        assertEquals("val1", val);
+
+        // Update index value, check that index value is still not updated
+        conn.createStatement().execute("ALTER INDEX "+indexName+" ON " + 
testTable +" DISABLE");
+        upsertStmt = conn.prepareStatement("UPSERT INTO " + testTable + " 
VALUES(?, ?)");
+        upsertStmt.setString(1, "key1");
+        upsertStmt.setString(2, "val2");
+        upsertStmt.execute();
+        conn.commit();
+
+        val = getIndexValue(conn, indexName, 2);
+        assertEquals("val1", val);
+
+        // Add extra row to Index
+        upsertStmt = conn.prepareStatement("UPSERT INTO " + indexName + " 
VALUES(?, ?)");
+        upsertStmt.setString(1, "key3");
+        upsertStmt.setString(2, "val3");
+        upsertStmt.execute();
+
+        //conn.createStatement().execute("ALTER TABLE "+ testTable +" ADD V41 
INTEGER");
+        conn.createStatement().execute("ALTER INDEX "+indexName+" ON " + 
testTable +" REBUILD ALL ASYNC");
+
+        Table systemHTable= 
conn.unwrap(PhoenixConnection.class).getQueryServices()
 
 Review comment:
   Rather than counting rows in the task table (which could be brittle, 
especially if we want to run tests in parallel) could we check for the actual 
task?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to