Skip to content

Commit

Permalink
[AMORO-2316] The Files page supports filtering by partition name and …
Browse files Browse the repository at this point in the history
…sorting by dictionary value (apache#2343)

* fix-2316

* fix-2316

* change param name

---------

Co-authored-by: shendanfeng <shendanfeng01@corp.netease.com>
  • Loading branch information
2 people authored and ShawHee committed Dec 29, 2023
1 parent 2c3108a commit c140ddd
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@

import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -423,12 +424,18 @@ public void getTablePartitions(Context ctx) {
String catalog = ctx.pathParam("catalog");
String database = ctx.pathParam("db");
String table = ctx.pathParam("table");
String filter = ctx.queryParamAsClass("filter", String.class).getOrDefault("");
Integer page = ctx.queryParamAsClass("page", Integer.class).getOrDefault(1);
Integer pageSize = ctx.queryParamAsClass("pageSize", Integer.class).getOrDefault(20);

List<PartitionBaseInfo> partitionBaseInfos =
tableDescriptor.getTablePartition(
TableIdentifier.of(catalog, database, table).buildTableIdentifier());
partitionBaseInfos =
partitionBaseInfos.stream()
.filter(e -> e.getPartition().contains(filter))
.sorted(Comparator.comparing(PartitionBaseInfo::getPartition).reversed())
.collect(Collectors.toList());
int offset = (page - 1) * pageSize;
PageResult<PartitionBaseInfo> amsPageResult =
PageResult.of(partitionBaseInfos, offset, pageSize);
Expand Down

0 comments on commit c140ddd

Please sign in to comment.