mirror of
https://github.com/datahub-project/datahub.git
synced 2025-11-03 12:16:10 +00:00
fix(glossary):default browse path for glossary term (#2788)
This commit is contained in:
parent
44ed2f3684
commit
ae014bf2e1
@ -3651,7 +3651,7 @@
|
||||
"Aspect" : {
|
||||
"name" : "glossaryTermInfo"
|
||||
}
|
||||
}, "com.linkedin.common.Ownership", "com.linkedin.common.Status" ]
|
||||
}, "com.linkedin.common.Ownership", "com.linkedin.common.Status", "com.linkedin.common.BrowsePaths" ]
|
||||
}
|
||||
},
|
||||
"doc" : "The list of metadata aspects associated with the GlossaryTerm. Depending on the use case, this can either be all, or a selection, of supported aspects."
|
||||
|
||||
@ -30,6 +30,28 @@
|
||||
"doc" : "The entity (e.g. a service URN) which performs the change on behalf of the Actor and must be authorized to act as the Actor.",
|
||||
"optional" : true
|
||||
} ]
|
||||
}, {
|
||||
"type" : "record",
|
||||
"name" : "BrowsePaths",
|
||||
"namespace" : "com.linkedin.common",
|
||||
"doc" : "Shared aspect containing Browse Paths to be indexed for an entity.",
|
||||
"fields" : [ {
|
||||
"name" : "paths",
|
||||
"type" : {
|
||||
"type" : "array",
|
||||
"items" : "string"
|
||||
},
|
||||
"doc" : "A list of valid browse paths for the entity.\n\nBrowse paths are expected to be backslash-separated strings. For example: 'prod/snowflake/datasetName'",
|
||||
"Searchable" : {
|
||||
"/*" : {
|
||||
"fieldName" : "browsePaths",
|
||||
"fieldType" : "BROWSE_PATH"
|
||||
}
|
||||
}
|
||||
} ],
|
||||
"Aspect" : {
|
||||
"name" : "browsePaths"
|
||||
}
|
||||
}, {
|
||||
"type" : "typeref",
|
||||
"name" : "GlossaryNodeUrn",
|
||||
@ -306,7 +328,7 @@
|
||||
"Aspect" : {
|
||||
"name" : "glossaryTermKey"
|
||||
}
|
||||
}, "com.linkedin.glossary.GlossaryTermInfo", "com.linkedin.common.Ownership", "com.linkedin.common.Status" ]
|
||||
}, "com.linkedin.glossary.GlossaryTermInfo", "com.linkedin.common.Ownership", "com.linkedin.common.Status", "com.linkedin.common.BrowsePaths" ]
|
||||
}, "com.linkedin.metadata.key.GlossaryTermKey", {
|
||||
"type" : "record",
|
||||
"name" : "AggregationMetadata",
|
||||
|
||||
@ -32,7 +32,7 @@ public class GlossaryTermInfoIndexBuilder extends BaseIndexBuilder<GlossaryTermI
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
private static String buildBrowsePath(@Nonnull GlossaryTermUrn urn) {
|
||||
public static String buildBrowsePath(@Nonnull GlossaryTermUrn urn) {
|
||||
return "/" + urn.getNameEntity().replace('.', '/').toLowerCase();
|
||||
}
|
||||
|
||||
|
||||
@ -4635,7 +4635,8 @@
|
||||
"doc": "Properties associated with a GlossaryTerm"
|
||||
},
|
||||
"com.linkedin.pegasus2avro.common.Ownership",
|
||||
"com.linkedin.pegasus2avro.common.Status"
|
||||
"com.linkedin.pegasus2avro.common.Status",
|
||||
"com.linkedin.pegasus2avro.common.BrowsePaths"
|
||||
]
|
||||
},
|
||||
"name": "aspects",
|
||||
|
||||
@ -4611,7 +4611,7 @@ class GlossaryTermSnapshotClass(DictWrapper):
|
||||
RECORD_SCHEMA = get_schema_type("com.linkedin.pegasus2avro.metadata.snapshot.GlossaryTermSnapshot")
|
||||
def __init__(self,
|
||||
urn: str,
|
||||
aspects: List[Union["GlossaryTermKeyClass", "GlossaryTermInfoClass", "OwnershipClass", "StatusClass"]],
|
||||
aspects: List[Union["GlossaryTermKeyClass", "GlossaryTermInfoClass", "OwnershipClass", "StatusClass", "BrowsePathsClass"]],
|
||||
):
|
||||
super().__init__()
|
||||
|
||||
@ -4642,12 +4642,12 @@ class GlossaryTermSnapshotClass(DictWrapper):
|
||||
|
||||
|
||||
@property
|
||||
def aspects(self) -> List[Union["GlossaryTermKeyClass", "GlossaryTermInfoClass", "OwnershipClass", "StatusClass"]]:
|
||||
def aspects(self) -> List[Union["GlossaryTermKeyClass", "GlossaryTermInfoClass", "OwnershipClass", "StatusClass", "BrowsePathsClass"]]:
|
||||
"""Getter: The list of metadata aspects associated with the GlossaryTerm. Depending on the use case, this can either be all, or a selection, of supported aspects."""
|
||||
return self._inner_dict.get('aspects') # type: ignore
|
||||
|
||||
@aspects.setter
|
||||
def aspects(self, value: List[Union["GlossaryTermKeyClass", "GlossaryTermInfoClass", "OwnershipClass", "StatusClass"]]) -> None:
|
||||
def aspects(self, value: List[Union["GlossaryTermKeyClass", "GlossaryTermInfoClass", "OwnershipClass", "StatusClass", "BrowsePathsClass"]]) -> None:
|
||||
"""Setter: The list of metadata aspects associated with the GlossaryTerm. Depending on the use case, this can either be all, or a selection, of supported aspects."""
|
||||
self._inner_dict['aspects'] = value
|
||||
|
||||
|
||||
@ -4580,7 +4580,8 @@
|
||||
}
|
||||
},
|
||||
"com.linkedin.pegasus2avro.common.Ownership",
|
||||
"com.linkedin.pegasus2avro.common.Status"
|
||||
"com.linkedin.pegasus2avro.common.Status",
|
||||
"com.linkedin.pegasus2avro.common.BrowsePaths"
|
||||
]
|
||||
},
|
||||
"doc": "The list of metadata aspects associated with the GlossaryTerm. Depending on the use case, this can either be all, or a selection, of supported aspects."
|
||||
|
||||
@ -4579,7 +4579,8 @@
|
||||
}
|
||||
},
|
||||
"com.linkedin.pegasus2avro.common.Ownership",
|
||||
"com.linkedin.pegasus2avro.common.Status"
|
||||
"com.linkedin.pegasus2avro.common.Status",
|
||||
"com.linkedin.pegasus2avro.common.BrowsePaths"
|
||||
]
|
||||
},
|
||||
"doc": "The list of metadata aspects associated with the GlossaryTerm. Depending on the use case, this can either be all, or a selection, of supported aspects."
|
||||
|
||||
@ -6,6 +6,7 @@ import com.linkedin.common.urn.DashboardUrn;
|
||||
import com.linkedin.common.urn.DataFlowUrn;
|
||||
import com.linkedin.common.urn.DataJobUrn;
|
||||
import com.linkedin.common.urn.DatasetUrn;
|
||||
import com.linkedin.common.urn.GlossaryTermUrn;
|
||||
import com.linkedin.common.urn.Urn;
|
||||
import com.linkedin.data.template.RecordTemplate;
|
||||
import com.linkedin.data.template.StringArray;
|
||||
@ -20,11 +21,14 @@ import com.linkedin.metadata.aspect.DataJobAspect;
|
||||
import com.linkedin.metadata.aspect.DataJobAspectArray;
|
||||
import com.linkedin.metadata.aspect.DatasetAspect;
|
||||
import com.linkedin.metadata.aspect.DatasetAspectArray;
|
||||
import com.linkedin.metadata.aspect.GlossaryTermAspect;
|
||||
import com.linkedin.metadata.aspect.GlossaryTermAspectArray;
|
||||
import com.linkedin.metadata.builders.search.ChartIndexBuilder;
|
||||
import com.linkedin.metadata.builders.search.DashboardIndexBuilder;
|
||||
import com.linkedin.metadata.builders.search.DataFlowIndexBuilder;
|
||||
import com.linkedin.metadata.builders.search.DataJobIndexBuilder;
|
||||
import com.linkedin.metadata.builders.search.DatasetIndexBuilder;
|
||||
import com.linkedin.metadata.builders.search.GlossaryTermInfoIndexBuilder;
|
||||
import com.linkedin.metadata.dao.utils.RecordUtils;
|
||||
import com.linkedin.metadata.snapshot.Snapshot;
|
||||
import java.net.URISyntaxException;
|
||||
@ -59,6 +63,8 @@ public class BrowsePathUtils {
|
||||
return DataFlowIndexBuilder.buildBrowsePath(DataFlowUrn.createFromUrn(urn));
|
||||
case "dataJob":
|
||||
return DataJobIndexBuilder.buildBrowsePath(DataJobUrn.createFromUrn(urn));
|
||||
case "glossaryTerm":
|
||||
return GlossaryTermInfoIndexBuilder.buildBrowsePath(GlossaryTermUrn.createFromUrn(urn));
|
||||
default:
|
||||
log.debug(String.format("Failed to generate default browse path for unknown entity type %s", urn.getEntityType()));
|
||||
return "";
|
||||
@ -85,6 +91,20 @@ public class BrowsePathUtils {
|
||||
aspects.add(DatasetAspect.create(defaultBrowsePaths));
|
||||
}
|
||||
}
|
||||
if (urn.getEntityType().equals("glossaryTerm")) {
|
||||
final GlossaryTermAspectArray aspects = snapshot.getGlossaryTermSnapshot().getAspects();
|
||||
boolean hasBrowse = false;
|
||||
if (browsePathEntity != null) {
|
||||
final GlossaryTermAspectArray aspectsWithExistingBrowse = browsePathEntity.getValue().getGlossaryTermSnapshot().getAspects();
|
||||
hasBrowse = aspects.stream()
|
||||
.filter(glossaryTermAspect -> glossaryTermAspect.isBrowsePaths()).findFirst().isPresent()
|
||||
|| aspectsWithExistingBrowse.stream()
|
||||
.filter(glossaryTermAspect -> glossaryTermAspect.isBrowsePaths()).findFirst().isPresent();
|
||||
}
|
||||
if (!hasBrowse) {
|
||||
aspects.add(GlossaryTermAspect.create(defaultBrowsePaths));
|
||||
}
|
||||
}
|
||||
if (urn.getEntityType().equals("chart")) {
|
||||
final ChartAspectArray aspects = snapshot.getChartSnapshot().getAspects();
|
||||
boolean hasBrowse = false;
|
||||
|
||||
@ -4,8 +4,10 @@ import com.linkedin.glossary.GlossaryTermInfo
|
||||
import com.linkedin.metadata.key.GlossaryTermKey
|
||||
import com.linkedin.common.Ownership
|
||||
import com.linkedin.common.Status
|
||||
import com.linkedin.common.BrowsePaths
|
||||
|
||||
|
||||
/**
|
||||
* A union of all supported metadata aspects for a CorpUser
|
||||
*/
|
||||
typeref GlossaryTermAspect = union[GlossaryTermKey, GlossaryTermInfo, Ownership, Status]
|
||||
typeref GlossaryTermAspect = union[GlossaryTermKey, GlossaryTermInfo, Ownership, Status,BrowsePaths]
|
||||
Loading…
x
Reference in New Issue
Block a user