Uploaded image for project: 'Phoenix'
  1. Phoenix
  2. PHOENIX-1508 VIEW enhancements
  3. PHOENIX-5317

Upserting rows into child views with pk fails when the base view has an index on it.

Attach filesAttach ScreenshotVotersWatch issueWatchersLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Sub-task
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 4.13.0, 4.14.1
    • 5.1.0, 4.16.0
    • None
    • None

    Description

      Steps to reproduce -

      1 Create Base Table, Base/Global View and Index using non tenanted connection.

      CREATE TABLE IF NOT EXISTS TEST.BASETABLE (
      TENANT_ID CHAR(15) NOT NULL,
      KEY_PREFIX CHAR(3) NOT NULL,
      CREATED_DATE DATE,
      CREATED_BY CHAR(15),
      SYSTEM_MODSTAMP DATE
      CONSTRAINT PK PRIMARY KEY (
      TENANT_ID,
      KEY_PREFIX
      )
      ) VERSIONS=1, MULTI_TENANT=true, IMMUTABLE_ROWS=TRUE, REPLICATION_SCOPE=1;

      CREATE VIEW IF NOT EXISTS TEST.MY_GLOBAL_VIEW (
      TEXT1 VARCHAR NOT NULL,
      INT1 BIGINT NOT NULL,
      DOUBLE1 DECIMAL(12, 3),
      IS_BOOLEAN BOOLEAN,
      RELATIONSHIP_ID CHAR(15),
      TEXT_READ_ONLY VARCHAR,
      DATE_TIME1 DATE,
      JSON1 VARCHAR,
      IP_START_ADDRESS VARCHAR
      CONSTRAINT PKVIEW PRIMARY KEY
      (
      TEXT1, INT1
      )
      )
      AS SELECT * FROM TEST.BASETABLE WHERE KEY_PREFIX = '0CY';

      CREATE INDEX IF NOT EXISTS TEST_MY_GLOBAL_VIEW_SEC_INDEX
      ON TEST.MY_GLOBAL_VIEW (TEXT1, INT1)
      INCLUDE (CREATED_BY, RELATIONSHIP_ID, JSON1, DOUBLE1, IS_BOOLEAN, IP_START_ADDRESS, CREATED_DATE, SYSTEM_MODSTAMP, TEXT_READ_ONLY);

      2. Create child view using an tenant-owned connection

      CREATE VIEW IF NOT EXISTS TEST."z01" (COL1 VARCHAR, COL2 VARCHAR, COL3 VARCHAR, COL4 VARCHAR CONSTRAINT PK PRIMARY KEY (COL1, COL2, COL3, COL4)) AS SELECT * FROM TEST.MY_GLOBAL_VIEW;

      3. Upsert into child view
      UPSERT INTO TEST."z01" (DATE_TIME1, INT1, TEXT1, COL1, COL2, COL3, COL4) VALUES (TO_DATE('2017-10-16 22:00:00', 'yyyy-MM-dd HH:mm:ss'), 10, 'zzzzz', '8', 'zzzzz', 'zzzzz', 'zzzzz');

      Following exception is thrown -

      0: jdbc:phoenix:localhost> UPSERT INTO TEST."z01" (DATE_TIME1, INT1, TEXT1, COL1, COL2, COL3, COL4) VALUES (TO_DATE('2017-10-16 22:00:00', 'yyyy-MM-dd HH:mm:ss'), 10, 'zzzzz', '8', 'zzzzz', 'zzzzz', 'zzzzz');
      java.lang.IllegalArgumentException
      at com.google.common.base.Preconditions.checkArgument(Preconditions.java:76)
      at com.google.common.collect.Lists.computeArrayListCapacity(Lists.java:105)
      at com.google.common.collect.Lists.newArrayListWithExpectedSize(Lists.java:195)
      at org.apache.phoenix.index.IndexMaintainer.<init>(IndexMaintainer.java:424)
      at org.apache.phoenix.index.IndexMaintainer.create(IndexMaintainer.java:143)
      at org.apache.phoenix.schema.PTableImpl.getIndexMaintainer(PTableImpl.java:1176)
      at org.apache.phoenix.util.IndexUtil.generateIndexData(IndexUtil.java:303)
      at org.apache.phoenix.execute.MutationState$1.next(MutationState.java:519)
      at org.apache.phoenix.execute.MutationState$1.next(MutationState.java:501)
      at org.apache.phoenix.execute.MutationState.send(MutationState.java:941)
      at org.apache.phoenix.execute.MutationState.send(MutationState.java:1387)
      at org.apache.phoenix.execute.MutationState.commit(MutationState.java:1228)
      at org.apache.phoenix.jdbc.PhoenixConnection$3.call(PhoenixConnection.java:666)
      at org.apache.phoenix.jdbc.PhoenixConnection$3.call(PhoenixConnection.java:662)
      at org.apache.phoenix.call.CallRunner.run(CallRunner.java:53)
      at org.apache.phoenix.jdbc.PhoenixConnection.commit(PhoenixConnection.java:662)
      at org.apache.phoenix.jdbc.PhoenixStatement$2.call(PhoenixStatement.java:399)
      at org.apache.phoenix.jdbc.PhoenixStatement$2.call(PhoenixStatement.java:379)
      at org.apache.phoenix.call.CallRunner.run(CallRunner.java:53)
      at org.apache.phoenix.jdbc.PhoenixStatement.executeMutation(PhoenixStatement.java:378)
      at org.apache.phoenix.jdbc.PhoenixStatement.executeMutation(PhoenixStatement.java:366)
      at org.apache.phoenix.jdbc.PhoenixStatement.execute(PhoenixStatement.java:1775)
      at sqlline.Commands.execute(Commands.java:822)
      at sqlline.Commands.sql(Commands.java:732)
      at sqlline.SqlLine.dispatch(SqlLine.java:807)
      at sqlline.SqlLine.begin(SqlLine.java:681)
      at sqlline.SqlLine.start(SqlLine.java:398)
      at sqlline.SqlLine.main(SqlLine.java:292)

      Attachments

        1. PHOENIX-5317.master.v1.patch
          26 kB
          Sandeep Guggilam
        2. PHOENIX-5317.4.x-HBase-1.3.v3.patch
          26 kB
          Sandeep Guggilam
        3. PHOENIX-5317.4.x-HBase-1.3.v2.patch
          27 kB
          Sandeep Guggilam
        4. PHOENIX-5317.4.x-HBase-1.3.v1.patch
          27 kB
          Sandeep Guggilam
        5. PHOENIX-5137-TestFailure.txt
          5 kB
          Jacob Isaac

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            sandeep.guggilam Sandeep Guggilam
            jisaac Jacob Isaac
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment