capistrant commented on code in PR #12599:
URL: https://github.com/apache/druid/pull/12599#discussion_r914850385


##########
server/src/main/java/org/apache/druid/metadata/SQLMetadataConnector.java:
##########
@@ -464,6 +501,52 @@ tableName, getSerialType(), getPayloadType()
     );
   }
 
+  /**
+   * Adds the used_flag_last_updated column to the Druid segment table.
+   *
+   * This is public due to allow the UpdateTables cli tool to use for upgrade 
prep.
+   */
+  @Override
+  public void alterSegmentTableAddUsedFlagLastUpdated()
+  {
+    String tableName = tablesConfigSupplier.get().getSegmentsTable();
+    if (!tableHasColumn(tableName, "used_flag_last_updated")) {
+      log.info("Adding used_flag_last_updated column to %s", tableName);
+      alterTable(
+          tableName,
+          ImmutableList.of(
+              StringUtils.format(
+                  "ALTER TABLE %1$s \n"
+                  + "ADD used_flag_last_updated varchar(255)",
+                  tableName
+              )
+          )
+      );
+    } else {
+      log.info("%s already has used_flag_last_updated column", tableName);
+    }
+  }
+
+  /**
+   * Populates the used_flag_last_updated column for all unused segments in 
the Druid segment table.
+   *
+   * The current UTC timestamp string is used for the content of each column.
+   * This is public due to allow the UpdateTables cli tool to use in a 
optional post-upgrade action.
+   */
+  @Override
+  public void updateSegmentTablePopulateUsedFlagLastUpdated()

Review Comment:
   thinking out loud: Might make sense to add batching capability here. an int 
batching size that could break up the UPDATE command to avoid updating many 
rows in one action. For instance, an operator with 6 million unused segments 
may not want to do that kind of db update all at once. something like a batch 
of 10k might be more palatable to them. I do warn the operator about the single 
transaction in the docs regarding the cli tool update that calls this method so 
people *should* not be caught off guard by this if they read the doc before 
using the cli tool (which is the only thing that calls this method as of now)



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

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to