phoenix-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [phoenix] swaroopak commented on a change in pull request #514: PHOENIX-5261: Implement ALTER TABLE/VIEW ADD COLUMN CASCADE
Date Mon, 10 Jun 2019 17:18:46 GMT
swaroopak 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_r292104788
 
 

 ##########
 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:
   Good catch! Thank you for noticing. 

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