gjacoby126 commented on a change in pull request #935:
URL: https://github.com/apache/phoenix/pull/935#discussion_r521030508



##########
File path: phoenix-core/src/main/java/org/apache/phoenix/util/UpgradeUtil.java
##########
@@ -2586,4 +2588,18 @@ public static boolean isNoUpgradeSet(Properties props) {
     public static void doNotUpgradeOnFirstConnection(Properties props) {
         props.setProperty(DO_NOT_UPGRADE, String.valueOf(true));
     }
+
+    //When upgrading to Phoenix 4.16, make each existing table's DDL timestamp 
equal to its last
+    // updated row timestamp.
+    public static void bootstrapLastDDLTimestamp(PhoenixConnection 
metaConnection) throws SQLException  {
+        String pkCols = TENANT_ID + ", " + TABLE_SCHEM +
+            ", " + TABLE_NAME + ", " + COLUMN_NAME + ", " + COLUMN_FAMILY;
+        String upsertSql =
+            "UPSERT INTO " + SYSTEM_CATALOG_NAME + " (" + pkCols + ", " +
+        LAST_DDL_TIMESTAMP + ")" + " " +
+            "SELECT " + pkCols + ", PHOENIX_ROW_TIMESTAMP() FROM " + 
SYSTEM_CATALOG_NAME + " " +
+                "WHERE " + TABLE_TYPE + " " + " in " + "('u','v')";

Review comment:
       Because I affirmatively only intend for it to affect tables and views, 
not "not system tables or indexes". I'll add a comment in the code though, good 
point. 
   
   The reason, btw, is that only tables and views are relevant schema for 
_external_ systems trying to interpret Phoenix data. (This is a pre-req change 
for Phoenix change data capture, to allow Phoenix DML to be emitted as 
schema'ed messages into a message bus.) Indexes are an internal Phoenix 
optimization, and system tables are internal Phoenix config; no other system or 
external schema registry should care about them. 
   
   If some other kind of Phoenix schema object is created later, I'd want 
whoever creates it to opt-in to having a ddl timestamp, not need to remember to 
opt-out.




----------------------------------------------------------------
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:
[email protected]


Reply via email to