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/14 15:06:45 UTC

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

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



##########
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,
+                        PhoenixDatabaseMetaData.TABLE_FAMILY_BYTES,
+                        PhoenixDatabaseMetaData.DATA_TYPE_BYTES,
+                        MetaDataProtocol.MIN_SYSTEM_TABLE_TIMESTAMP,
+                        PInteger.INSTANCE.toBytes(Types.BIGINT));
+                Put viewIndexIdPut = new Put(rowKey);
+                viewIndexIdPut.add(viewIndexIdKV);
+                sysTable.put(viewIndexIdPut);
+            }
+            return true;
+        } catch (Exception e) {
+            LOGGER.error("Upgrade/change VIEW_INDEX_ID data type failed: " + e.getMessage() +
+                    ". Full stacktrace: " + ExceptionUtils.getFullStackTrace(e));

Review comment:
       nit: we can use placeholders `{}` for arguments?

##########
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

Review comment:
       nit: you mean `BIGINT` at the last?




----------------------------------------------------------------
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