Julian Jaffe created PHOENIX-2301:
-------------------------------------

             Summary: 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
            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