Github user JamesRTaylor commented on a diff in the pull request: https://github.com/apache/phoenix/pull/248#discussion_r116625769 --- Diff: phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataEndpointImpl.java --- @@ -2324,96 +2488,97 @@ else if (pkCount <= COLUMN_NAME_INDEX if (ordinalPos >= newOrdinalPosition) { if (ordinalPos == existingOrdinalPos) { /* - * No need to update ordinal positions of columns beyond the existing column's + * No need to update ordinal positions of columns beyond the existing column's * old ordinal position. */ break; } // increment ordinal position of columns occurring after this column by 1 int updatedPos = ordinalPos + 1; ordinalPositionList.addColumn(getColumnKey(viewKey, col), updatedPos); - } + } } - } + } } else { if (existingOrdinalPos != newOrdinalPosition) { ordinalPositionList.addColumn(columnKey, newOrdinalPosition); } } columnsAddedToBaseTable++; } - } else { - // The column doesn't exist in the view. - Put viewColumnPut = new Put(columnKey, clientTimeStamp); - for (Cell cell : baseTableColumnPut.getFamilyCellMap().values().iterator().next()) { - viewColumnPut.add(CellUtil.createCell(columnKey, CellUtil.cloneFamily(cell), - CellUtil.cloneQualifier(cell), cell.getTimestamp(), cell.getTypeByte(), - CellUtil.cloneValue(cell))); - } - if (isDivergedView(view)) { - if (isPkCol) { - /* - * Only pk cols of the base table are added to the diverged views. These pk - * cols are added at the end. - */ - int lastOrdinalPos = getOrdinalPosition(view, view.getColumns().get(numCols - 1)); - int newPosition = ++lastOrdinalPos; - byte[] ptr = new byte[PInteger.INSTANCE.getByteSize()]; - PInteger.INSTANCE.getCodec().encodeInt(newPosition, ptr, 0); - viewColumnPut.add(PhoenixDatabaseMetaData.TABLE_FAMILY_BYTES, - PhoenixDatabaseMetaData.ORDINAL_POSITION_BYTES, clientTimeStamp, ptr); - mutationsForAddingColumnsToViews.add(viewColumnPut); - } else { - continue; // move on to the next column - } - } else { - int newOrdinalPosition = p.ordinalPosition; - /* - * For a non-diverged view, we need to make sure that the base table column - * is added at the right position. - */ - if (ordinalPositionList.size() == 0) { - ordinalPositionList.setOffset(newOrdinalPosition); - ordinalPositionList.addColumn(columnKey, newOrdinalPosition); - for (PColumn col : view.getColumns()) { - int ordinalPos = getOrdinalPosition(view, col); - if (ordinalPos >= newOrdinalPosition) { - // increment ordinal position of columns by 1 - int updatedPos = ordinalPos + 1; - ordinalPositionList.addColumn(getColumnKey(viewKey, col), updatedPos); - } - } - } else { - ordinalPositionList.addColumn(columnKey, newOrdinalPosition); - } - mutationsForAddingColumnsToViews.add(viewColumnPut); - } - if (isPkCol) { - deltaNumPkColsSoFar++; - // Set the key sequence for the pk column to be added - short currentKeySeq = SchemaUtil.getMaxKeySeq(view); - short newKeySeq = (short)(currentKeySeq + deltaNumPkColsSoFar); - byte[] keySeqBytes = new byte[PSmallint.INSTANCE.getByteSize()]; - PSmallint.INSTANCE.getCodec().encodeShort(newKeySeq, keySeqBytes, 0); - viewColumnPut.add(PhoenixDatabaseMetaData.TABLE_FAMILY_BYTES, - PhoenixDatabaseMetaData.KEY_SEQ_BYTES, keySeqBytes); - addMutationsForAddingPkColsToViewIndexes(mutationsForAddingColumnsToViews, clientTimeStamp, view, - deltaNumPkColsSoFar, columnName, viewColumnPut); - } - columnsAddedToView++; - columnsAddedToBaseTable++; } +// else { --- End diff -- You'll likely get to this later, but let's remove the commented out code when you're ready.
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---