Skip to content

Commit

Permalink
includeParentChildInfo in get
Browse files Browse the repository at this point in the history
  • Loading branch information
Yingjian Wu committed Jul 10, 2024
1 parent 93b2c57 commit 2746907
Showing 7 changed files with 60 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -266,7 +266,7 @@ default TableDto getTable(
Boolean includeDataMetadata
) {
return getTable(catalogName, databaseName, tableName, includeInfo,
includeDefinitionMetadata, includeDataMetadata, false);
includeDefinitionMetadata, includeDataMetadata, false, false);
}

/**
@@ -279,6 +279,7 @@ default TableDto getTable(
* @param includeDefinitionMetadata true if the definition metadata to be included
* @param includeDataMetadata true if the data metadata to be included
* @param includeInfoDetails true if the more info details to be included
* @param includeParentChildInfo true if includeParentChildInfo
* @return table
*/
default TableDto getTable(
@@ -288,10 +289,12 @@ default TableDto getTable(
Boolean includeInfo,
Boolean includeDefinitionMetadata,
Boolean includeDataMetadata,
Boolean includeInfoDetails
Boolean includeInfoDetails,
Boolean includeParentChildInfo
) {
return getTable(catalogName, databaseName, tableName, includeInfo,
includeDefinitionMetadata, includeDataMetadata, includeInfoDetails, false);
includeDefinitionMetadata, includeDataMetadata, includeInfoDetails, false,
includeParentChildInfo);
}

/**
@@ -306,6 +309,7 @@ default TableDto getTable(
* @param includeInfoDetails true if the more info details to be included
* @param includeMetadataLocationOnly true if only metadata location needs to be included.
* All other flags are ignored if this is set to true.
* @param includeParentChildInfo true if includeParentChildInfo
* @return table
*/
@GET
@@ -333,7 +337,10 @@ TableDto getTable(
Boolean includeInfoDetails,
@DefaultValue("false")
@QueryParam("includeMetadataLocationOnly")
Boolean includeMetadataLocationOnly
Boolean includeMetadataLocationOnly,
@DefaultValue("false")
@QueryParam("includeParentChildInfo")
Boolean includeParentChildInfo
);

/**
Original file line number Diff line number Diff line change
@@ -81,7 +81,7 @@ default TableDto getTable(
final boolean includeInfoDetails
) {
return getTable(catalogName, databaseName, tableName, includeInfo, includeDefinitionMetadata,
includeDataMetadata, includeInfoDetails, false);
includeDataMetadata, includeInfoDetails, false, false);
}

/**
@@ -96,6 +96,7 @@ default TableDto getTable(
* @param includeInfoDetails true if the more info details to be included
* @param includeMetadataLocationOnly true if only metadata location needs to be included.
* All other flags are ignored
* @param includeParentChildInfo true if includeParentChildInfo needs to be included.
* @return table
*/
TableDto getTable(
@@ -106,7 +107,8 @@ TableDto getTable(
final boolean includeDefinitionMetadata,
final boolean includeDataMetadata,
final boolean includeInfoDetails,
final boolean includeMetadataLocationOnly
final boolean includeMetadataLocationOnly,
final boolean includeParentChildInfo
);

/**
Original file line number Diff line number Diff line change
@@ -676,7 +676,7 @@ class MetacatSmokeSpec extends Specification {
then:
noExceptionThrown()
when:
def tableMetadataOnly = api.getTable(catalogName, databaseName, tableName, true, false, false, false, true)
def tableMetadataOnly = api.getTable(catalogName, databaseName, tableName, true, false, false, false, true, false)
then:
tableMetadataOnly.getFields().size() == 0
tableMetadataOnly.getMetadata().get('metadata_location') != null
@@ -711,7 +711,7 @@ class MetacatSmokeSpec extends Specification {
updatedTable.getFields().get(1).getSource_type().equals('string')
when:
api.updateTable(catalogName, databaseName, tableName, tableDto)
def tableWithDetails = api.getTable(catalogName, databaseName, tableName, true, false, false, true)
def tableWithDetails = api.getTable(catalogName, databaseName, tableName, true, false, false, true, false)
then:
tableWithDetails.getMetadata().get('metadata_content') != null
when:
Original file line number Diff line number Diff line change
@@ -655,7 +655,10 @@ public TableDto getTable(
@ApiParam(value = "Whether to include only the metadata location in the response")
@RequestParam(
name = "includeMetadataLocationOnly",
defaultValue = "false") final boolean includeMetadataLocationOnly
defaultValue = "false") final boolean includeMetadataLocationOnly,
@RequestParam(
name = "includeParentChildInfo",
defaultValue = "false") final boolean includeParentChildInfo
) {
final Supplier<QualifiedName> qualifiedNameSupplier =
() -> QualifiedName.ofTable(catalogName, databaseName, tableName);
@@ -669,6 +672,7 @@ public TableDto getTable(
.put("includeDataMetadata", String.valueOf(includeDataMetadata))
.put("includeMetadataFromConnector", String.valueOf(includeInfoDetails))
.put("includeMetadataLocationOnly", String.valueOf(includeMetadataLocationOnly))
.put("includeParentChildInfo", String.valueOf(includeParentChildInfo))
.build(),
() -> {
final Optional<TableDto> table = this.tableService.get(
@@ -680,6 +684,7 @@ public TableDto getTable(
.disableOnReadMetadataIntercetor(false)
.includeMetadataFromConnector(includeInfoDetails)
.includeMetadataLocationOnly(includeMetadataLocationOnly)
.includeParentChildInfo(includeParentChildInfo)
.useCache(true)
.build()
);
Original file line number Diff line number Diff line change
@@ -36,4 +36,5 @@ public class GetTableServiceParameters {
private final boolean useCache;
private final boolean includeMetadataFromConnector;
private final boolean includeMetadataLocationOnly;
private final boolean includeParentChildInfo;
}
Original file line number Diff line number Diff line change
@@ -518,7 +518,7 @@ public Optional<TableDto> get(final QualifiedName name, final GetTableServicePar
&& definitionMetadata.get().has(ParentChildRelMetadataConstants.PARENT_CHILD_RELINFO)) {
definitionMetadata.get().remove(ParentChildRelMetadataConstants.PARENT_CHILD_RELINFO);
}
if (config.isParentChildGetEnabled()) {
if (config.isParentChildGetEnabled() || getTableServiceParameters.isIncludeParentChildInfo()) {
final ObjectNode parentChildRelObjectNode = createParentChildObjectNode(name);
if (!parentChildRelObjectNode.isEmpty()) {
if (!definitionMetadata.isPresent()) {
Original file line number Diff line number Diff line change
@@ -480,7 +480,7 @@ class TableServiceImplSpec extends Specification {
noExceptionThrown()
}

def "Mock Parent Child Relationship Drop"() {
def "Mock Parent Child Relationship Drop with isParentChildGetEnabled enabled and getParameter disabled"() {
given:
def name = QualifiedName.ofTable("clone", "clone", "child")

@@ -577,7 +577,7 @@ class TableServiceImplSpec extends Specification {
noExceptionThrown()
}

def "Mock Parent Child Relationship Get"() {
def "Mock Parent Child Relationship Get with GetTableServiceParameters disabled"() {
when:
service.get(name,GetTableServiceParameters.builder().
disableOnReadMetadataIntercetor(false)
@@ -609,6 +609,39 @@ class TableServiceImplSpec extends Specification {
1 * parentChildRelSvc.isParentTable(name)
}

def "Mock Parent Child Relationship Get with GetTableServiceParameters enabled"() {
when:
service.get(name,GetTableServiceParameters.builder().
disableOnReadMetadataIntercetor(false)
.includeDataMetadata(true)
.includeDefinitionMetadata(true)
.includeParentChildInfo(true)
.build())
then:
1 * connectorManager.getCatalogConfig(_) >> catalogConfig
1 * usermetadataService.getDefinitionMetadataWithInterceptor(_,_) >> Optional.empty()
1 * usermetadataService.getDataMetadata(_) >> Optional.empty()
0 * usermetadataService.getDefinitionMetadata(_) >> Optional.empty()
1 * config.isParentChildGetEnabled() >> false
1 * parentChildRelSvc.getParents(name)
1 * parentChildRelSvc.isParentTable(name)

when:
service.get(name,GetTableServiceParameters.builder().
disableOnReadMetadataIntercetor(false)
.includeDataMetadata(true)
.includeDefinitionMetadata(true)
.build())
then:
1 * connectorManager.getCatalogConfig(_) >> catalogConfig
1 * usermetadataService.getDefinitionMetadataWithInterceptor(_,_) >> Optional.empty()
1 * usermetadataService.getDataMetadata(_) >> Optional.empty()
0 * usermetadataService.getDefinitionMetadata(_) >> Optional.empty()
1 * config.isParentChildGetEnabled() >> true
1 * parentChildRelSvc.getParents(name)
1 * parentChildRelSvc.isParentTable(name)
}

def "Will not throw on Successful Table Update with Failed Get"() {
given:
def updatedTableDto = new TableDto(name: name, serde: new StorageDto(uri: 's3:/a/b/c'))

0 comments on commit 2746907

Please sign in to comment.