You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@phoenix.apache.org by ya...@apache.org on 2020/11/02 22:30:27 UTC

[phoenix] branch 4.x updated: PHOENIX-5210 NullPointerException when alter options of a table that is appendOnlySchema

This is an automated email from the ASF dual-hosted git repository.

yanxinyi pushed a commit to branch 4.x
in repository https://gitbox.apache.org/repos/asf/phoenix.git


The following commit(s) were added to refs/heads/4.x by this push:
     new 8aa243d  PHOENIX-5210 NullPointerException when alter options of a table that is appendOnlySchema
8aa243d is described below

commit 8aa243d1e35a2a9ac85c6c30f1e958289973c214
Author: Toshihiro Suzuki <br...@gmail.com>
AuthorDate: Thu Aug 15 13:50:32 2019 +0900

    PHOENIX-5210 NullPointerException when alter options of a table that is appendOnlySchema
    
    Signed-off-by: Xinyi Yan <ya...@apache.org>
---
 .../apache/phoenix/end2end/AppendOnlySchemaIT.java | 24 ++++++++++++++++++++++
 .../org/apache/phoenix/schema/MetaDataClient.java  |  2 +-
 2 files changed, 25 insertions(+), 1 deletion(-)

diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/AppendOnlySchemaIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/AppendOnlySchemaIT.java
index dc06f62..2cf32c8 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/AppendOnlySchemaIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/AppendOnlySchemaIT.java
@@ -39,6 +39,7 @@ import java.sql.Connection;
 import java.sql.DriverManager;
 import java.sql.ResultSet;
 import java.sql.SQLException;
+import java.sql.Statement;
 import java.util.Collections;
 import java.util.List;
 import java.util.Properties;
@@ -354,4 +355,27 @@ public class AppendOnlySchemaIT extends ParallelStatsDisabledIT {
         }
     }
 
+    @Test
+    public void testAlterTableOptions() throws Exception {
+        Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
+        try (Connection conn = DriverManager.getConnection(getUrl(), props);
+             Statement stmt = conn.createStatement()) {
+            String tableName = generateUniqueName();
+            // create a table
+            stmt.execute("CREATE TABLE " + tableName +
+              " (ID INTEGER PRIMARY KEY, COL INTEGER) APPEND_ONLY_SCHEMA = true,"
+              + " UPDATE_CACHE_FREQUENCY = 1");
+
+            // alter the table to set table options
+            stmt.execute("ALTER TABLE " + tableName + " SET STORE_NULLS = true");
+
+            try (ResultSet rs = stmt.executeQuery("SELECT STORE_NULLS FROM \"SYSTEM\".\"CATALOG\""
+              + " WHERE TABLE_NAME = '" + tableName + "' AND STORE_NULLS IS NOT NULL"
+              + " AND TENANT_ID IS NULL AND TABLE_SCHEM IS NULL")) {
+                assertTrue(rs.next());
+                assertTrue(rs.getBoolean(1));
+                assertFalse(rs.next());
+            }
+        }
+    }
 }
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java
index 8e5de13..27daf66 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java
@@ -3680,7 +3680,7 @@ public class MetaDataClient {
             connection.setAutoCommit(false);
 
             List<ColumnDef> columnDefs;
-            if (table.isAppendOnlySchema() || ifNotExists) {
+            if ((table.isAppendOnlySchema() || ifNotExists) && origColumnDefs != null) {
                 // only make the rpc if we are adding new columns
                 columnDefs = Lists.newArrayList();
                 for (ColumnDef columnDef : origColumnDefs) {