[ 
https://issues.apache.org/jira/browse/PHOENIX-6172?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17213988#comment-17213988
 ] 

ASF GitHub Bot commented on PHOENIX-6172:
-----------------------------------------

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:
us...@infra.apache.org


> Updating VIEW_INDEX_ID column type and ts in Syscat with a 4.16 upgrade 
> script 
> -------------------------------------------------------------------------------
>
>                 Key: PHOENIX-6172
>                 URL: https://issues.apache.org/jira/browse/PHOENIX-6172
>             Project: Phoenix
>          Issue Type: Improvement
>    Affects Versions: 4.15.0
>            Reporter: Xinyi Yan
>            Priority: Major
>             Fix For: 4.16.0
>
>
> Updating VIEW_INDEX_ID column type and ts in Syscat with a 4.16 upgrade 
> script by using HBase put. Making sure the HBase row ts reflects the 4.16 
> version.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to