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

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


The following commit(s) were added to refs/heads/4.x-HBase-1.3 by this push:
     new 8aad8d1  PHOENIX-5104: breaks client backwards compatibility
8aad8d1 is described below

commit 8aad8d15be072bb85f8b19b494ad09463b4bbaf2
Author: Mehdi Salarkia <msalar...@box.com>
AuthorDate: Sun Jul 28 18:40:55 2019 -0700

    PHOENIX-5104: breaks client backwards compatibility
---
 phoenix-core/src/it/resources/hbase-site.xml              |  9 +++++++++
 .../main/java/org/apache/phoenix/query/QueryServices.java |  2 ++
 .../org/apache/phoenix/query/QueryServicesOptions.java    |  1 +
 .../java/org/apache/phoenix/schema/MetaDataClient.java    | 15 ++++++++++++++-
 4 files changed, 26 insertions(+), 1 deletion(-)

diff --git a/phoenix-core/src/it/resources/hbase-site.xml 
b/phoenix-core/src/it/resources/hbase-site.xml
index 691b702..ba45107 100644
--- a/phoenix-core/src/it/resources/hbase-site.xml
+++ b/phoenix-core/src/it/resources/hbase-site.xml
@@ -33,4 +33,13 @@
     version is X.X.X-SNAPSHOT"
     </description>
   </property>
+  <property>
+    <!--
+    We have some hardcoded viewIndex ids in the IT tests which assumes 
viewIndexId is of type Long.
+    However the default viewIndexId type is set to "short" by default until we 
upgrade all clients to support
+    long viewIndex ids.
+    -->
+    <name>phoenix.index.longViewIndex.enabled</name>
+    <value>true</value>
+  </property>
 </configuration>
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/query/QueryServices.java 
b/phoenix-core/src/main/java/org/apache/phoenix/query/QueryServices.java
index 9bdd22f..0a284f3 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/query/QueryServices.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/query/QueryServices.java
@@ -352,6 +352,8 @@ public interface QueryServices extends SQLCloseable {
     public static final String GLOBAL_INDEX_ROW_REPAIR_COUNT_ATTRIB = 
"phoenix.global.index.row.repair.count.ms";
     // Enable the IndexRegionObserver Coprocessor
     public static final String INDEX_REGION_OBSERVER_ENABLED_ATTRIB = 
"phoenix.index.region.observer.enabled";
+    // Enable support for long view index(default is false)
+    public static final String LONG_VIEW_INDEX_ENABLED_ATTRIB = 
"phoenix.index.longViewIndex.enabled";
 
 
     // Before 4.15 when we created a view we included the parent table column 
metadata in the view
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/query/QueryServicesOptions.java 
b/phoenix-core/src/main/java/org/apache/phoenix/query/QueryServicesOptions.java
index 144d388..0ccd0c6 100644
--- 
a/phoenix-core/src/main/java/org/apache/phoenix/query/QueryServicesOptions.java
+++ 
b/phoenix-core/src/main/java/org/apache/phoenix/query/QueryServicesOptions.java
@@ -393,6 +393,7 @@ public class QueryServicesOptions {
 
     public static final String DEFAULT_GUIDE_POSTS_CACHE_FACTORY_CLASS = 
"org.apache.phoenix.query.DefaultGuidePostsCacheFactory";
 
+    public static final boolean DEFAULT_LONG_VIEW_INDEX_ENABLED = false;
     private final Configuration config;
 
     private QueryServicesOptions(Configuration config) {
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 b1fffcc..8291edd 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
@@ -98,6 +98,7 @@ import static 
org.apache.phoenix.query.QueryConstants.BASE_TABLE_BASE_COLUMN_COU
 import static org.apache.phoenix.query.QueryConstants.DEFAULT_COLUMN_FAMILY;
 import static 
org.apache.phoenix.query.QueryConstants.ENCODED_CQ_COUNTER_INITIAL_VALUE;
 import static org.apache.phoenix.query.QueryServices.DROP_METADATA_ATTRIB;
+import static 
org.apache.phoenix.query.QueryServices.LONG_VIEW_INDEX_ENABLED_ATTRIB;
 import static 
org.apache.phoenix.query.QueryServicesOptions.DEFAULT_DROP_METADATA;
 import static 
org.apache.phoenix.query.QueryServicesOptions.DEFAULT_RUN_UPDATE_STATS_ASYNC;
 import static org.apache.phoenix.schema.PTable.EncodedCQCounter.NULL_COUNTER;
@@ -1440,6 +1441,18 @@ public class MetaDataClient {
     }
 
     /**
+     * Supprort long viewIndexId only if client has explicitly set
+     * the QueryServices.LONG_VIEW_INDEX_ENABLED_ATTRIB connection property to 
'true'.
+     * @return
+     */
+    private PDataType getViewIndexDataType() throws SQLException {
+        boolean supportsLongViewIndexId = 
connection.getQueryServices().getProps().getBoolean(
+                                QueryServices.LONG_VIEW_INDEX_ENABLED_ATTRIB,
+                                
QueryServicesOptions.DEFAULT_LONG_VIEW_INDEX_ENABLED);
+        return supportsLongViewIndexId ? MetaDataUtil.getViewIndexIdDataType() 
: MetaDataUtil.getLegacyViewIndexIdDataType();
+    }
+
+    /**
      * Create an index table by morphing the CreateIndexStatement into a 
CreateTableStatement and calling
      * MetaDataClient.createTable. In doing so, we perform the following 
translations:
      * 1) Change the type of any columns being indexed to types that support 
null if the column is nullable.
@@ -1537,7 +1550,7 @@ public class MetaDataClient {
              */
             if (isLocalIndex || (dataTable.getType() == PTableType.VIEW && 
dataTable.getViewType() != ViewType.MAPPED)) {
                 allocateIndexId = true;
-                PDataType dataType = MetaDataUtil.getViewIndexIdDataType();
+                PDataType dataType = getViewIndexDataType();
                 ColumnName colName = 
ColumnName.caseSensitiveColumnName(MetaDataUtil.getViewIndexIdColumnName());
                 allPkColumns.add(new ColumnDefInPkConstraint(colName, 
SortOrder.getDefault(), false));
                 columnDefs.add(FACTORY.columnDef(colName, 
dataType.getSqlTypeName(), false, null, null, false, SortOrder.getDefault(), 
null, false));

Reply via email to