This is an automated email from the ASF dual-hosted git repository.
xiangfu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pinot.git
The following commit(s) were added to refs/heads/master by this push:
new 55f29fe04d Adding support for listing dimension tables in /tables API
(#11859)
55f29fe04d is described below
commit 55f29fe04dc7ed0ff18737fcec5b272969d6aba1
Author: soumitra-st <[email protected]>
AuthorDate: Sun Oct 29 17:52:35 2023 -0700
Adding support for listing dimension tables in /tables API (#11859)
* Adding support for listing dimension tables in /tables API
* Clarified the dimension table type in comment.
* Using table cache to fetch the list of tables
* Incorporated review feedbacks
---
.../pinot/common/config/provider/TableCache.java | 14 ++++++++++++++
.../api/resources/PinotTableRestletResource.java | 18 +++++++++++++-----
.../helix/core/PinotHelixResourceManager.java | 9 +++++++++
3 files changed, 36 insertions(+), 5 deletions(-)
diff --git
a/pinot-common/src/main/java/org/apache/pinot/common/config/provider/TableCache.java
b/pinot-common/src/main/java/org/apache/pinot/common/config/provider/TableCache.java
index 4522fdec43..9dc0c68454 100644
---
a/pinot-common/src/main/java/org/apache/pinot/common/config/provider/TableCache.java
+++
b/pinot-common/src/main/java/org/apache/pinot/common/config/provider/TableCache.java
@@ -155,6 +155,20 @@ public class TableCache implements PinotConfigProvider {
return _tableNameMap;
}
+ /**
+ * Get all dimension table names.
+ * @return List of dimension table names
+ */
+ public List<String> getAllDimensionTables() {
+ List<String> dimensionTables = new ArrayList<>();
+ for (TableConfigInfo tableConfigInfo : _tableConfigInfoMap.values()) {
+ if (tableConfigInfo._tableConfig.isDimTable()) {
+ dimensionTables.add(tableConfigInfo._tableConfig.getTableName());
+ }
+ }
+ return dimensionTables;
+ }
+
/**
* Returns a map from column name to actual column name for the given table,
or {@code null} if the table schema does
* not exist. For case-insensitive case, the keys of the map are in lower
case.
diff --git
a/pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotTableRestletResource.java
b/pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotTableRestletResource.java
index f0216da013..55ffb01046 100644
---
a/pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotTableRestletResource.java
+++
b/pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotTableRestletResource.java
@@ -268,20 +268,28 @@ public class PinotTableRestletResource {
@Path("/tables")
@Authorize(targetType = TargetType.CLUSTER, action =
Actions.Cluster.GET_TABLE)
@ApiOperation(value = "Lists all tables in cluster", notes = "Lists all
tables in cluster")
- public String listTables(@ApiParam(value = "realtime|offline")
@QueryParam("type") String tableTypeStr,
+ public String listTables(@ApiParam(value = "realtime|offline|dimension")
@QueryParam("type") String tableTypeStr,
@ApiParam(value = "Task type") @QueryParam("taskType") String taskType,
@ApiParam(value = "name|creationTime|lastModifiedTime")
@QueryParam("sortType") String sortTypeStr,
@ApiParam(value = "true|false") @QueryParam("sortAsc")
@DefaultValue("true") boolean sortAsc) {
try {
+ boolean isDimensionTable = "dimension".equalsIgnoreCase(tableTypeStr);
TableType tableType = null;
- if (tableTypeStr != null) {
+ if (isDimensionTable) {
+ // Dimension is a property (isDimTable) of an OFFLINE table.
+ tableType = TableType.OFFLINE;
+ } else if (tableTypeStr != null) {
tableType = TableType.valueOf(tableTypeStr.toUpperCase());
}
SortType sortType = sortTypeStr != null ?
SortType.valueOf(sortTypeStr.toUpperCase()) : SortType.NAME;
- List<String> tableNamesWithType = tableType == null ?
_pinotHelixResourceManager.getAllTables()
- : (tableType == TableType.REALTIME ?
_pinotHelixResourceManager.getAllRealtimeTables()
- : _pinotHelixResourceManager.getAllOfflineTables());
+ // If tableTypeStr is dimension, then tableType is set to
TableType.OFFLINE.
+ // So, checking the isDimensionTable to get the list of dimension tables
only.
+ List<String> tableNamesWithType =
+ isDimensionTable ? _pinotHelixResourceManager.getAllDimensionTables()
+ : tableType == null ? _pinotHelixResourceManager.getAllTables()
+ : (tableType == TableType.REALTIME ?
_pinotHelixResourceManager.getAllRealtimeTables()
+ : _pinotHelixResourceManager.getAllOfflineTables());
if (StringUtils.isNotBlank(taskType)) {
Set<String> tableNamesForTaskType = new HashSet<>();
diff --git
a/pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/PinotHelixResourceManager.java
b/pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/PinotHelixResourceManager.java
index 95db8d35f9..9df5835216 100644
---
a/pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/PinotHelixResourceManager.java
+++
b/pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/PinotHelixResourceManager.java
@@ -729,6 +729,15 @@ public class PinotHelixResourceManager {
return offlineTableNames;
}
+ /**
+ * Get all dimension table names.
+ *
+ * @return List of dimension table names
+ */
+ public List<String> getAllDimensionTables() {
+ return _tableCache.getAllDimensionTables();
+ }
+
/**
* Get all realtime table names.
*
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]