You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@phoenix.apache.org by ja...@apache.org on 2016/05/19 20:48:53 UTC

[1/2] phoenix git commit: PHOENIX-2911 Don't use parent table schema name for auto partitioned tables

Repository: phoenix
Updated Branches:
  refs/heads/master 4ee0989af -> 7d3ae7168


PHOENIX-2911 Don't use parent table schema name for auto partitioned tables


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

Branch: refs/heads/master
Commit: a5ee6fc2eae896bd7d910c0ecb9a36cfd360ba48
Parents: 4ee0989
Author: James Taylor <jt...@Danielas-MacBook-Pro.local>
Authored: Thu May 19 07:43:03 2016 -0700
Committer: James Taylor <ja...@apache.org>
Committed: Thu May 19 08:06:29 2016 -0700

----------------------------------------------------------------------
 .../org/apache/phoenix/end2end/AutoPartitionViewsIT.java     | 8 ++++----
 .../org/apache/phoenix/coprocessor/MetaDataEndpointImpl.java | 4 ++--
 .../main/java/org/apache/phoenix/schema/TableProperty.java   | 8 +++++++-
 3 files changed, 13 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/a5ee6fc2/phoenix-core/src/it/java/org/apache/phoenix/end2end/AutoPartitionViewsIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/AutoPartitionViewsIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/AutoPartitionViewsIT.java
index b21b772..c66a7c8 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/AutoPartitionViewsIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/AutoPartitionViewsIT.java
@@ -64,7 +64,7 @@ public class AutoPartitionViewsIT extends BaseHBaseManagedTimeIT {
 
     public AutoPartitionViewsIT(boolean salted, boolean isMultiTenant) {
         this.isMultiTenant = isMultiTenant;
-        StringBuilder optionBuilder = new StringBuilder(" AUTO_PARTITION_SEQ=metric_id_seq");
+        StringBuilder optionBuilder = new StringBuilder(" AUTO_PARTITION_SEQ=\"TSDB.METRIC_ID_SEQ\"");
         if (salted) optionBuilder.append(", SALTED=4 ");
         if (isMultiTenant) optionBuilder.append(", MULTI_TENANT=true ");
         this.tableDDLOptions = optionBuilder.toString();
@@ -111,7 +111,7 @@ public class AutoPartitionViewsIT extends BaseHBaseManagedTimeIT {
             }
 
             conn.createStatement().execute(
-                "CREATE SEQUENCE metric_id_seq start with " + (Integer.MAX_VALUE-2) + " cache 1");
+                "CREATE SEQUENCE TSDB.metric_id_seq start with " + (Integer.MAX_VALUE-2) + " cache 1");
             viewConn1.createStatement().execute(
                 "CREATE VIEW metric1 AS SELECT * FROM metric_table WHERE val2=1.2");
             // create a view without a where clause
@@ -232,7 +232,7 @@ public class AutoPartitionViewsIT extends BaseHBaseManagedTimeIT {
                             isMultiTenant ? "tenantId, ": "", 
                             tableDDLOptions);
             conn.createStatement().execute(ddl);
-            conn.createStatement().execute("CREATE SEQUENCE hbase.metric_id_seq CACHE 1");
+            conn.createStatement().execute("CREATE SEQUENCE TSDB.metric_id_seq CACHE 1");
             // create a view
             viewConn1.createStatement().execute(
                 "CREATE VIEW metric1 AS SELECT * FROM hbase.metric_table WHERE val2=1.2");
@@ -306,7 +306,7 @@ public class AutoPartitionViewsIT extends BaseHBaseManagedTimeIT {
                             isMultiTenant ? "tenantId, ": "", 
                             tableDDLOptions);
             conn.createStatement().execute(ddl);
-            conn.createStatement().execute("CREATE SEQUENCE hbase.metric_id_seq CACHE 1");
+            conn.createStatement().execute("CREATE SEQUENCE TSDB.metric_id_seq CACHE 1");
             // create a view
             viewConn1.createStatement().execute(
                 "CREATE VIEW metric1 AS SELECT * FROM hbase.metric_table");

http://git-wip-us.apache.org/repos/asf/phoenix/blob/a5ee6fc2/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataEndpointImpl.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataEndpointImpl.java b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataEndpointImpl.java
index 5becf24..8264101 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataEndpointImpl.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataEndpointImpl.java
@@ -1452,8 +1452,8 @@ public class MetaDataEndpointImpl extends MetaDataProtocol implements Coprocesso
                     props.setProperty(PhoenixRuntime.NO_UPGRADE_ATTRIB, Boolean.TRUE.toString());
                     try (PhoenixConnection connection = DriverManager.getConnection(MetaDataUtil.getJdbcUrl(env), props).unwrap(PhoenixConnection.class);
                             Statement stmt = connection.createStatement()) {
-                        String seqNextValueSql = String.format("SELECT NEXT VALUE FOR %s FROM %s LIMIT 1",
-                            SchemaUtil.getTableName(parentTable.getSchemaName().getString(), parentTable.getAutoPartitionSeqName()), PhoenixDatabaseMetaData.SYSTEM_CATALOG_NAME);
+                        String seqName = parentTable.getAutoPartitionSeqName();
+                        String seqNextValueSql = String.format("SELECT NEXT VALUE FOR %s", seqName);
                         ResultSet rs = stmt.executeQuery(seqNextValueSql);
                         rs.next();
                         autoPartitionNum = rs.getLong(1);

http://git-wip-us.apache.org/repos/asf/phoenix/blob/a5ee6fc2/phoenix-core/src/main/java/org/apache/phoenix/schema/TableProperty.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/schema/TableProperty.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/TableProperty.java
index 7e521e6..d5d0b84 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/schema/TableProperty.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/TableProperty.java
@@ -32,6 +32,7 @@ import org.apache.hadoop.hbase.HColumnDescriptor;
 import org.apache.phoenix.exception.SQLExceptionCode;
 import org.apache.phoenix.exception.SQLExceptionInfo;
 import org.apache.phoenix.jdbc.PhoenixDatabaseMetaData;
+import org.apache.phoenix.util.SchemaUtil;
 
 public enum TableProperty {
 
@@ -68,7 +69,12 @@ public enum TableProperty {
 	    }	    
 	},
 	
-	AUTO_PARTITION_SEQ(PhoenixDatabaseMetaData.AUTO_PARTITION_SEQ, COLUMN_FAMILY_NOT_ALLOWED_TABLE_PROPERTY, false, false),
+	AUTO_PARTITION_SEQ(PhoenixDatabaseMetaData.AUTO_PARTITION_SEQ, COLUMN_FAMILY_NOT_ALLOWED_TABLE_PROPERTY, false, false) {
+        @Override
+        public Object getValue(Object value) {
+            return value == null ? null : SchemaUtil.normalizeIdentifier(value.toString());
+        }  
+	},
 	
 	APPEND_ONLY_SCHEMA(PhoenixDatabaseMetaData.APPEND_ONLY_SCHEMA, COLUMN_FAMILY_NOT_ALLOWED_TABLE_PROPERTY, true, true),
     ;


[2/2] phoenix git commit: PHOENIX-2918 Fix backward compat for APPEND_ONLY_SCHEMA and AUTO_PARTITION_SEQ features

Posted by ja...@apache.org.
PHOENIX-2918 Fix backward compat for APPEND_ONLY_SCHEMA and AUTO_PARTITION_SEQ features


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

Branch: refs/heads/master
Commit: 7d3ae71687983b51800fdc7f06e34a74fae86283
Parents: a5ee6fc
Author: James Taylor <ja...@apache.org>
Authored: Thu May 19 13:48:32 2016 -0700
Committer: James Taylor <ja...@apache.org>
Committed: Thu May 19 13:48:32 2016 -0700

----------------------------------------------------------------------
 .../apache/phoenix/coprocessor/MetaDataProtocol.java   |  2 +-
 .../phoenix/query/ConnectionQueryServicesImpl.java     | 13 ++++++++++++-
 2 files changed, 13 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/7d3ae716/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataProtocol.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataProtocol.java b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataProtocol.java
index f847b97..df00f8f 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataProtocol.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataProtocol.java
@@ -79,7 +79,7 @@ public abstract class MetaDataProtocol extends MetaDataService {
     public static final long MIN_SYSTEM_TABLE_TIMESTAMP_4_5_0 = MIN_TABLE_TIMESTAMP + 8;
     public static final long MIN_SYSTEM_TABLE_TIMESTAMP_4_6_0 = MIN_TABLE_TIMESTAMP + 9;
     public static final long MIN_SYSTEM_TABLE_TIMESTAMP_4_7_0 = MIN_TABLE_TIMESTAMP + 15;
-    public static final long MIN_SYSTEM_TABLE_TIMESTAMP_4_8_0 = MIN_TABLE_TIMESTAMP + 16;
+    public static final long MIN_SYSTEM_TABLE_TIMESTAMP_4_8_0 = MIN_TABLE_TIMESTAMP + 18;
     // MIN_SYSTEM_TABLE_TIMESTAMP needs to be set to the max of all the MIN_SYSTEM_TABLE_TIMESTAMP_* constants
     public static final long MIN_SYSTEM_TABLE_TIMESTAMP = MIN_SYSTEM_TABLE_TIMESTAMP_4_8_0;
     // TODO: pare this down to minimum, as we don't need duplicates for both table and column errors, nor should we need

http://git-wip-us.apache.org/repos/asf/phoenix/blob/7d3ae716/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java b/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
index f665cb4..b8d9762 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
@@ -174,6 +174,7 @@ import org.apache.phoenix.schema.types.PDataType;
 import org.apache.phoenix.schema.types.PInteger;
 import org.apache.phoenix.schema.types.PLong;
 import org.apache.phoenix.schema.types.PUnsignedTinyint;
+import org.apache.phoenix.schema.types.PVarchar;
 import org.apache.phoenix.util.ByteUtil;
 import org.apache.phoenix.util.Closeables;
 import org.apache.phoenix.util.ConfigUtil;
@@ -2480,9 +2481,19 @@ public class ConnectionQueryServicesImpl extends DelegateQueryServices implement
                                 if (currentServerSideTableTimeStamp < MetaDataProtocol.MIN_SYSTEM_TABLE_TIMESTAMP_4_8_0) {
                                     metaConnection = addColumnsIfNotExists(metaConnection,
                                             PhoenixDatabaseMetaData.SYSTEM_CATALOG,
-                                            MetaDataProtocol.MIN_SYSTEM_TABLE_TIMESTAMP_4_8_0,
+                                            MetaDataProtocol.MIN_SYSTEM_TABLE_TIMESTAMP_4_8_0 - 2,
                                             PhoenixDatabaseMetaData.IS_NAMESPACE_MAPPED + " "
                                                     + PBoolean.INSTANCE.getSqlTypeName());
+                                    metaConnection = addColumnsIfNotExists(metaConnection,
+                                            PhoenixDatabaseMetaData.SYSTEM_CATALOG,
+                                            MetaDataProtocol.MIN_SYSTEM_TABLE_TIMESTAMP_4_8_0 - 1,
+                                            PhoenixDatabaseMetaData.AUTO_PARTITION_SEQ + " "
+                                                    + PVarchar.INSTANCE.getSqlTypeName());
+                                    metaConnection = addColumnsIfNotExists(metaConnection,
+                                            PhoenixDatabaseMetaData.SYSTEM_CATALOG,
+                                            MetaDataProtocol.MIN_SYSTEM_TABLE_TIMESTAMP_4_8_0,
+                                            PhoenixDatabaseMetaData.APPEND_ONLY_SCHEMA + " "
+                                                    + PBoolean.INSTANCE.getSqlTypeName());
                                     ConnectionQueryServicesImpl.this.removeTable(null,
                                             PhoenixDatabaseMetaData.SYSTEM_CATALOG_NAME, null,
                                             MetaDataProtocol.MIN_SYSTEM_TABLE_TIMESTAMP_4_8_0);