mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-11-09 23:40:05 +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) {
|
public String getCondition(String tableName) {
|
||||||
String condition = getIncludeCondition(tableName);
|
String condition = getIncludeCondition(tableName);
|
||||||
condition = addCondition(condition, getDatabaseCondition(tableName));
|
condition = addCondition(condition, getDatabaseCondition(tableName));
|
||||||
|
condition = addCondition(condition, getDatabaseSchemaCondition(tableName));
|
||||||
condition = addCondition(condition, getServiceCondition(tableName));
|
condition = addCondition(condition, getServiceCondition(tableName));
|
||||||
condition = addCondition(condition, getPipelineTypeCondition(tableName));
|
condition = addCondition(condition, getPipelineTypeCondition(tableName));
|
||||||
condition = addCondition(condition, getParentCondition(tableName));
|
condition = addCondition(condition, getParentCondition(tableName));
|
||||||
@ -70,6 +71,11 @@ public class ListFilter {
|
|||||||
return database == null ? "" : getFqnPrefixCondition(tableName, database);
|
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) {
|
public String getServiceCondition(String tableName) {
|
||||||
String service = queryParams.get("service");
|
String service = queryParams.get("service");
|
||||||
return service == null ? "" : getFqnPrefixCondition(tableName, 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"))
|
schema = @Schema(type = "string", example = "snowflakeWestCoast.financeDB"))
|
||||||
@QueryParam("database")
|
@QueryParam("database")
|
||||||
String databaseParam,
|
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) ")
|
@Parameter(description = "Limit the number tables returned. (1 to 1000000, default = " + "10) ")
|
||||||
@DefaultValue("10")
|
@DefaultValue("10")
|
||||||
@Min(0)
|
@Min(0)
|
||||||
@ -174,7 +179,10 @@ public class TableResource extends EntityResource<Table, TableRepository> {
|
|||||||
@DefaultValue("non-deleted")
|
@DefaultValue("non-deleted")
|
||||||
Include include)
|
Include include)
|
||||||
throws IOException {
|
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);
|
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());
|
assertEquals(tableList.getData().size(), tableList1.getData().size());
|
||||||
assertFields(tableList1.getData(), fields);
|
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
|
// GET .../tables?fields=usageSummary,owner
|
||||||
final String fields1 = "usageSummary,owner";
|
final String fields1 = "usageSummary,owner";
|
||||||
queryParams = new HashMap<>();
|
queryParams = new HashMap<>();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user