You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@phoenix.apache.org by td...@apache.org on 2017/02/13 22:59:50 UTC

phoenix git commit: PHOENIX-3660 Don't pass statement properties while adding columns to a table that already exists that had APPEND_ONLY_SCHEMA=true

Repository: phoenix
Updated Branches:
  refs/heads/4.x-HBase-0.98 f11237c8e -> 234e427b3


PHOENIX-3660 Don't pass statement properties while adding columns to a table that already exists that had APPEND_ONLY_SCHEMA=true


Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/234e427b
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/234e427b
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/234e427b

Branch: refs/heads/4.x-HBase-0.98
Commit: 234e427b31b8b00a95e7d7dd1e5f143dce20dd16
Parents: f11237c
Author: Thomas D'Silva <td...@salesforce.com>
Authored: Mon Feb 13 13:35:59 2017 -0800
Committer: Thomas D'Silva <td...@salesforce.com>
Committed: Mon Feb 13 14:34:55 2017 -0800

----------------------------------------------------------------------
 .../phoenix/end2end/AppendOnlySchemaIT.java     | 28 +++++++++++++++-----
 .../apache/phoenix/schema/MetaDataClient.java   |  3 ++-
 2 files changed, 23 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/234e427b/phoenix-core/src/it/java/org/apache/phoenix/end2end/AppendOnlySchemaIT.java
----------------------------------------------------------------------
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 7ed64ff..e9a20b3 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
@@ -81,23 +81,37 @@ public class AppendOnlySchemaIT extends ParallelStatsDisabledIT {
             // create sequence for auto partition
             conn1.createStatement().execute("CREATE SEQUENCE " + metricIdSeqTableName + " CACHE 1");
             // create base table
-            conn1.createStatement().execute("CREATE TABLE "+ metricTableName + "(metricId INTEGER NOT NULL, metricVal DOUBLE, CONSTRAINT PK PRIMARY KEY(metricId))"
-                    + " APPEND_ONLY_SCHEMA = true, UPDATE_CACHE_FREQUENCY=1, AUTO_PARTITION_SEQ=" + metricIdSeqTableName);
+            String ddl = "CREATE TABLE " + (notExists ? "IF NOT EXISTS " : "") + metricTableName + "(metricId INTEGER NOT NULL, metricVal DOUBLE, CONSTRAINT PK PRIMARY KEY(metricId))"
+                    + " APPEND_ONLY_SCHEMA = true, UPDATE_CACHE_FREQUENCY=1, AUTO_PARTITION_SEQ=" + metricIdSeqTableName;
+			conn1.createStatement().execute(ddl);
+			// execute same create ddl
+            try {
+                conn2.createStatement().execute(ddl);
+                if (!notExists) {
+                    fail("Create Table should fail");
+                }
+            }
+            catch (TableAlreadyExistsException e) {
+                if (notExists) {
+                    fail("Create Table should not fail");
+                }
+            }
+			
             // create view
-            String ddl =
+            String viewDDL =
                     "CREATE VIEW " + (notExists ? "IF NOT EXISTS " : "")
                             + viewName + " ( hostName varchar NOT NULL, tagName varChar"
                             + " CONSTRAINT HOSTNAME_PK PRIMARY KEY (hostName))"
                             + " AS SELECT * FROM " + metricTableName
                             + " UPDATE_CACHE_FREQUENCY=300000";
-            conn1.createStatement().execute(ddl);
+            conn1.createStatement().execute(viewDDL);
             conn1.createStatement().execute("UPSERT INTO " + viewName + "(hostName, metricVal) VALUES('host1', 1.0)");
             conn1.commit();
             reset(connectionQueryServices);
 
             // execute same create ddl
             try {
-                conn2.createStatement().execute(ddl);
+                conn2.createStatement().execute(viewDDL);
                 if (!notExists) {
                     fail("Create Table should fail");
                 }
@@ -118,9 +132,9 @@ public class AppendOnlySchemaIT extends ParallelStatsDisabledIT {
             reset(connectionQueryServices);
             
             // execute alter table ddl that adds the same column
-            ddl = "ALTER VIEW " + viewName + " ADD " + (notExists ? "IF NOT EXISTS" : "") + " tagName varchar";
+            viewDDL = "ALTER VIEW " + viewName + " ADD " + (notExists ? "IF NOT EXISTS" : "") + " tagName varchar";
             try {
-                conn2.createStatement().execute(ddl);
+                conn2.createStatement().execute(viewDDL);
                 if (!notExists) {
                     fail("Alter Table should fail");
                 }

http://git-wip-us.apache.org/repos/asf/phoenix/blob/234e427b/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java
----------------------------------------------------------------------
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 cc2b5b9..705cde0 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
@@ -215,6 +215,7 @@ import org.apache.tephra.TxConstants;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import com.google.common.collect.ImmutableListMultimap;
 import com.google.common.collect.Iterators;
 import com.google.common.collect.ListMultimap;
 import com.google.common.collect.Lists;
@@ -950,7 +951,7 @@ public class MetaDataClient {
                     }
                 }
                 // if there are new columns to add
-                return addColumn(table, columnDefs, statement.getProps(), statement.ifNotExists(),
+                return addColumn(table, columnDefs, ImmutableListMultimap.<String,Pair<String,Object>>of(), statement.ifNotExists(),
                         true, NamedTableNode.create(statement.getTableName()), statement.getTableType());
             }
         }