sandeepvinayak commented on a change in pull request #569: PHOENIX-4743: ALTER 
TABLE ADD COLUMN for global index should not modify HBase metadata if failed
URL: https://github.com/apache/phoenix/pull/569#discussion_r317310583
 
 

 ##########
 File path: 
phoenix-core/src/it/java/org/apache/phoenix/end2end/AlterTableIT.java
 ##########
 @@ -852,6 +854,39 @@ public void testDropMultipleColumns() throws Exception {
         conn1.close();
     }
 
+    @Test
+    public void testAlterTableOnGlobalIndex() throws Exception {
+        try (Connection conn = DriverManager.getConnection(getUrl())) {
+            conn.setAutoCommit(false);
+            Admin admin = 
conn.unwrap(PhoenixConnection.class).getQueryServices().getAdmin();
+            Statement stmt = conn.createStatement();
+            String tableName = generateUniqueName();
+            String globalIndexTableName = generateUniqueName();
+
+            conn.createStatement().execute("CREATE TABLE " + tableName +
+                " (ID INTEGER PRIMARY KEY, COL1 VARCHAR(10), COL2 BOOLEAN)");
+
+            conn.createStatement().execute("CREATE INDEX " + 
globalIndexTableName + " on " + tableName + " (COL2)");
+            TableDescriptor originalDesc = 
admin.getDescriptor(TableName.valueOf(globalIndexTableName));
+            int expectedErrorCode = 0;
+            try {
+                conn.createStatement().execute("ALTER TABLE " + 
globalIndexTableName + " ADD CF1.AGE INTEGER ");
+                conn.commit();
+                fail("The alter table did not fail as expected");
+            } catch (SQLException e) {
+                assertEquals(e.getErrorCode(), 
CANNOT_MUTATE_TABLE.getErrorCode());
+            }
+
+            TableDescriptor finalDesc = 
admin.getDescriptor(TableName.valueOf(globalIndexTableName));
+            assertTrue(finalDesc.equals(originalDesc));
+
+            // remove the table
+            stmt.execute("DROP TABLE " + tableName);
+            admin.disableTable(TableName.valueOf(tableName));
 
 Review comment:
   @ChinmaySKulkarni In tests, I saw the pattern of disabling and deleting even 
after dropping the table. Does the drop perform all the operations the delete 
does ? I can remove it for sure

----------------------------------------------------------------
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