You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@phoenix.apache.org by "Gabriel Reid (JIRA)" <ji...@apache.org> on 2014/03/16 08:20:05 UTC

[jira] [Resolved] (PHOENIX-599) Data loss when primary key belongs to a column family

     [ https://issues.apache.org/jira/browse/PHOENIX-599?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Gabriel Reid resolved PHOENIX-599.
----------------------------------

    Resolution: Fixed

Bulk resolve of closed issues imported from GitHub. This status was reached by first re-opening all closed imported issues and then resolving them in bulk.

> Data loss when primary key belongs to a column family
> -----------------------------------------------------
>
>                 Key: PHOENIX-599
>                 URL: https://issues.apache.org/jira/browse/PHOENIX-599
>             Project: Phoenix
>          Issue Type: Task
>            Reporter: Pankaj Kumar
>
> Primary key should not belong to a column family. 
> This is restricted in table creation but the same can be achieved by specifying primary key as CONSTRAINT.
> Sql statement executed:
> 0: jdbc:phoenix:10.18.40.47> create table detail(cf1.id varchar,cf1.name varchar,cf2.address varchar constraint pk primary key(id));
> 0: jdbc:phoenix:10.18.40.47> upsert into detail values('ID1','Pankaj','Ranchi');
> 0: jdbc:phoenix:10.18.40.47> upsert into detail values('ID2','Pankaj','Ranchi');
> 0: jdbc:phoenix:10.18.40.47> upsert into detail values('ID3','Pankaj','Ranchi');
> 0: jdbc:phoenix:10.18.40.47> select * from detail;
> +------------+------------+------------+
> |     ID     |    NAME    |  ADDRESS   |
> +------------+------------+------------+
> | ID3        | Pankaj     | Ranchi     |
> +------------+------------+------------+
> 0: jdbc:phoenix:10.18.40.47>  create table detail_1(id varchar,cf1.name varchar,cf2.address varchar constraint pk primary key(id));
> 0: jdbc:phoenix:10.18.40.47> upsert into detail_1 values('ID1','Pankaj','Ranchi');
> 0: jdbc:phoenix:10.18.40.47> upsert into detail_1 values('ID2','Pankaj','Ranchi');
> 0: jdbc:phoenix:10.18.40.47> upsert into detail_1 values('ID3','Pankaj','Ranchi');
> 0: jdbc:phoenix:10.18.40.47> select * from detail_1;
> +------------+------------+------------+
> |     ID     |    NAME    |  ADDRESS   |
> +------------+------------+------------+
> | ID1        | Pankaj     | Ranchi     |
> | ID2        | Pankaj     | Ranchi     |
> | ID3        | Pankaj     | Ranchi     |
> +------------+------------+------------+
> 0: jdbc:phoenix:10.18.40.47>  create table detail_2(cf1.id varchar not null primary key,cf1.name varchar,cf2.address varchar);
> Error: ERROR 1003 (42J01): Primary key should not have a family name. columnName=CF1.ID (state=42J01,code=1003)
> 0: jdbc:phoenix:10.18.40.47>
>  
> In the above statements,
> Case 1: Primary key defined using Constraint 
>        DETAIL table is created with primary key ID which belongs to CF1. After  inserting 3 records, two records only fetched.
> Case 2: Primary key defined while defining column
>      DETAIL_1 table is created with primary key ID which do not belongs to any column family. After inserting 3 records, all records fetched.
> Case 3: Primary key defined while defining column
>    Creating of DETAIL_2 table is not allowed since it belongs to CF1.



--
This message was sent by Atlassian JIRA
(v6.2#6252)