mirror of
https://github.com/datahub-project/datahub.git
synced 2025-12-24 08:28:12 +00:00
feat(lineage): give via and paths in entity lineage response (#10192)
This commit is contained in:
parent
57de905c66
commit
888a1de9fc
@ -1,8 +1,10 @@
|
||||
package com.linkedin.datahub.graphql.resolvers.load;
|
||||
|
||||
import static com.linkedin.datahub.graphql.resolvers.ResolverUtils.*;
|
||||
import static com.linkedin.datahub.graphql.types.mappers.MapperUtils.*;
|
||||
|
||||
import com.datahub.authorization.AuthorizationConfiguration;
|
||||
import com.linkedin.common.UrnArrayArray;
|
||||
import com.linkedin.common.urn.Urn;
|
||||
import com.linkedin.common.urn.UrnUtils;
|
||||
import com.linkedin.data.template.SetMode;
|
||||
@ -156,6 +158,11 @@ public class EntityLineageResultResolver
|
||||
result.setUpdatedActor(UrnToEntityMapper.map(context, updatedActor));
|
||||
}
|
||||
result.setIsManual(lineageRelationship.hasIsManual() && lineageRelationship.isIsManual());
|
||||
if (lineageRelationship.getPaths() != null) {
|
||||
UrnArrayArray paths = lineageRelationship.getPaths();
|
||||
result.setPaths(
|
||||
paths.stream().map(path -> mapPath(context, path)).collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -3,9 +3,11 @@ package com.linkedin.datahub.graphql.types.mappers;
|
||||
import static com.linkedin.datahub.graphql.util.SearchInsightsUtil.*;
|
||||
import static com.linkedin.metadata.utils.SearchUtil.*;
|
||||
|
||||
import com.linkedin.common.UrnArray;
|
||||
import com.linkedin.common.urn.Urn;
|
||||
import com.linkedin.datahub.graphql.QueryContext;
|
||||
import com.linkedin.datahub.graphql.generated.AggregationMetadata;
|
||||
import com.linkedin.datahub.graphql.generated.EntityPath;
|
||||
import com.linkedin.datahub.graphql.generated.FacetMetadata;
|
||||
import com.linkedin.datahub.graphql.generated.MatchedField;
|
||||
import com.linkedin.datahub.graphql.generated.SearchResult;
|
||||
@ -104,4 +106,11 @@ public class MapperUtils {
|
||||
return new SearchSuggestion(
|
||||
suggestion.getText(), suggestion.getScore(), Math.toIntExact(suggestion.getFrequency()));
|
||||
}
|
||||
|
||||
public static EntityPath mapPath(@Nullable final QueryContext context, UrnArray path) {
|
||||
EntityPath entityPath = new EntityPath();
|
||||
entityPath.setPath(
|
||||
path.stream().map(p -> UrnToEntityMapper.map(context, p)).collect(Collectors.toList()));
|
||||
return entityPath;
|
||||
}
|
||||
}
|
||||
|
||||
@ -3,11 +3,9 @@ package com.linkedin.datahub.graphql.types.mappers;
|
||||
import static com.linkedin.datahub.graphql.types.mappers.MapperUtils.*;
|
||||
import static com.linkedin.datahub.graphql.util.SearchInsightsUtil.*;
|
||||
|
||||
import com.linkedin.common.UrnArray;
|
||||
import com.linkedin.data.template.RecordTemplate;
|
||||
import com.linkedin.datahub.graphql.QueryContext;
|
||||
import com.linkedin.datahub.graphql.generated.Entity;
|
||||
import com.linkedin.datahub.graphql.generated.EntityPath;
|
||||
import com.linkedin.datahub.graphql.generated.FreshnessStats;
|
||||
import com.linkedin.datahub.graphql.generated.SearchAcrossLineageResult;
|
||||
import com.linkedin.datahub.graphql.generated.SearchAcrossLineageResults;
|
||||
@ -72,13 +70,7 @@ public class UrnSearchAcrossLineageResultsMapper<T extends RecordTemplate, E ext
|
||||
.setDegree(searchEntity.getDegree())
|
||||
.setDegrees(new ArrayList<>(searchEntity.getDegrees()))
|
||||
.setExplored(Boolean.TRUE.equals(searchEntity.isExplored()))
|
||||
.setIgnoredAsHop(Boolean.TRUE.equals(searchEntity.isIgnoredAsHop()))
|
||||
.build();
|
||||
}
|
||||
|
||||
private EntityPath mapPath(@Nullable final QueryContext context, UrnArray path) {
|
||||
EntityPath entityPath = new EntityPath();
|
||||
entityPath.setPath(
|
||||
path.stream().map(p -> UrnToEntityMapper.map(context, p)).collect(Collectors.toList()));
|
||||
return entityPath;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1331,6 +1331,10 @@ type LineageRelationship {
|
||||
"""
|
||||
isManual: Boolean
|
||||
|
||||
"""
|
||||
The paths traversed for this relationship
|
||||
"""
|
||||
paths: [EntityPath]
|
||||
}
|
||||
|
||||
"""
|
||||
|
||||
@ -747,6 +747,11 @@ type SearchAcrossLineageResult {
|
||||
"""
|
||||
explored: Boolean!
|
||||
|
||||
"""
|
||||
Whether this relationship was ignored as a hop
|
||||
"""
|
||||
ignoredAsHop: Boolean!
|
||||
|
||||
}
|
||||
|
||||
"""
|
||||
|
||||
@ -389,9 +389,11 @@ public class ESGraphQueryDAO {
|
||||
|| platformMatches(
|
||||
lineageRelationship.getEntity(),
|
||||
ignoreAsHops.get(entityType)))))
|
||||
.map(LineageRelationship::getEntity)
|
||||
.forEach(additionalCurrentLevel::add);
|
||||
;
|
||||
.forEach(
|
||||
lineageRelationship -> {
|
||||
additionalCurrentLevel.add(lineageRelationship.getEntity());
|
||||
lineageRelationship.setIgnoredAsHop(true);
|
||||
});
|
||||
if (!additionalCurrentLevel.isEmpty()) {
|
||||
Stream<Urn> ignoreAsHopUrns =
|
||||
processOneHopLineage(
|
||||
|
||||
@ -739,6 +739,7 @@ public class LineageSearchService {
|
||||
entity.setDegrees(lineageRelationship.getDegrees());
|
||||
}
|
||||
entity.setExplored(Boolean.TRUE.equals(lineageRelationship.isExplored()));
|
||||
entity.setIgnoredAsHop(Boolean.TRUE.equals(lineageRelationship.isIgnoredAsHop()));
|
||||
}
|
||||
return entity;
|
||||
}
|
||||
|
||||
@ -72,4 +72,9 @@ record LineageRelationship {
|
||||
* Marks this relationship as explored during the graph walk
|
||||
*/
|
||||
explored: optional boolean
|
||||
|
||||
/**
|
||||
* Whether this relationship was ignored as a hop while performing the graph walk
|
||||
*/
|
||||
ignoredAsHop: optional boolean
|
||||
}
|
||||
|
||||
@ -34,4 +34,9 @@ record LineageSearchEntity includes SearchEntity {
|
||||
* Marks an entity as having been explored for as a part of the graph walk
|
||||
*/
|
||||
explored: optional boolean
|
||||
|
||||
/**
|
||||
* Whether this relationship was ignored as a hop while performing the graph walk
|
||||
*/
|
||||
ignoredAsHop: optional boolean
|
||||
}
|
||||
@ -6210,6 +6210,11 @@
|
||||
"type" : "boolean",
|
||||
"doc" : "Marks an entity as having been explored for as a part of the graph walk",
|
||||
"optional" : true
|
||||
}, {
|
||||
"name" : "ignoredAsHop",
|
||||
"type" : "boolean",
|
||||
"doc" : "Whether this relationship was ignored as a hop while performing the graph walk",
|
||||
"optional" : true
|
||||
} ]
|
||||
}
|
||||
},
|
||||
|
||||
@ -182,6 +182,11 @@
|
||||
"type" : "boolean",
|
||||
"doc" : "Marks this relationship as explored during the graph walk",
|
||||
"optional" : true
|
||||
}, {
|
||||
"name" : "ignoredAsHop",
|
||||
"type" : "boolean",
|
||||
"doc" : "Whether this relationship was ignored as a hop while performing the graph walk",
|
||||
"optional" : true
|
||||
} ]
|
||||
}
|
||||
},
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user