feat(lineage): give via and paths in entity lineage response (#10192)

This commit is contained in:
RyanHolstien 2024-04-02 19:36:52 -05:00 committed by GitHub
parent 57de905c66
commit 888a1de9fc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
11 changed files with 52 additions and 12 deletions

View File

@ -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;
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -1331,6 +1331,10 @@ type LineageRelationship {
"""
isManual: Boolean
"""
The paths traversed for this relationship
"""
paths: [EntityPath]
}
"""

View File

@ -747,6 +747,11 @@ type SearchAcrossLineageResult {
"""
explored: Boolean!
"""
Whether this relationship was ignored as a hop
"""
ignoredAsHop: Boolean!
}
"""

View File

@ -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(

View File

@ -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;
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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
} ]
}
},

View File

@ -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
} ]
}
},