npawar commented on code in PR #13789:
URL: https://github.com/apache/pinot/pull/13789#discussion_r1714393632


##########
pinot-server/src/main/java/org/apache/pinot/server/api/resources/TablesResource.java:
##########
@@ -952,4 +955,41 @@ public TableSegmentValidationInfo 
validateTableSegmentState(
     }
     return new TableSegmentValidationInfo(true, maxEndTimeMs);
   }
+
+  @GET
+  @Path("/tables/{tableName}/segments/mismatch")
+  @Produces(MediaType.APPLICATION_JSON)
+  @ApiOperation(value = "Checks if there is any mismatch of columns in a 
segment", notes =
+      "Returns true if reload is required on" + " any segment in a given 
server")
+  @ApiResponses(value = {
+      @ApiResponse(code = 200, message = "Success", response = 
TableSegments.class), @ApiResponse(code = 500,
+      message = "Server initialization error", response = ErrorInfo.class)
+  })
+  public String checkMismatchedSegments(
+      @ApiParam(value = "Table Name with type", required = true) 
@PathParam("tableName") String tableName,
+      @ApiParam(value = "Column name", allowMultiple = true) 
@QueryParam("columns") @DefaultValue("")
+      List<String> columns, @Context HttpHeaders headers) {
+    tableName = DatabaseUtils.translateTableName(tableName, headers);
+    TableDataManager tableDataManager = 
ServerResourceUtils.checkGetTableDataManager(_serverInstance, tableName);
+    Pair<TableConfig, Schema> tableConfigSchema = 
tableDataManager.fetchTableConfigAndSchema();
+    Schema schema = tableConfigSchema.getValue();
+    Set<String> schemaColumns = schema.getPhysicalColumnNames();
+    List<SegmentDataManager> segmentDataManagers = 
tableDataManager.acquireAllSegments();
+    try {
+      boolean mismatchCheck = false;
+      for (SegmentDataManager segmentDataManager : segmentDataManagers) {
+        Set<String> segmentColumns = 
SegmentMetadataFetcher.getSegmentColumns(segmentDataManager, columns);
+        if (!segmentColumns.containsAll(schemaColumns)) {

Review Comment:
   we would need to also check indexing changes. reload will be needed for 
indexing changes, dictionary changes, along with new column added



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