[
https://issues.apache.org/jira/browse/PHOENIX-1504?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14591336#comment-14591336
]
Samarth Jain commented on PHOENIX-1504:
---------------------------------------
Thanks for the review [~jamestaylor].
Regarding the change in ByteUtil.java
{code}
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/util/ByteUtil.java
b/phoenix-core/src/main/java/org/apache/phoenix/util/ByteUtil.java
index 1e3516d..1f4a285 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/util/ByteUtil.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/util/ByteUtil.java
@@ -253,13 +253,17 @@ public class ByteUtil {
public static byte[] concat(byte[] first, byte[]... rest) {
int totalLength = first.length;
for (byte[] array : rest) {
- totalLength += array.length;
+ if (array != null) {
+ totalLength += array.length;
+ }
{code}
I noticed that the a test in TenantSpecificTablesDDLIT was failing because of
an NPE in MetadataEndpointImpl. The NPE was happening because the column family
of the column being added is null.
Test code line:
{code}
conn.createStatement().execute("alter table " + PARENT_TABLE_NAME + " add
new_pk varchar primary key");
{code}
NPE
{code}
Caused by: java.lang.NullPointerException
at org.apache.phoenix.util.ByteUtil.concat(ByteUtil.java:256)
at
org.apache.phoenix.coprocessor.MetaDataEndpointImpl.addRowsToChildViews(MetaDataEndpointImpl.java:1602)
at
org.apache.phoenix.coprocessor.MetaDataEndpointImpl.access$3(MetaDataEndpointImpl.java:1571)
at
org.apache.phoenix.coprocessor.MetaDataEndpointImpl$2.updateMutation(MetaDataEndpointImpl.java:1678)
at
org.apache.phoenix.coprocessor.MetaDataEndpointImpl.mutateColumn(MetaDataEndpointImpl.java:1546)
... 11 more
{code}
Line at which NPE is thrown because the column family is null.
{code}
byte[] k = ByteUtil.concat(viewKey, QueryConstants.SEPARATOR_BYTE_ARRAY,
rkmd[COLUMN_NAME_INDEX],
QueryConstants.SEPARATOR_BYTE_ARRAY,
rkmd[FAMILY_NAME_INDEX]);
{code}
What do you think? Should we allow adding PK columns to base tables that have
views? If yes, I will also add a test to make sure that the new column shows up
as PK for the entire view hierarchy too.
> Support adding column to a table that has views
> -----------------------------------------------
>
> Key: PHOENIX-1504
> URL: https://issues.apache.org/jira/browse/PHOENIX-1504
> Project: Phoenix
> Issue Type: Sub-task
> Reporter: James Taylor
> Assignee: Samarth Jain
> Fix For: 5.0.0, 4.5.0
>
> Attachments: PHOENIX-1504-wip.patch, PHOENIX-1504.patch
>
>
> We currently disallow any schema modifications to a table that has views. We
> should relax that constraint and push the schema change as necessary out to
> all views.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)