Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cypherean committed Oct 29, 2024
1 parent 2290a82 commit dbc583e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ public String generateTableMetadataServerURL(String tableNameWithType, List<Stri
Set<String> segmentsToInclude, String endpoint) {
tableNameWithType = URLEncoder.encode(tableNameWithType, StandardCharsets.UTF_8);
String paramsStr = generateColumnsParam(columns)
+ generateSegmentsParam(new ArrayList<>(segmentsToInclude));
+ generateSegmentsParam(segmentsToInclude);
return String.format("%s/tables/%s/metadata?%s", endpoint, tableNameWithType, paramsStr);
}

Expand Down Expand Up @@ -479,7 +479,7 @@ private String generateColumnsParam(List<String> columns) {
return paramsStr;
}

private String generateSegmentsParam(List<String> values) {
private String generateSegmentsParam(Set<String> values) {
String paramsStr = "";
if (values == null || values.isEmpty()) {
return paramsStr;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,8 @@ public String getSegmentMetadata(
@ApiParam(value = "Table Name with type", required = true) @PathParam("tableName") String tableName,
@ApiParam(value = "Column name", allowMultiple = true) @QueryParam("columns") @DefaultValue("")
List<String> columns,
@ApiParam(value = "List of segments to fetch metadata for") @QueryParam("segmentsToInclude") @DefaultValue("")
List<String> segmentsToInclude, @Context HttpHeaders headers)
@ApiParam(value = "List of segments to fetch metadata for", allowMultiple = true) @QueryParam("segmentsToInclude")
@DefaultValue("") List<String> segmentsToInclude, @Context HttpHeaders headers)
throws WebApplicationException {
tableName = DatabaseUtils.translateTableName(tableName, headers);
InstanceDataManager instanceDataManager = _serverInstance.getInstanceDataManager();
Expand All @@ -212,6 +212,14 @@ public String getSegmentMetadata(
decodedColumns.add(URIUtils.decode(column));
}

List<String> decodedSegments = new ArrayList<>();
if (segmentsToInclude != null && !segmentsToInclude.isEmpty()) {
for (String segment : segmentsToInclude) {
if (!segment.isEmpty()) {
decodedSegments.add(URIUtils.decode(segment));
}
}
}
boolean allColumns = false;
// For robustness, loop over all columns, if any of the columns is "*", return metadata for all columns.
for (String column : decodedColumns) {
Expand All @@ -222,8 +230,8 @@ public String getSegmentMetadata(
}
Set<String> columnSet = allColumns ? null : new HashSet<>(decodedColumns);
List<SegmentDataManager> segmentDataManagers;
if (segmentsToInclude != null && !segmentsToInclude.isEmpty()) {
segmentDataManagers = tableDataManager.acquireSegments(segmentsToInclude, new ArrayList<>());
if (!decodedSegments.isEmpty()) {
segmentDataManagers = tableDataManager.acquireSegments(decodedSegments, new ArrayList<>());
} else {
segmentDataManagers = tableDataManager.acquireAllSegments();
}
Expand Down

0 comments on commit dbc583e

Please sign in to comment.