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

James Taylor commented on PHOENIX-2276:
---------------------------------------

Yes, tomorrow is fine. Thanks, [~maryannxue]! Is there an inherent assumption 
that the tenantId is always the first field in the row key? If that's the case, 
we should check {{if PTable.getViewIndexId() != null}} as in that case it'll be 
the second field. You'd always want to skip the first field in this case, as 
it's the index id.

> Creating index on a global view on a multi-tenant table fails with NPE
> ----------------------------------------------------------------------
>
>                 Key: PHOENIX-2276
>                 URL: https://issues.apache.org/jira/browse/PHOENIX-2276
>             Project: Phoenix
>          Issue Type: Bug
>            Reporter: Samarth Jain
>            Assignee: Samarth Jain
>              Labels: SFDC
>             Fix For: 4.8.0
>
>         Attachments: PHOENIX-2276-1.fix, PHOENIX-2276.patch
>
>
> {code}
> @Test
>     public void testCreatingIndexOnGlobalView() throws Exception {
>         String baseTable = "testRowTimestampColWithViews".toUpperCase();
>         String globalView = "globalView".toUpperCase();
>         String globalViewIdx = "globalView_idx".toUpperCase();
>         long ts = nextTimestamp();
>         try (Connection conn = getConnection(ts)) {
>             conn.createStatement().execute("CREATE TABLE " + baseTable + " 
> (TENANT_ID CHAR(15) NOT NULL, PK2 DATE NOT NULL, PK3 INTEGER NOT NULL, KV1 
> VARCHAR, KV2 VARCHAR, KV3 CHAR(15) CONSTRAINT PK PRIMARY KEY(TENANT_ID, PK2 
> ROW_TIMESTAMP, PK3)) MULTI_TENANT=true");
>         }
>         ts = nextTimestamp();
>         try (Connection conn = getConnection(ts)) {
>             conn.createStatement().execute("CREATE VIEW " + globalView + " AS 
> SELECT * FROM " + baseTable + " WHERE KV1 = 'KV1'");
>         }
>         ts = nextTimestamp();
>         try (Connection conn = getConnection(ts)) {
>             conn.createStatement().execute("CREATE INDEX " + globalViewIdx + 
> " ON " + globalView + " (PK3 DESC, KV3) INCLUDE (KV1)");
>         }
>     }
> java.lang.NullPointerException
>       at 
> org.apache.phoenix.util.StringUtil.escapeBackslash(StringUtil.java:392)
>       at 
> org.apache.phoenix.compile.PostIndexDDLCompiler.compile(PostIndexDDLCompiler.java:78)
>       at 
> org.apache.phoenix.schema.MetaDataClient.buildIndex(MetaDataClient.java:1027)
>       at 
> org.apache.phoenix.schema.MetaDataClient.buildIndexAtTimeStamp(MetaDataClient.java:903)
>       at 
> org.apache.phoenix.schema.MetaDataClient.createIndex(MetaDataClient.java:1321)
>       at 
> org.apache.phoenix.compile.CreateIndexCompiler$1.execute(CreateIndexCompiler.java:95)
>       at 
> org.apache.phoenix.jdbc.PhoenixStatement$3.call(PhoenixStatement.java:315)
>       at 
> org.apache.phoenix.jdbc.PhoenixStatement$3.call(PhoenixStatement.java:1)
>       at org.apache.phoenix.call.CallRunner.run(CallRunner.java:53)
>       at 
> org.apache.phoenix.jdbc.PhoenixStatement.executeMutation(PhoenixStatement.java:306)
>       at 
> org.apache.phoenix.jdbc.PhoenixStatement.execute(PhoenixStatement.java:1375)
> {code}



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

Reply via email to