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

Julian Jaffe edited comment on PHOENIX-2301 at 10/8/15 12:14 AM:
-----------------------------------------------------------------

This bug also applies to the BINARY type:

{code:SQL}
0: jdbc:phoenix:xxxxxx> CREATE TABLE IF NOT EXISTS TEST.TEST("testBinArray" 
BINARY(3)[] constraint "test_pk" PRIMARY KEY ("testBinArray")) 
DEFAULT_COLUMN_FAMILY='TT', SALT_BUCKETS=10;
No rows affected (1.16 seconds)
0: jdbc:phoenix:xxxxxx> UPSERT INTO TEST.TEST VALUES(ARRAY[1, 0]);
java.lang.NullPointerException
        at 
org.apache.phoenix.schema.types.PArrayDataType.createPhoenixArray(PArrayDataType.java:1123)
        at 
org.apache.phoenix.schema.types.PArrayDataType.toObject(PArrayDataType.java:338)
        at 
org.apache.phoenix.schema.types.PBinaryArray.toObject(PBinaryArray.java:63)
        at 
org.apache.phoenix.schema.types.PDataType.toObject(PDataType.java:967)
        at 
org.apache.phoenix.schema.types.PDataType.toObject(PDataType.java:1008)
        at 
org.apache.phoenix.schema.types.PDataType.toObject(PDataType.java:1004)
        at org.apache.phoenix.util.SchemaUtil.toString(SchemaUtil.java:381)
        at org.apache.phoenix.schema.PTableImpl.newKey(PTableImpl.java:572)
        at 
org.apache.phoenix.compile.UpsertCompiler.setValues(UpsertCompiler.java:117)
        at 
org.apache.phoenix.compile.UpsertCompiler.access$400(UpsertCompiler.java:98)
        at 
org.apache.phoenix.compile.UpsertCompiler$3.execute(UpsertCompiler.java:821)
        at 
org.apache.phoenix.jdbc.PhoenixStatement$2.call(PhoenixStatement.java:319)
        at 
org.apache.phoenix.jdbc.PhoenixStatement$2.call(PhoenixStatement.java:311)
        at org.apache.phoenix.call.CallRunner.run(CallRunner.java:53)
        at 
org.apache.phoenix.jdbc.PhoenixStatement.executeMutation(PhoenixStatement.java:309)
        at 
org.apache.phoenix.jdbc.PhoenixStatement.execute(PhoenixStatement.java:1432)
        at sqlline.Commands.execute(Commands.java:822)
        at sqlline.Commands.sql(Commands.java:732)
        at sqlline.SqlLine.dispatch(SqlLine.java:808)
        at sqlline.SqlLine.begin(SqlLine.java:681)
        at sqlline.SqlLine.start(SqlLine.java:398)
        at sqlline.SqlLine.main(SqlLine.java:292)
0: jdbc:phoenix:xxxxxx> SELECT * FROM TEST.TEST;
+--------------+
| testBinArray |
+--------------+
+--------------+
No rows selected (0.179 seconds)
{code}.

It appears to be due to the fact that both PChar and PBinary return true for 
isFixedWidth() but null for getByteSize(), while all other fixed-width types 
return a byteSize.


was (Author: jja...@marinsoftware.com):
This bug also applies to the BINARY type:

{code:SQL}
0: jdbc:phoenix:xxxxxx> CREATE TABLE IF NOT EXISTS TEST.TEST("testBinArray" 
BINARY(3)[] constraint "test_pk" PRIMARY KEY ("testBinArray")) 
DEFAULT_COLUMN_FAMILY='TT', SALT_BUCKETS=10;
No rows affected (1.16 seconds)
0: jdbc:phoenix:xxxxxx> UPSERT INTO TEST.TEST VALUES(ARRAY[1, 0]);
java.lang.NullPointerException
        at 
org.apache.phoenix.schema.types.PArrayDataType.createPhoenixArray(PArrayDataType.java:1123)
        at 
org.apache.phoenix.schema.types.PArrayDataType.toObject(PArrayDataType.java:338)
        at 
org.apache.phoenix.schema.types.PBinaryArray.toObject(PBinaryArray.java:63)
        at 
org.apache.phoenix.schema.types.PDataType.toObject(PDataType.java:967)
        at 
org.apache.phoenix.schema.types.PDataType.toObject(PDataType.java:1008)
        at 
org.apache.phoenix.schema.types.PDataType.toObject(PDataType.java:1004)
        at org.apache.phoenix.util.SchemaUtil.toString(SchemaUtil.java:381)
        at org.apache.phoenix.schema.PTableImpl.newKey(PTableImpl.java:572)
        at 
org.apache.phoenix.compile.UpsertCompiler.setValues(UpsertCompiler.java:117)
        at 
org.apache.phoenix.compile.UpsertCompiler.access$400(UpsertCompiler.java:98)
        at 
org.apache.phoenix.compile.UpsertCompiler$3.execute(UpsertCompiler.java:821)
        at 
org.apache.phoenix.jdbc.PhoenixStatement$2.call(PhoenixStatement.java:319)
        at 
org.apache.phoenix.jdbc.PhoenixStatement$2.call(PhoenixStatement.java:311)
        at org.apache.phoenix.call.CallRunner.run(CallRunner.java:53)
        at 
org.apache.phoenix.jdbc.PhoenixStatement.executeMutation(PhoenixStatement.java:309)
        at 
org.apache.phoenix.jdbc.PhoenixStatement.execute(PhoenixStatement.java:1432)
        at sqlline.Commands.execute(Commands.java:822)
        at sqlline.Commands.sql(Commands.java:732)
        at sqlline.SqlLine.dispatch(SqlLine.java:808)
        at sqlline.SqlLine.begin(SqlLine.java:681)
        at sqlline.SqlLine.start(SqlLine.java:398)
        at sqlline.SqlLine.main(SqlLine.java:292)
0: jdbc:phoenix:xxxxxx> SELECT * FROM TEST.TEST;
+--------------+
| testBinArray |
+--------------+
+--------------+
No rows selected (0.179 seconds)
{code}.

It appears to be due to the fact that both PChar and PBinary return true for 
isFixedWidth() but null for getByteSize(), while all other non-array types 
return a byteSize.

> NullPointerException when upserting into a char array column
> ------------------------------------------------------------
>
>                 Key: PHOENIX-2301
>                 URL: https://issues.apache.org/jira/browse/PHOENIX-2301
>             Project: Phoenix
>          Issue Type: Bug
>    Affects Versions: 4.5.2
>            Reporter: Julian Jaffe
>
> Attempting to upsert into a char array causes an NPE. Minimum example:
> {code:sql}
> 0: jdbc:phoenix:xxxxxx> CREATE TABLE IF NOT EXISTS TEST("testIntArray" 
> INTEGER[], CONSTRAINT "test_pk" PRIMARY KEY("testIntArray")) 
> DEFAULT_COLUMN_FAMILY='T';
> No rows affected (1.28 seconds)
> 0: jdbc:phoenix:xxxxxx> UPSERT INTO TEST VALUES (ARRAY[1, 2, 3]);
> 1 row affected (0.184 seconds)
> 0: jdbc:phoenix:xxxxxx> SELECT * FROM TEST;
> +------------------------------------------+
> |               testIntArray               |
> +------------------------------------------+
> | [1, 2, 3]                                |
> +------------------------------------------+
> 1 row selected (0.308 seconds)
> 0: jdbc:phoenix:xxxxxx> DROP TABLE IF EXISTS TEST;
> No rows affected (3.348 seconds)
> 0: jdbc:phoenix:xxxxxx> CREATE TABLE IF NOT EXISTS TEST("testCharArray" 
> CHAR(3)[], CONSTRAINT "test_pk" PRIMARY KEY("testCharArray")) 
> DEFAULT_COLUMN_FAMILY='T';
> No rows affected (1.446 seconds)
> 0: jdbc:phoenix:xxxxxx> UPSERT INTO TEST VALUES (ARRAY['aaa', 'bbb', 'ccc']);
> java.lang.NullPointerException
>       at 
> org.apache.phoenix.schema.types.PArrayDataType.createPhoenixArray(PArrayDataType.java:1123)
>       at 
> org.apache.phoenix.schema.types.PArrayDataType.toObject(PArrayDataType.java:338)
>       at 
> org.apache.phoenix.schema.types.PCharArray.toObject(PCharArray.java:64)
>       at 
> org.apache.phoenix.schema.types.PDataType.toObject(PDataType.java:967)
>       at 
> org.apache.phoenix.schema.types.PDataType.toObject(PDataType.java:1008)
>       at 
> org.apache.phoenix.schema.types.PDataType.toObject(PDataType.java:1004)
>       at org.apache.phoenix.util.SchemaUtil.toString(SchemaUtil.java:381)
>       at org.apache.phoenix.schema.PTableImpl.newKey(PTableImpl.java:572)
>       at 
> org.apache.phoenix.compile.UpsertCompiler.setValues(UpsertCompiler.java:117)
>       at 
> org.apache.phoenix.compile.UpsertCompiler.access$400(UpsertCompiler.java:98)
>       at 
> org.apache.phoenix.compile.UpsertCompiler$3.execute(UpsertCompiler.java:821)
>       at 
> org.apache.phoenix.jdbc.PhoenixStatement$2.call(PhoenixStatement.java:319)
>       at 
> org.apache.phoenix.jdbc.PhoenixStatement$2.call(PhoenixStatement.java:311)
>       at org.apache.phoenix.call.CallRunner.run(CallRunner.java:53)
>       at 
> org.apache.phoenix.jdbc.PhoenixStatement.executeMutation(PhoenixStatement.java:309)
>       at 
> org.apache.phoenix.jdbc.PhoenixStatement.execute(PhoenixStatement.java:1432)
>       at sqlline.Commands.execute(Commands.java:822)
>       at sqlline.Commands.sql(Commands.java:732)
>       at sqlline.SqlLine.dispatch(SqlLine.java:808)
>       at sqlline.SqlLine.begin(SqlLine.java:681)
>       at sqlline.SqlLine.start(SqlLine.java:398)
>       at sqlline.SqlLine.main(SqlLine.java:292)
> 0: jdbc:phoenix:xxxxxx> SELECT * FROM TEST;
> +---------------+
> | testCharArray |
> +---------------+
> +---------------+
> No rows selected (0.169 seconds)
> 0: jdbc:phoenix:xxxxxx> SELECT "testCharArray" FROM TEST;
> +---------------+
> | testCharArray |
> +---------------+
> +---------------+
> No rows selected (0.182 seconds)
> {code}



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

Reply via email to