Jackie-Jiang commented on a change in pull request #7142: URL: https://github.com/apache/incubator-pinot/pull/7142#discussion_r667133484
########## File path: pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotTableRestletResource.java ########## @@ -210,21 +214,60 @@ public String listTableConfigs(@ApiParam(value = "realtime|offline") @QueryParam if (tableType == null) { tableNames = _pinotHelixResourceManager.getAllRawTables(); + } else if (tableType == TableType.REALTIME) { + tableNames = _pinotHelixResourceManager.getAllRealtimeTables(); } else { - if (tableType == TableType.REALTIME) { - tableNames = _pinotHelixResourceManager.getAllRealtimeTables(); - } else { - tableNames = _pinotHelixResourceManager.getAllOfflineTables(); - } + tableNames = _pinotHelixResourceManager.getAllOfflineTables(); + } + if (sortType == null) { Review comment: We should treat this the same as `sortType` of "name" for backward-compatibility ```suggestion if (sortType == null || sortType.equalsIgnoreCase("name")) { ... } ``` ########## File path: pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotTableRestletResource.java ########## @@ -210,21 +214,60 @@ public String listTableConfigs(@ApiParam(value = "realtime|offline") @QueryParam if (tableType == null) { tableNames = _pinotHelixResourceManager.getAllRawTables(); + } else if (tableType == TableType.REALTIME) { + tableNames = _pinotHelixResourceManager.getAllRealtimeTables(); } else { - if (tableType == TableType.REALTIME) { - tableNames = _pinotHelixResourceManager.getAllRealtimeTables(); - } else { - tableNames = _pinotHelixResourceManager.getAllOfflineTables(); - } + tableNames = _pinotHelixResourceManager.getAllOfflineTables(); + } + if (sortType == null) { + return JsonUtils.newObjectNode().set("tables", JsonUtils.objectToJsonNode(tableNames)).toString(); } - Collections.sort(tableNames); + if (sortType == "name") { Review comment: Should not use `==` to compare string ########## File path: pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotTableRestletResource.java ########## @@ -200,7 +202,9 @@ public String recommendConfig(String inputStr) { @Produces(MediaType.APPLICATION_JSON) @Path("/tables") @ApiOperation(value = "Lists all tables in cluster", notes = "Lists all tables in cluster") - public String listTableConfigs(@ApiParam(value = "realtime|offline") @QueryParam("type") String tableTypeStr) { + public String listTableData(@ApiParam(value = "realtime|offline") @QueryParam("type") String tableTypeStr, Review comment: Suggest renaming to `listTables` ########## File path: pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotTableRestletResource.java ########## @@ -210,21 +214,60 @@ public String listTableConfigs(@ApiParam(value = "realtime|offline") @QueryParam if (tableType == null) { tableNames = _pinotHelixResourceManager.getAllRawTables(); + } else if (tableType == TableType.REALTIME) { + tableNames = _pinotHelixResourceManager.getAllRealtimeTables(); } else { - if (tableType == TableType.REALTIME) { - tableNames = _pinotHelixResourceManager.getAllRealtimeTables(); - } else { - tableNames = _pinotHelixResourceManager.getAllOfflineTables(); - } + tableNames = _pinotHelixResourceManager.getAllOfflineTables(); + } + if (sortType == null) { + return JsonUtils.newObjectNode().set("tables", JsonUtils.objectToJsonNode(tableNames)).toString(); } - Collections.sort(tableNames); + if (sortType == "name") { + // Sort table names alphabetically + Collections.sort(tableNames, sortAsc ? null : Collections.reverseOrder()); + } else { + // Sort table names based on (1) Create Time or (2) Last Modified Time Review comment: I feel it is cleaner to read all table stats first, then sort on them per the sort type. We need to add `tableName` to the table stats in order to make it work. We should make branches for `creationTime` and `lastModifiedTime`, and throw `IllegalArgumentException` when `sortType` is not valid ########## File path: pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotTableRestletResource.java ########## @@ -210,21 +214,60 @@ public String listTableConfigs(@ApiParam(value = "realtime|offline") @QueryParam if (tableType == null) { tableNames = _pinotHelixResourceManager.getAllRawTables(); + } else if (tableType == TableType.REALTIME) { + tableNames = _pinotHelixResourceManager.getAllRealtimeTables(); } else { - if (tableType == TableType.REALTIME) { - tableNames = _pinotHelixResourceManager.getAllRealtimeTables(); - } else { - tableNames = _pinotHelixResourceManager.getAllOfflineTables(); - } + tableNames = _pinotHelixResourceManager.getAllOfflineTables(); + } + if (sortType == null) { + return JsonUtils.newObjectNode().set("tables", JsonUtils.objectToJsonNode(tableNames)).toString(); } - Collections.sort(tableNames); + if (sortType == "name") { + // Sort table names alphabetically + Collections.sort(tableNames, sortAsc ? null : Collections.reverseOrder()); + } else { + // Sort table names based on (1) Create Time or (2) Last Modified Time + TableType finalTableType = tableType; Review comment: (nit) not used -- 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...@pinot.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For additional commands, e-mail: commits-h...@pinot.apache.org