Repository: phoenix
Updated Branches:
  refs/heads/4.x-HBase-1.1 6169dbbbd -> 45fd77b42


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/f043bcad
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/f043bcad
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/f043bcad

Branch: refs/heads/4.x-HBase-1.1
Commit: f043bcadbf0c1562241c32927ae231d963f9897d
Parents: 6169dbb
Author: James Taylor <[email protected]>
Authored: Thu May 19 07:43:03 2016 -0700
Committer: James Taylor <[email protected]>
Committed: Thu May 19 13:51:04 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/f043bcad/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/f043bcad/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/f043bcad/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),
     ;

Reply via email to