findingrish commented on code in PR #15817:
URL: https://github.com/apache/druid/pull/15817#discussion_r1567596445


##########
server/src/main/java/org/apache/druid/metadata/SQLMetadataConnector.java:
##########
@@ -540,6 +580,50 @@ protected void alterSegmentTableAddUsedFlagLastUpdated()
     }
   }
 
+  /**
+   * Adds new columns (used_status_last_updated, schema_id, segment_stats) to 
the "segments" table.
+   */
+  protected void alterSegmentTableSchemaPersistenceEnabled()
+  {
+    final String tableName = tablesConfigSupplier.get().getSegmentsTable();
+
+    Map<String, String> columnNameTypes = new HashMap<>();
+    columnNameTypes.put("used_status_last_updated", "varchar(255)");
+    columnNameTypes.put("schema_id", "BIGINT");
+    columnNameTypes.put("num_rows", "BIGINT");
+
+    Set<String> columnsToAdd = new HashSet<>();
+
+    for (String columnName : columnNameTypes.keySet()) {
+      if (tableHasColumn(tableName, columnName)) {
+        log.info("Table[%s] already has column[%s].", tableName, columnName);
+      } else {
+        columnsToAdd.add(columnName);
+      }
+    }
+
+    List<String> alterCommands = new ArrayList<>();
+    if (!columnsToAdd.isEmpty()) {
+      for (String columnName : columnsToAdd) {
+        alterCommands.add(

Review Comment:
   There is a single alter table call which takes in multiple alter commands.



-- 
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: commits-unsubscr...@druid.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@druid.apache.org
For additional commands, e-mail: commits-h...@druid.apache.org

Reply via email to