Uploaded image for project: 'Phoenix'
  1. Phoenix
  2. PHOENIX-2304

NullPointerException when using an index and a char array

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 4.5.2
    • Fix Version/s: 4.6.0
    • Component/s: None
    • Labels:
      None

      Description

      An NPE occurs when Phoenix attempts to retrieve a char array from an index. Retrieving other columns in the table is unaffected. Example below:

      0: jdbc:phoenix:xxxxxx> CREATE TABLE IF NOT EXISTS TEST.TEST("testInt" INTEGER, "testCharArray" CHAR(3)[], CONSTRAINT "test_pk" PRIMARY KEY("testInt")) DEFAULT_COLUMN_FAMILY='T';
      No rows affected (2.223 seconds)
      0: jdbc:phoenix:xxxxxx> UPSERT INTO TEST.TEST VALUES (5, ARRAY['aaa', 'bbb']);
      1 row affected (0.165 seconds)
      0: jdbc:phoenix:xxxxxx> SELECT "testCharArray" FROM TEST.TEST;
      +---------------+
      | testCharArray |
      +---------------+
      | ['aaa', 'bbb'] |
      +---------------+
      1 row selected (0.183 seconds)
      0: jdbc:phoenix:xxxxxx> CREATE INDEX IF NOT EXISTS TEST_INDEX ON TEST.TEST ("testInt") INCLUDE ("testCharArray");
      1 row affected (10.331 seconds)
      0: jdbc:phoenix:xxxxxx> EXPLAIN SELECT "testCharArray" FROM TEST.TEST;
      +------------------------------------------+
      |                   PLAN                   |
      +------------------------------------------+
      | CLIENT 1-CHUNK PARALLEL 1-WAY FULL SCAN OVER TEST.TEST |
      +------------------------------------------+
      1 row selected (0.173 seconds)
      0: jdbc:phoenix:xxxxxx> SELECT "testCharArray" FROM TEST.TEST;
      +---------------+
      | testCharArray |
      +---------------+
      | ['aaa', 'bbb'] |
      +---------------+
      1 row selected (0.475 seconds)
      0: jdbc:phoenix:xxxxxx> EXPLAIN SELECT /*+ INDEX(TEST.TEST TEST_INDEX)*/ "testCharArray" FROM TEST.TEST;
      +------------------------------------------+
      |                   PLAN                   |
      +------------------------------------------+
      | CLIENT 1-CHUNK PARALLEL 1-WAY FULL SCAN OVER TEST.TEST_INDEX |
      +------------------------------------------+
      1 row selected (0.186 seconds)
      0: jdbc:phoenix:xxxxxx> SELECT /*+ INDEX(TEST.TEST TEST_INDEX)*/ "testCharArray" FROM TEST.TEST;
      +------------------------------------------+
      |              testCharArray               |
      +------------------------------------------+
      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:984)
      	at org.apache.phoenix.compile.ExpressionProjector.getValue(ExpressionProjector.java:75)
      	at org.apache.phoenix.jdbc.PhoenixResultSet.getString(PhoenixResultSet.java:603)
      	at sqlline.Rows$Row.<init>(Rows.java:183)
      	at sqlline.IncrementalRows.hasNext(IncrementalRows.java:63)
      	at sqlline.TableOutputFormat.print(TableOutputFormat.java:33)
      	at sqlline.SqlLine.print(SqlLine.java:1653)
      	at sqlline.Commands.execute(Commands.java:833)
      	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> CREATE INDEX IF NOT EXISTS TEST2 ON TEST.TEST ("testInt", "testCharArray");
      1 row affected (2.098 seconds)
      0: jdbc:phoenix:xxxxxx> EXPLAIN SELECT /*+ INDEX(TEST.TEST TEST2) */ "testCharArray" FROM TEST.TEST;
      +------------------------------------------+
      |                   PLAN                   |
      +------------------------------------------+
      | CLIENT 1-CHUNK PARALLEL 1-WAY FULL SCAN OVER TEST.TEST2 |
      |     SERVER FILTER BY FIRST KEY ONLY      |
      +------------------------------------------+
      2 rows selected (0.189 seconds)
      0: jdbc:phoenix:xxxxxx> SELECT /*+ INDEX(TEST.TEST TEST2) */ "testCharArray" FROM TEST.TEST;
      +------------------------------------------+
      |              testCharArray               |
      +------------------------------------------+
      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:984)
      	at org.apache.phoenix.compile.ExpressionProjector.getValue(ExpressionProjector.java:75)
      	at org.apache.phoenix.jdbc.PhoenixResultSet.getString(PhoenixResultSet.java:603)
      	at sqlline.Rows$Row.<init>(Rows.java:183)
      	at sqlline.IncrementalRows.hasNext(IncrementalRows.java:63)
      	at sqlline.TableOutputFormat.print(TableOutputFormat.java:33)
      	at sqlline.SqlLine.print(SqlLine.java:1653)
      	at sqlline.Commands.execute(Commands.java:833)
      	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> EXPLAIN SELECT /*+ SKIP_SCAN */ "testCharArray" FROM TEST.TEST;
      +------------------------------------------+
      |                   PLAN                   |
      +------------------------------------------+
      | CLIENT 1-CHUNK PARALLEL 1-WAY FULL SCAN OVER TEST.TEST2 |
      |     SERVER FILTER BY FIRST KEY ONLY      |
      +------------------------------------------+
      2 rows selected (0.447 seconds)
      0: jdbc:phoenix:xxxxxx> SELECT /*+ SKIP_SCAN */ "testCharArray" FROM TEST.TEST;
      +------------------------------------------+
      |              testCharArray               |
      +------------------------------------------+
      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:984)
      	at org.apache.phoenix.compile.ExpressionProjector.getValue(ExpressionProjector.java:75)
      	at org.apache.phoenix.jdbc.PhoenixResultSet.getString(PhoenixResultSet.java:603)
      	at sqlline.Rows$Row.<init>(Rows.java:183)
      	at sqlline.IncrementalRows.hasNext(IncrementalRows.java:63)
      	at sqlline.TableOutputFormat.print(TableOutputFormat.java:33)
      	at sqlline.SqlLine.print(SqlLine.java:1653)
      	at sqlline.Commands.execute(Commands.java:833)
      	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 /*+ INDEX(TEST.TEST TEST2) */ "testInt" FROM TEST.TEST;
      +------------------------------------------+
      |                 testInt                  |
      +------------------------------------------+
      | 5                                        |
      +------------------------------------------+
      1 row selected (0.233 seconds)
      

        Attachments

        1. PHOENIX-2304_v2.patch
          34 kB
          James R. Taylor
        2. PHOENIX-2304_v1.patch
          9 kB
          James R. Taylor
        3. PHOENIX-2402.patch
          10 kB
          Julian Jaffe

          Activity

            People

            • Assignee:
              navis Navis Ryu
              Reporter:
              jjaffe@marinsoftware.com Julian Jaffe
            • Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: