ChinmaySKulkarni commented on a change in pull request #541: PHOENIX-4893 Move 
parent column combining logic of view and view inde…
URL: https://github.com/apache/phoenix/pull/541#discussion_r305164974
 
 

 ##########
 File path: 
phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataEndpointImpl.java
 ##########
 @@ -2982,22 +2516,54 @@ MetaDataMutationResult updateMutation(PTable table, 
byte[][] rowKeyMetaData,
                     return new 
MetaDataMutationResult(MutationCode.UNALLOWED_TABLE_MUTATION,
                             EnvironmentEdgeManager.currentTimeMillis(), null);
                 } else {
-                    // server-side, except for indexing, we always expect the 
keyvalues to be standard KeyValues
-                    PTableType expectedType = 
MetaDataUtil.getTableType(tableMetadata, GenericKeyValueBuilder.INSTANCE,
-                            new ImmutableBytesWritable());
                     // We said to drop a table, but found a view or visa versa
-                    if (type != expectedType) { return new 
MetaDataMutationResult(MutationCode.TABLE_NOT_FOUND,
-                            EnvironmentEdgeManager.currentTimeMillis(), null); 
}
+                    if (type != expectedType) {
+                        return new 
MetaDataMutationResult(MutationCode.TABLE_NOT_FOUND,
+                                EnvironmentEdgeManager.currentTimeMillis(), 
null);
+                    }
                 }
-                result = mutator.updateMutation(table, rowKeyMetaData, 
tableMetadata, region,
-                            invalidateList, locks, clientTimeStamp);
+
+                if (!childViews.isEmpty()) {
+                    // validate the add or drop column mutations
+                    result = mutator.validateWithChildViews(table, childViews, 
tableMetadata, schemaName, tableName);
+                    if (result != null) {
+                        return result;
+                    }
+                }
+
+                getCoprocessorHost().preAlterTable(Bytes.toString(tenantId),
+                        SchemaUtil.getTableName(schemaName, tableName),
+                        TableName.valueOf(table.getPhysicalName().getBytes()),
+                        getParentPhysicalTableName(table), table.getType());
+
+                result = mutator.validateAndAddMetadata(table, rowKeyMetaData, 
tableMetadata, region,
+                        invalidateList, locks, clientTimeStamp);
                 // if the update mutation caused tables to be deleted, the 
mutation code returned
                 // will be MutationCode.TABLE_ALREADY_EXISTS
                 if (result != null
                         && result.getMutationCode() != 
MutationCode.TABLE_ALREADY_EXISTS) {
                     return result;
                 }
 
+                // drop any indexes on the base table othat need the column 
that is going to be dropped
 
 Review comment:
   nit: typo "othat"

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