priyankporwal commented on a change in pull request #514: PHOENIX-5261:
Implement ALTER TABLE/VIEW ADD COLUMN CASCADE
URL: https://github.com/apache/phoenix/pull/514#discussion_r291379571
##########
File path:
phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java
##########
@@ -3693,6 +3704,26 @@ public MutationState addColumn(PTable table,
List<ColumnDef> origColumnDefs,
.setTableName(tableName).build().buildException();
}
PColumn column = newColumn(position++, colDef,
PrimaryKeyConstraint.EMPTY, table.getDefaultFamilyName() == null ? null :
table.getDefaultFamilyName().getString(), true, columnQualifierBytes,
willBeImmutableRows);
+ HashMap<PTable, PColumn> indexColumn = null;
+ if (cascade) {
+ if (colDef.isPK()) {
+ //only supported for non pk column
+ throw new SQLExceptionInfo.Builder(
+
SQLExceptionCode.NOT_SUPPORTED_CASCADE_FEATURE_PK)
+ .build()
+ .buildException();
+ }
+ indexColumn = new
HashMap(indexesPTable.size());
+ for (PTable index : indexesPTable) {
+ int iPos = index.getColumns().size();
+ PDataType indexColDataType =
IndexUtil.getIndexColumnDataType(colDef.isNull(), colDef.getDataType());
+ ColumnName indexColName =
ColumnName.caseSensitiveColumnName(IndexUtil.getIndexColumnName(familyName,
colDef.getColumnDefName().getColumnName()));
+ ColumnDef indexColDef =
FACTORY.columnDef(indexColName, indexColDataType.getSqlTypeName(),
colDef.isNull(), colDef.getMaxLength(), colDef.getScale(), false,
colDef.getSortOrder(), colDef.getExpression(), colDef.isRowTimestamp());
+ PColumn iColumn = newColumn(iPos,
indexColDef, null, "", false, null, willBeImmutableRows);
Review comment:
Nit: These 3 are stmts (3719-3721) can be outside of the for loop
----------------------------------------------------------------
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