Skip to content

Commit

Permalink
feat(dataPlatformInstance) - Resolve and display dataPlatformInstance…
Browse files Browse the repository at this point in the history
… on entities (datahub-project#4867)

Co-authored-by: Chris Collins <[email protected]>
  • Loading branch information
2 people authored and justinas-marozas committed May 17, 2022
1 parent 809c949 commit dabc3f8
Show file tree
Hide file tree
Showing 58 changed files with 555 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import com.linkedin.datahub.graphql.generated.DataFlow;
import com.linkedin.datahub.graphql.generated.DataJob;
import com.linkedin.datahub.graphql.generated.DataJobInputOutput;
import com.linkedin.datahub.graphql.generated.DataPlatformInstance;
import com.linkedin.datahub.graphql.generated.Dataset;
import com.linkedin.datahub.graphql.generated.Domain;
import com.linkedin.datahub.graphql.generated.EntityRelationship;
Expand Down Expand Up @@ -132,6 +133,8 @@
import com.linkedin.datahub.graphql.resolvers.user.RemoveUserResolver;
import com.linkedin.datahub.graphql.resolvers.user.UpdateUserStatusResolver;
import com.linkedin.datahub.graphql.types.BrowsableEntityType;
import com.linkedin.datahub.graphql.types.dataplatforminstance.DataPlatformInstanceType;
import com.linkedin.datahub.graphql.types.dataprocessinst.mappers.DataProcessInstanceRunEventMapper;
import com.linkedin.datahub.graphql.types.EntityType;
import com.linkedin.datahub.graphql.types.LoadableType;
import com.linkedin.datahub.graphql.types.SearchableEntityType;
Expand All @@ -147,7 +150,6 @@
import com.linkedin.datahub.graphql.types.dataflow.DataFlowType;
import com.linkedin.datahub.graphql.types.datajob.DataJobType;
import com.linkedin.datahub.graphql.types.dataplatform.DataPlatformType;
import com.linkedin.datahub.graphql.types.dataprocessinst.mappers.DataProcessInstanceRunEventMapper;
import com.linkedin.datahub.graphql.types.dataset.DatasetType;
import com.linkedin.datahub.graphql.types.dataset.mappers.DatasetProfileMapper;
import com.linkedin.datahub.graphql.types.domain.DomainType;
Expand Down Expand Up @@ -249,6 +251,7 @@ public class GmsGraphQLEngine {
private final NotebookType notebookType;
private final AssertionType assertionType;
private final VersionedDatasetType versionedDatasetType;
private final DataPlatformInstanceType dataPlatformInstanceType;


/**
Expand Down Expand Up @@ -340,6 +343,7 @@ public GmsGraphQLEngine(
this.notebookType = new NotebookType(entityClient);
this.assertionType = new AssertionType(entityClient);
this.versionedDatasetType = new VersionedDatasetType(entityClient);
this.dataPlatformInstanceType = new DataPlatformInstanceType(entityClient);

// Init Lists
this.entityTypes = ImmutableList.of(
Expand All @@ -362,7 +366,8 @@ public GmsGraphQLEngine(
notebookType,
domainType,
assertionType,
versionedDatasetType
versionedDatasetType,
dataPlatformInstanceType
);
this.loadableTypes = new ArrayList<>(entityTypes);
this.ownerTypes = ImmutableList.of(corpUserType, corpGroupType);
Expand Down Expand Up @@ -409,6 +414,7 @@ public void configureRuntimeWiring(final RuntimeWiring.Builder builder) {
configureIngestionSourceResolvers(builder);
configureAnalyticsResolvers(builder);
configureContainerResolvers(builder);
configureDataPlatformInstanceResolvers(builder);
configureGlossaryTermResolvers(builder);
configureDomainResolvers(builder);
configureAssertionResolvers(builder);
Expand Down Expand Up @@ -476,6 +482,22 @@ private void configureContainerResolvers(final RuntimeWiring.Builder builder) {
return container.getContainer() != null ? container.getContainer().getUrn() : null;
})
)
.dataFetcher("dataPlatformInstance",
new LoadableTypeResolver<>(dataPlatformInstanceType,
(env) -> {
final Container container = env.getSource();
return container.getDataPlatformInstance() != null ? container.getDataPlatformInstance().getUrn() : null;
})
)
);
}

private void configureDataPlatformInstanceResolvers(final RuntimeWiring.Builder builder) {
builder
.type("DataPlatformInstance", typeWiring -> typeWiring
.dataFetcher("platform",
new LoadableTypeResolver<>(dataPlatformType,
(env) -> ((DataPlatformInstance) env.getSource()).getPlatform().getUrn()))
);
}

Expand Down Expand Up @@ -672,6 +694,13 @@ private void configureDatasetResolvers(final RuntimeWiring.Builder builder) {
return dataset.getContainer() != null ? dataset.getContainer().getUrn() : null;
})
)
.dataFetcher("dataPlatformInstance",
new LoadableTypeResolver<>(dataPlatformInstanceType,
(env) -> {
final Dataset dataset = env.getSource();
return dataset.getDataPlatformInstance() != null ? dataset.getDataPlatformInstance().getUrn() : null;
})
)
.dataFetcher("datasetProfiles", new TimeSeriesAspectResolver(
this.entityClient,
"dataset",
Expand Down Expand Up @@ -783,6 +812,13 @@ private void configureNotebookResolvers(final RuntimeWiring.Builder builder) {
.dataFetcher("relationships", new EntityRelationshipsResultResolver(graphClient))
.dataFetcher("platform", new LoadableTypeResolver<>(dataPlatformType,
(env) -> ((Notebook) env.getSource()).getPlatform().getUrn()))
.dataFetcher("dataPlatformInstance",
new LoadableTypeResolver<>(dataPlatformInstanceType,
(env) -> {
final Notebook notebook = env.getSource();
return notebook.getDataPlatformInstance() != null ? notebook.getDataPlatformInstance().getUrn() : null;
})
)
.dataFetcher("domain", new LoadableTypeResolver<>(domainType,
(env) -> ((Notebook) env.getSource()).getDomain().getUrn())
));
Expand All @@ -805,6 +841,13 @@ private void configureDashboardResolvers(final RuntimeWiring.Builder builder) {
}
)
)
.dataFetcher("dataPlatformInstance",
new LoadableTypeResolver<>(dataPlatformInstanceType,
(env) -> {
final Dashboard dashboard = env.getSource();
return dashboard.getDataPlatformInstance() != null ? dashboard.getDataPlatformInstance().getUrn() : null;
})
)
.dataFetcher("container", new LoadableTypeResolver<>(containerType,
(env) -> {
final Dashboard dashboard = env.getSource();
Expand Down Expand Up @@ -836,6 +879,13 @@ private void configureChartResolvers(final RuntimeWiring.Builder builder) {
return chart.getDomain() != null ? chart.getDomain().getUrn() : null;
})
)
.dataFetcher("dataPlatformInstance",
new LoadableTypeResolver<>(dataPlatformInstanceType,
(env) -> {
final Chart chart = env.getSource();
return chart.getDataPlatformInstance() != null ? chart.getDataPlatformInstance().getUrn() : null;
})
)
.dataFetcher("container", new LoadableTypeResolver<>(
containerType,
(env) -> {
Expand Down Expand Up @@ -912,6 +962,13 @@ private void configureDataJobResolvers(final RuntimeWiring.Builder builder) {
return dataJob.getDomain() != null ? dataJob.getDomain().getUrn() : null;
})
)
.dataFetcher("dataPlatformInstance",
new LoadableTypeResolver<>(dataPlatformInstanceType,
(env) -> {
final DataJob dataJob = env.getSource();
return dataJob.getDataPlatformInstance() != null ? dataJob.getDataPlatformInstance().getUrn() : null;
})
)
.dataFetcher("runs", new DataJobRunsResolver(entityClient))
)
.type("DataJobInputOutput", typeWiring -> typeWiring
Expand Down Expand Up @@ -947,6 +1004,13 @@ private void configureDataFlowResolvers(final RuntimeWiring.Builder builder) {
return dataFlow.getDomain() != null ? dataFlow.getDomain().getUrn() : null;
})
)
.dataFetcher("dataPlatformInstance",
new LoadableTypeResolver<>(dataPlatformInstanceType,
(env) -> {
final DataFlow dataFlow = env.getSource();
return dataFlow.getDataPlatformInstance() != null ? dataFlow.getDataPlatformInstance().getUrn() : null;
})
)
);
}

Expand All @@ -961,6 +1025,13 @@ private void configureMLFeatureTableResolvers(final RuntimeWiring.Builder builde
.dataFetcher("platform",
new LoadableTypeResolver<>(dataPlatformType,
(env) -> ((MLFeatureTable) env.getSource()).getPlatform().getUrn()))
.dataFetcher("dataPlatformInstance",
new LoadableTypeResolver<>(dataPlatformInstanceType,
(env) -> {
final MLFeatureTable entity = env.getSource();
return entity.getDataPlatformInstance() != null ? entity.getDataPlatformInstance().getUrn() : null;
})
)
.dataFetcher("domain", new LoadableTypeResolver<>(
domainType,
(env) -> {
Expand Down Expand Up @@ -1003,6 +1074,13 @@ private void configureMLFeatureTableResolvers(final RuntimeWiring.Builder builde
.dataFetcher("lineage", new EntityLineageResultResolver(graphClient))
.dataFetcher("platform", new LoadableTypeResolver<>(dataPlatformType,
(env) -> ((MLModel) env.getSource()).getPlatform().getUrn()))
.dataFetcher("dataPlatformInstance",
new LoadableTypeResolver<>(dataPlatformInstanceType,
(env) -> {
final MLModel mlModel = env.getSource();
return mlModel.getDataPlatformInstance() != null ? mlModel.getDataPlatformInstance().getUrn() : null;
})
)
.dataFetcher("domain",
new LoadableTypeResolver<>(
domainType,
Expand Down Expand Up @@ -1030,6 +1108,13 @@ private void configureMLFeatureTableResolvers(final RuntimeWiring.Builder builde
.dataFetcher("platform", new LoadableTypeResolver<>(dataPlatformType,
(env) -> ((MLModelGroup) env.getSource()).getPlatform().getUrn())
)
.dataFetcher("dataPlatformInstance",
new LoadableTypeResolver<>(dataPlatformInstanceType,
(env) -> {
final MLModelGroup entity = env.getSource();
return entity.getDataPlatformInstance() != null ? entity.getDataPlatformInstance().getUrn() : null;
})
)
.dataFetcher("domain",
new LoadableTypeResolver<>(
domainType,
Expand All @@ -1041,6 +1126,13 @@ private void configureMLFeatureTableResolvers(final RuntimeWiring.Builder builde
.type("MLFeature", typeWiring -> typeWiring
.dataFetcher("relationships", new EntityRelationshipsResultResolver(graphClient))
.dataFetcher("lineage", new EntityLineageResultResolver(graphClient))
.dataFetcher("dataPlatformInstance",
new LoadableTypeResolver<>(dataPlatformInstanceType,
(env) -> {
final MLFeature entity = env.getSource();
return entity.getDataPlatformInstance() != null ? entity.getDataPlatformInstance().getUrn() : null;
})
)
.dataFetcher("domain",
new LoadableTypeResolver<>(
domainType,
Expand All @@ -1052,6 +1144,13 @@ private void configureMLFeatureTableResolvers(final RuntimeWiring.Builder builde
.type("MLPrimaryKey", typeWiring -> typeWiring
.dataFetcher("relationships", new EntityRelationshipsResultResolver(graphClient))
.dataFetcher("lineage", new EntityLineageResultResolver(graphClient))
.dataFetcher("dataPlatformInstance",
new LoadableTypeResolver<>(dataPlatformInstanceType,
(env) -> {
final MLPrimaryKey entity = env.getSource();
return entity.getDataPlatformInstance() != null ? entity.getDataPlatformInstance().getUrn() : null;
})
)
.dataFetcher("domain",
new LoadableTypeResolver<>(
domainType,
Expand Down Expand Up @@ -1080,6 +1179,13 @@ private void configureAssertionResolvers(final RuntimeWiring.Builder builder) {
new EntityRelationshipsResultResolver(graphClient))
.dataFetcher("platform", new LoadableTypeResolver<>(dataPlatformType,
(env) -> ((Assertion) env.getSource()).getPlatform().getUrn()))
.dataFetcher("dataPlatformInstance",
new LoadableTypeResolver<>(dataPlatformInstanceType,
(env) -> {
final Assertion assertion = env.getSource();
return assertion.getDataPlatformInstance() != null ? assertion.getDataPlatformInstance().getUrn() : null;
})
)
.dataFetcher("runEvents", new AssertionRunEventResolver(entityClient)));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public class EntityTypeMapper {
.put(EntityType.CONTAINER, "container")
.put(EntityType.DOMAIN, "domain")
.put(EntityType.NOTEBOOK, "notebook")
.put(EntityType.DATA_PLATFORM_INSTANCE, "dataPlatformInstance")
.build();

private static final Map<String, EntityType> ENTITY_NAME_TO_TYPE =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.linkedin.assertion.AssertionInfo;
import com.linkedin.common.DataPlatformInstance;
import com.linkedin.common.urn.Urn;
import com.linkedin.data.DataMap;
import com.linkedin.datahub.graphql.generated.Assertion;
import com.linkedin.datahub.graphql.generated.AssertionStdAggregation;
import com.linkedin.datahub.graphql.generated.AssertionStdOperator;
Expand All @@ -15,6 +16,7 @@
import com.linkedin.datahub.graphql.generated.DatasetAssertionScope;
import com.linkedin.datahub.graphql.generated.EntityType;
import com.linkedin.datahub.graphql.generated.SchemaFieldRef;
import com.linkedin.datahub.graphql.types.common.mappers.DataPlatformInstanceAspectMapper;
import com.linkedin.datahub.graphql.types.common.mappers.StringMapMapper;
import com.linkedin.entity.EntityResponse;
import com.linkedin.entity.EnvelopedAspect;
Expand All @@ -40,7 +42,9 @@ public static Assertion map(final EntityResponse entityResponse) {
}
final EnvelopedAspect envelopedPlatformInstance = aspects.get(Constants.DATA_PLATFORM_INSTANCE_ASPECT_NAME);
if (envelopedPlatformInstance != null) {
result.setPlatform(mapPlatform(new DataPlatformInstance(envelopedPlatformInstance.getValue().data())));
final DataMap data = envelopedPlatformInstance.getValue().data();
result.setPlatform(mapPlatform(new DataPlatformInstance(data)));
result.setDataPlatformInstance(DataPlatformInstanceAspectMapper.map(new DataPlatformInstance(data)));
} else {
final DataPlatform unknownPlatform = new DataPlatform();
unknownPlatform.setUrn(Constants.UNKNOWN_DATA_PLATFORM);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ public class ChartType implements SearchableEntityType<Chart, String>, Browsable
STATUS_ASPECT_NAME,
CONTAINER_ASPECT_NAME,
DOMAINS_ASPECT_NAME,
DEPRECATION_ASPECT_NAME
DEPRECATION_ASPECT_NAME,
DATA_PLATFORM_INSTANCE_ASPECT_NAME
);
private static final Set<String> FACET_FIELDS = ImmutableSet.of("access", "queryType", "tool", "type");

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.linkedin.datahub.graphql.types.chart.mappers;

import com.linkedin.chart.EditableChartProperties;
import com.linkedin.common.DataPlatformInstance;
import com.linkedin.common.Deprecation;
import com.linkedin.common.GlobalTags;
import com.linkedin.common.GlossaryTerms;
Expand All @@ -22,6 +23,7 @@
import com.linkedin.datahub.graphql.generated.Domain;
import com.linkedin.datahub.graphql.generated.EntityType;
import com.linkedin.datahub.graphql.types.common.mappers.AuditStampMapper;
import com.linkedin.datahub.graphql.types.common.mappers.DataPlatformInstanceAspectMapper;
import com.linkedin.datahub.graphql.types.common.mappers.DeprecationMapper;
import com.linkedin.datahub.graphql.types.common.mappers.InstitutionalMemoryMapper;
import com.linkedin.datahub.graphql.types.common.mappers.OwnershipMapper;
Expand Down Expand Up @@ -76,6 +78,8 @@ public Chart apply(@Nonnull final EntityResponse entityResponse) {
mappingHelper.mapToResult(DOMAINS_ASPECT_NAME, this::mapDomains);
mappingHelper.mapToResult(DEPRECATION_ASPECT_NAME, (chart, dataMap) ->
chart.setDeprecation(DeprecationMapper.map(new Deprecation(dataMap))));
mappingHelper.mapToResult(DATA_PLATFORM_INSTANCE_ASPECT_NAME, (dataset, dataMap) ->
dataset.setDataPlatformInstance(DataPlatformInstanceAspectMapper.map(new DataPlatformInstance(dataMap))));

return mappingHelper.getResult();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.linkedin.datahub.graphql.types.common.mappers;

import com.linkedin.datahub.graphql.generated.DataPlatformInstance;
import com.linkedin.datahub.graphql.generated.EntityType;
import com.linkedin.datahub.graphql.types.mappers.ModelMapper;

import javax.annotation.Nonnull;

public class DataPlatformInstanceAspectMapper implements ModelMapper<com.linkedin.common.DataPlatformInstance, DataPlatformInstance> {

public static final DataPlatformInstanceAspectMapper INSTANCE = new DataPlatformInstanceAspectMapper();

public static DataPlatformInstance map(@Nonnull final com.linkedin.common.DataPlatformInstance dataPlatformInstance) {
return INSTANCE.apply(dataPlatformInstance);
}

@Override
public DataPlatformInstance apply(@Nonnull final com.linkedin.common.DataPlatformInstance input) {
final DataPlatformInstance result = new DataPlatformInstance();
if (input.hasInstance()) {
result.setType(EntityType.DATA_PLATFORM_INSTANCE);
result.setUrn(input.getInstance().toString());
}
return result;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import com.linkedin.datahub.graphql.generated.DataFlow;
import com.linkedin.datahub.graphql.generated.DataJob;
import com.linkedin.datahub.graphql.generated.DataPlatform;
import com.linkedin.datahub.graphql.generated.DataPlatformInstance;
import com.linkedin.datahub.graphql.generated.Dataset;
import com.linkedin.datahub.graphql.generated.Domain;
import com.linkedin.datahub.graphql.generated.Entity;
Expand Down Expand Up @@ -116,6 +117,11 @@ public Entity apply(Urn input) {
((DataPlatform) partialEntity).setUrn(input.toString());
((DataPlatform) partialEntity).setType(EntityType.DATA_PLATFORM);
}
if (input.getEntityType().equals("dataPlatformInstance")) {
partialEntity = new DataPlatformInstance();
((DataPlatformInstance) partialEntity).setUrn(input.toString());
((DataPlatformInstance) partialEntity).setType(EntityType.DATA_PLATFORM_INSTANCE);
}
if (input.getEntityType().equals("container")) {
partialEntity = new Container();
((Container) partialEntity).setUrn(input.toString());
Expand Down
Loading

0 comments on commit dabc3f8

Please sign in to comment.