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

Sergey Soldatov edited comment on PHOENIX-4068 at 8/11/17 5:09 AM:
-------------------------------------------------------------------

That happens because we don't take in account that for salted tables the first 
primary key column is the salting one. Added couple checks as well as a test 
case. 
[~jamestaylor] could you please take a look.


was (Author: sergey.soldatov):
That happens because we don't take in account that for salted tables the first 
primary key column is the salting one. Added couple checks as well as a test 
case. 

> Atomic Upsert salted table with error(java.lang.NullPointerException).
> ----------------------------------------------------------------------
>
>                 Key: PHOENIX-4068
>                 URL: https://issues.apache.org/jira/browse/PHOENIX-4068
>             Project: Phoenix
>          Issue Type: Bug
>    Affects Versions: 4.10.0
>         Environment: CentOS release 6.5 (Final)
> java version "1.8.0_91"
> Java(TM) SE Runtime Environment (build 1.8.0_91-b14)
> Java HotSpot(TM) 64-Bit Server VM (build 25.91-b14, mixed mode)
> Hbase 1.1
>            Reporter: tian.yang
>            Assignee: Sergey Soldatov
>         Attachments: PHOENIX-4068-1.patch
>
>
> 0: jdbc:phoenix:> drop table MY_TABLE;
> No rows affected (4.635 seconds)
> 0: jdbc:phoenix:> create table my_table(id varchar not null,id1 varchar not 
> null, counter1 bigint, counter2 bigint CONSTRAINT pk PRIMARY KEY (id,id1));
> No rows affected (2.365 seconds)
> 0: jdbc:phoenix:> UPSERT INTO my_table(id,id1, counter1, counter2) VALUES 
> ('abc','123', 0, 0) ON DUPLICATE KEY UPDATE counter1 = counter1 + 1, counter2 
> = counter2 + 1;
> 1 row affected (0.024 seconds)
> 0: jdbc:phoenix:> drop table MY_TABLE;
> No rows affected (4.62 seconds)
> 0: jdbc:phoenix:> create table my_table(id varchar not null,id1 varchar not 
> null, counter1 bigint, counter2 bigint CONSTRAINT pk PRIMARY KEY 
> (id,id1))SALT_BUCKETS = 6;
> No rows affected (4.378 seconds)
> 0: jdbc:phoenix:> UPSERT INTO my_table(id,id1, counter1, counter2) VALUES 
> ('abc','123', 0, 0) ON DUPLICATE KEY UPDATE counter1 = counter1 + 1, counter2 
> = counter2 + 1;
> java.lang.NullPointerException: at index 3
>         at 
> com.google.common.collect.ObjectArrays.checkElementNotNull(ObjectArrays.java:191)
>         at 
> com.google.common.collect.ImmutableList.construct(ImmutableList.java:320)
>         at 
> com.google.common.collect.ImmutableList.copyOf(ImmutableList.java:290)
>         at org.apache.phoenix.schema.PTableImpl.init(PTableImpl.java:534)
>         at org.apache.phoenix.schema.PTableImpl.<init>(PTableImpl.java:408)
>         at 
> org.apache.phoenix.schema.PTableImpl.makePTable(PTableImpl.java:287)
>         at 
> org.apache.phoenix.compile.UpsertCompiler.compile(UpsertCompiler.java:979)
>         at 
> org.apache.phoenix.jdbc.PhoenixStatement$ExecutableUpsertStatement.compilePlan(PhoenixStatement.java:611)
>         at 
> org.apache.phoenix.jdbc.PhoenixStatement$ExecutableUpsertStatement.compilePlan(PhoenixStatement.java:597)
>         at 
> org.apache.phoenix.jdbc.PhoenixStatement$2.call(PhoenixStatement.java:351)
>         at 
> org.apache.phoenix.jdbc.PhoenixStatement$2.call(PhoenixStatement.java:341)
>         at org.apache.phoenix.call.CallRunner.run(CallRunner.java:53)
>         at 
> org.apache.phoenix.jdbc.PhoenixStatement.executeMutation(PhoenixStatement.java:339)
>         at 
> org.apache.phoenix.jdbc.PhoenixStatement.execute(PhoenixStatement.java:1511)
>         at sqlline.Commands.execute(Commands.java:822)
>         at sqlline.Commands.sql(Commands.java:732)
>         at sqlline.SqlLine.dispatch(SqlLine.java:813)
>         at sqlline.SqlLine.begin(SqlLine.java:686)
>         at sqlline.SqlLine.start(SqlLine.java:398)
>         at sqlline.SqlLine.main(SqlLine.java:291)
> 0: jdbc:phoenix:>



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to