You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@phoenix.apache.org by GitBox <gi...@apache.org> on 2020/10/15 22:43:41 UTC

[GitHub] [phoenix] ChinmaySKulkarni commented on a change in pull request #908: PHOENIX-6172 Updating VIEW_INDEX_ID column type and ts in Syscat with…

ChinmaySKulkarni commented on a change in pull request #908:
URL: https://github.com/apache/phoenix/pull/908#discussion_r505903071



##########
File path: phoenix-core/src/it/java/org/apache/phoenix/end2end/UpgradeIT.java
##########
@@ -672,4 +689,61 @@ private SequenceKey createViewIndexSequenceWithOldName(ConnectionQueryServices c
         return key;
     }
 
+    @Test
+    public void testUpgradeViewIndexIdDataType() throws Exception {
+        byte[] rowKey = SchemaUtil.getColumnKey(null,
+                SYSTEM_SCHEMA_NAME, SYSTEM_CATALOG_TABLE, VIEW_INDEX_ID,
+                PhoenixDatabaseMetaData.TABLE_FAMILY);
+        byte[] syscatBytes = PhoenixDatabaseMetaData.SYSTEM_CATALOG_NAME.getBytes();
+        byte[] viewIndexIdTypeCellValueIn414 = PInteger.INSTANCE.toBytes(Types.SMALLINT);
+        byte[] viewIndexIdTypeCellValueIn416 = PInteger.INSTANCE.toBytes(Types.BIGINT);
+
+        // update the VIEW_INDEX_ID 0:DATAT_TYPE cell value to SMALLINT
+        // (4.14 and prior version is a SMALLINT column)
+        updateViewIndexIdColumnValue(rowKey, syscatBytes, viewIndexIdTypeCellValueIn414);

Review comment:
       If something fails after this modification of SYSTEM.CATALOG and for some reason the upgrade part doesn't run, the rest of this IT will work with a SYSTEM.CATALOG that has some modification in it right? Can we have some `finally' block to make sure there are no such changes?

##########
File path: phoenix-core/src/main/java/org/apache/phoenix/util/UpgradeUtil.java
##########
@@ -2252,6 +2255,36 @@ public static void upgradeTable(PhoenixConnection conn, String srcTable) throws
         }
     }
 
+    public static boolean updateViewIndexIdColumnDataTypeFromShortToLongIfNeeds(

Review comment:
       nit: `IfNeeded`

##########
File path: phoenix-core/src/main/java/org/apache/phoenix/util/UpgradeUtil.java
##########
@@ -2252,6 +2255,36 @@ public static void upgradeTable(PhoenixConnection conn, String srcTable) throws
         }
     }
 
+    public static boolean updateViewIndexIdColumnDataTypeFromShortToLongIfNeeds(
+            PhoenixConnection metaConnection, HBaseAdmin admin) {

Review comment:
       Maybe we should return true if an update was required, false if not required and in case it throw, we can catch and log the exception in the caller?

##########
File path: phoenix-core/src/main/java/org/apache/phoenix/util/UpgradeUtil.java
##########
@@ -2252,6 +2255,36 @@ public static void upgradeTable(PhoenixConnection conn, String srcTable) throws
         }
     }
 
+    public static boolean updateViewIndexIdColumnDataTypeFromShortToLongIfNeeds(
+            PhoenixConnection metaConnection, HBaseAdmin admin) {
+        try {
+            String tableName = PhoenixDatabaseMetaData.SYSTEM_CATALOG_NAME;
+            if (!admin.tableExists(tableName)) {
+                tableName = tableName.replace(
+                        QueryConstants.NAME_SEPARATOR,
+                        QueryConstants.NAMESPACE_SEPARATOR);
+            }
+            try(Table sysTable = metaConnection.getQueryServices().getTable(tableName.getBytes())) {
+                byte[] rowKey =
+                        SchemaUtil.getColumnKey(null, SYSTEM_SCHEMA_NAME, SYSTEM_CATALOG_TABLE,
+                                VIEW_INDEX_ID, PhoenixDatabaseMetaData.TABLE_FAMILY);
+                KeyValue viewIndexIdKV = KeyValueUtil.newKeyValue(rowKey,

Review comment:
       We should avoid this Put (will be a no-op) if the view_index_id is already BIGINT right? 




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org