phoenix-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [phoenix] gokceni commented on a change in pull request #499: Phoenix-5272 ALTER INDEX REBUILD ALL
Date Tue, 28 May 2019 23:28:29 GMT
gokceni commented on a change in pull request #499: Phoenix-5272 ALTER INDEX REBUILD ALL 
URL: https://github.com/apache/phoenix/pull/499#discussion_r288340920
 
 

 ##########
 File path: phoenix-core/src/it/java/org/apache/phoenix/end2end/index/IndexMetadataIT.java
 ##########
 @@ -610,7 +615,86 @@ public void testAsyncRebuildTimestamp() throws Exception {
                 "order by table_name" );
         assertFalse(rs.next());
     }
-    
+
+    @Test
+    public void testAsyncRebuildAll() throws Exception {
+        Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
+        try (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 INDEX " + indexName + " ON " + testTable + " REBUILD ALL ASYNC");
+
+            String
+                    queryTaskTable =
+                    "SELECT * FROM " + SchemaUtil.getTableName(SYSTEM_CATALOG_SCHEMA,
+                            PhoenixDatabaseMetaData.SYSTEM_TASK_TABLE);
+            ResultSet rs = conn.createStatement().executeQuery(queryTaskTable);
 
 Review comment:
   done

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message