[ 
https://issues.apache.org/jira/browse/PHOENIX-2058?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14615951#comment-14615951
 ] 

Thomas D'Silva commented on PHOENIX-2058:
-----------------------------------------

[~jamestaylor]

I didn't have to check check which columns were being added to the 
viewColumnDefinitionPut because later on we explicity update the positions of 
the view columns

{code}
for (PColumn column : view.getColumns()) {
                if (column.getPosition() >= oldBaseColumnCount) {
                    int newPosition = column.getPosition() + numColsAddedToView 
+ 1;

                    byte[] k = ByteUtil.concat(viewKey, 
QueryConstants.SEPARATOR_BYTE_ARRAY, column.getName()
                            .getBytes());
                    if (column.getFamilyName() != null) {
                        k = ByteUtil.concat(k, 
QueryConstants.SEPARATOR_BYTE_ARRAY, column.getFamilyName().getBytes());
                    }

                    Put positionUpdatePut = new Put(k, clientTimeStamp);
                    byte[] ptr = new byte[PInteger.INSTANCE.getByteSize()];
                    PInteger.INSTANCE.getCodec().encodeInt(newPosition, ptr, 0);
                    
positionUpdatePut.add(PhoenixDatabaseMetaData.TABLE_FAMILY_BYTES,
                            PhoenixDatabaseMetaData.ORDINAL_POSITION_BYTES, 
clientTimeStamp, ptr);
                    mutationsForAddingColumnsToViews.add(positionUpdatePut);
                }
            }
{code}

I am working on adding a test that test adding a pk column that already exists 
in the view to the base table.

> Check for existence and compatibility of columns being added in view
> --------------------------------------------------------------------
>
>                 Key: PHOENIX-2058
>                 URL: https://issues.apache.org/jira/browse/PHOENIX-2058
>             Project: Phoenix
>          Issue Type: Bug
>            Reporter: James Taylor
>            Assignee: Thomas D'Silva
>         Attachments: PHOENIX-2058-WIP.patch, PHOENIX-2058.wip.2.patch
>
>
> One check I realized we're not doing, but need to do, is ensuring that the 
> column being added by the base table doesn't already exist in the view. If 
> the column does already exist, ideally we can allow the addition to the base 
> table if the type matches and the scale is null or >= existing scale and the 
> maxLength is null or >= existing maxLength. Also, if a column is a PK column 
> and it already exists in the view, the position in the PK must match. 
> The fact that we've materialized a PTable for the view should make the 
> addition of this check easier.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to