ChinmaySKulkarni commented on a change in pull request #929:
URL: https://github.com/apache/phoenix/pull/929#discussion_r507923226



##########
File path: 
phoenix-core/src/it/java/org/apache/phoenix/end2end/index/ViewIndexIT.java
##########
@@ -169,10 +171,67 @@ public void testDeleteViewIndexSequences() throws 
Exception {
         verifySequenceValue(null, sequenceName, sequenceSchemaName, 
Short.MIN_VALUE + 2);
         conn1.createStatement().execute("DROP VIEW " + fullViewName);
         conn1.createStatement().execute("DROP TABLE "+ fullTableName);
-        
+
         verifySequenceNotExists(null, sequenceName, sequenceSchemaName);
     }
-    
+
+    @Test
+    public void testDroppingColumnWhileCreatingIndex2() throws Exception {
+        String schemaName = "S1";
+        String tableName = generateUniqueName();
+        String viewSchemaName = "S1";
+        String fullTableName = SchemaUtil.getTableName(schemaName, tableName);
+        String indexName = "IND_" + generateUniqueName();
+        String viewName = "VIEW_" + generateUniqueName();
+        String fullViewName = SchemaUtil.getTableName(viewSchemaName, 
viewName);
+
+        createBaseTable(schemaName, tableName, false, null, null, true);
+        Connection conn = getConnection();
+        conn.setAutoCommit(true);
+        conn.createStatement().execute("CREATE VIEW " + fullViewName + " AS 
SELECT * FROM " + fullTableName);
+        conn.commit();
+
+        final String[] failedMsg = new String[1];
+        final CountDownLatch doneSignal = new CountDownLatch(2);
+        Runnable r1 = new Runnable() {
+
+            @Override public void run() {
+                try {
+                    conn.createStatement().execute("CREATE INDEX " + indexName 
+ " ON " + fullViewName + " (v1)");
+                } catch (SQLException e) {
+                    failedMsg[0] = e.getMessage();

Review comment:
       nit: Can we store and hence later assert the SQLException code rather 
than the exception message?

##########
File path: 
phoenix-core/src/it/java/org/apache/phoenix/end2end/index/ViewIndexIT.java
##########
@@ -169,10 +171,67 @@ public void testDeleteViewIndexSequences() throws 
Exception {
         verifySequenceValue(null, sequenceName, sequenceSchemaName, 
Short.MIN_VALUE + 2);
         conn1.createStatement().execute("DROP VIEW " + fullViewName);
         conn1.createStatement().execute("DROP TABLE "+ fullTableName);
-        
+
         verifySequenceNotExists(null, sequenceName, sequenceSchemaName);
     }
-    
+
+    @Test
+    public void testDroppingColumnWhileCreatingIndex2() throws Exception {
+        String schemaName = "S1";
+        String tableName = generateUniqueName();
+        String viewSchemaName = "S1";
+        String fullTableName = SchemaUtil.getTableName(schemaName, tableName);
+        String indexName = "IND_" + generateUniqueName();
+        String viewName = "VIEW_" + generateUniqueName();
+        String fullViewName = SchemaUtil.getTableName(viewSchemaName, 
viewName);
+
+        createBaseTable(schemaName, tableName, false, null, null, true);
+        Connection conn = getConnection();

Review comment:
       nit: try-with-resources for the connection

##########
File path: 
phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java
##########
@@ -1689,12 +1689,13 @@ public MutationState createIndex(CreateIndexStatement 
statement, byte[][] splits
                 for (ColumnName colName : requiredCols) {
                     // acquire the mutex using the global physical table name 
to
                     // prevent this column from being dropped while the index 
is being created
+                    String colNameSeparatedByDot = 
colName.getColumnName().replace(':', '.');

Review comment:
       Good to either extract this out as a SchemaUtil API and/or add a comment 
here. Is there some existing API which makes the indexed column name have a ':' 
instead of '.'?




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


Reply via email to