mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-11-02 03:29:03 +00:00
Filter tables by databaseSchema (#11574)
This commit is contained in:
parent
663083e55e
commit
4c77eaea72
@ -44,6 +44,7 @@ public class ListFilter {
|
||||
public String getCondition(String tableName) {
|
||||
String condition = getIncludeCondition(tableName);
|
||||
condition = addCondition(condition, getDatabaseCondition(tableName));
|
||||
condition = addCondition(condition, getDatabaseSchemaCondition(tableName));
|
||||
condition = addCondition(condition, getServiceCondition(tableName));
|
||||
condition = addCondition(condition, getPipelineTypeCondition(tableName));
|
||||
condition = addCondition(condition, getParentCondition(tableName));
|
||||
@ -70,6 +71,11 @@ public class ListFilter {
|
||||
return database == null ? "" : getFqnPrefixCondition(tableName, database);
|
||||
}
|
||||
|
||||
public String getDatabaseSchemaCondition(String tableName) {
|
||||
String databaseSchema = queryParams.get("databaseSchema");
|
||||
return databaseSchema == null ? "" : getFqnPrefixCondition(tableName, databaseSchema);
|
||||
}
|
||||
|
||||
public String getServiceCondition(String tableName) {
|
||||
String service = queryParams.get("service");
|
||||
return service == null ? "" : getFqnPrefixCondition(tableName, service);
|
||||
|
||||
@ -155,6 +155,11 @@ public class TableResource extends EntityResource<Table, TableRepository> {
|
||||
schema = @Schema(type = "string", example = "snowflakeWestCoast.financeDB"))
|
||||
@QueryParam("database")
|
||||
String databaseParam,
|
||||
@Parameter(
|
||||
description = "Filter tables by databaseSchema fully qualified name",
|
||||
schema = @Schema(type = "string", example = "snowflakeWestCoast.financeDB.schema"))
|
||||
@QueryParam("databaseSchema")
|
||||
String databaseSchemaParam,
|
||||
@Parameter(description = "Limit the number tables returned. (1 to 1000000, default = " + "10) ")
|
||||
@DefaultValue("10")
|
||||
@Min(0)
|
||||
@ -174,7 +179,10 @@ public class TableResource extends EntityResource<Table, TableRepository> {
|
||||
@DefaultValue("non-deleted")
|
||||
Include include)
|
||||
throws IOException {
|
||||
ListFilter filter = new ListFilter(include).addQueryParam("database", databaseParam);
|
||||
ListFilter filter =
|
||||
new ListFilter(include)
|
||||
.addQueryParam("database", databaseParam)
|
||||
.addQueryParam("databaseSchema", databaseSchemaParam);
|
||||
return super.listInternal(uriInfo, securityContext, fieldsParam, filter, limitParam, before, after);
|
||||
}
|
||||
|
||||
|
||||
@ -1484,6 +1484,14 @@ public class TableResourceTest extends EntityResourceTest<Table, CreateTable> {
|
||||
assertEquals(tableList.getData().size(), tableList1.getData().size());
|
||||
assertFields(tableList1.getData(), fields);
|
||||
|
||||
// List tables with databaseSchemaFQN as filter
|
||||
queryParams = new HashMap<>();
|
||||
queryParams.put("fields", fields);
|
||||
queryParams.put("databaseSchema", DATABASE_SCHEMA.getFullyQualifiedName());
|
||||
tableList1 = listEntities(queryParams, ADMIN_AUTH_HEADERS);
|
||||
assertEquals(tableList.getData().size(), tableList1.getData().size());
|
||||
assertFields(tableList1.getData(), fields);
|
||||
|
||||
// GET .../tables?fields=usageSummary,owner
|
||||
final String fields1 = "usageSummary,owner";
|
||||
queryParams = new HashMap<>();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user