Skip to content

Commit

Permalink
subtypes for charts
Browse files Browse the repository at this point in the history
  • Loading branch information
gabe-lyons committed Nov 6, 2023
1 parent 3a9452c commit 028ff78
Show file tree
Hide file tree
Showing 9 changed files with 70 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -1431,6 +1431,10 @@ private void configureChartResolvers(final RuntimeWiring.Builder builder) {
.dataFetcher("statsSummary", new ChartStatsSummaryResolver(this.timeseriesAspectService))
.dataFetcher("privileges", new EntityPrivilegesResolver(entityClient))
.dataFetcher("exists", new EntityExistsResolver(entityService))
.dataFetcher("subTypes", new SubTypesResolver(
this.entityClient,
"chart",
"subTypes"))
);
builder.type("ChartInfo", typeWiring -> typeWiring
.dataFetcher("inputs", new LoadableTypeBatchResolver<>(datasetType,
Expand Down
5 changes: 5 additions & 0 deletions datahub-graphql-core/src/main/resources/entity.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -5239,6 +5239,11 @@ type Chart implements EntityWithRelationships & Entity & BrowsableEntity {
Whether or not this entity exists on DataHub
"""
exists: Boolean

"""
Sub Types that this entity implements
"""
subTypes: SubTypes
}

"""
Expand Down
40 changes: 40 additions & 0 deletions datahub-web-react/lineage_fix.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
diff --git a/datahub-web-react/src/app/lineage/utils/layoutTree.ts b/datahub-web-react/src/app/lineage/utils/layoutTree.ts
index cc70400704..4d34103b9d 100644
--- a/datahub-web-react/src/app/lineage/utils/layoutTree.ts
+++ b/datahub-web-react/src/app/lineage/utils/layoutTree.ts
@@ -32,6 +32,20 @@ function getParentRelationship(direction: Direction, parent: VizNode | null, nod
return directionRelationships?.find((r) => r?.entity?.urn === node?.urn);
}

+function firstAppearanceIndices(arr) {
+ const seen = new Set(); // To track which strings have been seen
+ const result = [] as number[];
+
+ for (let i = 0; i < arr.length; i++) {
+ if (!seen.has(arr[i])) {
+ seen.add(arr[i]); // Add the string to the set
+ result.push(i); // Save the index
+ }
+ }
+
+ return result;
+}
+
function layoutNodesForOneDirection(
data: NodeData,
direction: Direction,
@@ -54,12 +68,10 @@ function layoutNodesForOneDirection(
while (nodesInCurrentLayer.length > 0) {
// if we've already added a node to the viz higher up dont add it again
const urnsToAddInCurrentLayer = Array.from(new Set(nodesInCurrentLayer.map(({ node }) => node.urn || '')));
- const nodesToAddInCurrentLayer = urnsToAddInCurrentLayer
- .filter((urn, pos) => urnsToAddInCurrentLayer.indexOf(urn) === pos)
- .filter((urn) => !nodesByUrn[urn || '']);
+ const positionsToAddInCurrentLayer = firstAppearanceIndices(urnsToAddInCurrentLayer);

const filteredNodesInCurrentLayer = nodesInCurrentLayer
- .filter(({ node }) => nodesToAddInCurrentLayer.indexOf(node.urn || '') > -1)
+ .filter((_, idx) => positionsToAddInCurrentLayer.indexOf(idx) > -1)
.filter(({ node }) => node.status?.removed !== true);

const layerSize = filteredNodesInCurrentLayer.length;
4 changes: 4 additions & 0 deletions datahub-web-react/src/app/entity/chart/ChartEntity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,12 @@ export class ChartEntity implements Entity<Chart> {
getOverridePropertiesFromEntity = (chart?: Chart | null): GenericEntityProperties => {
// TODO: Get rid of this once we have correctly formed platform coming back.
const name = chart?.properties?.name;
const subTypes = chart?.subTypes;
const externalUrl = chart?.properties?.externalUrl;
return {
name,
externalUrl,
entityTypeOverride: subTypes ? capitalizeFirstLetterOnly(subTypes.typeNames?.[0]) : '',
};
};

Expand Down Expand Up @@ -187,6 +189,7 @@ export class ChartEntity implements Entity<Chart> {
return (
<ChartPreview
urn={data.urn}
subType={data.subTypes?.typeNames?.[0]}
platform={data?.platform?.properties?.displayName || capitalizeFirstLetterOnly(data?.platform?.name)}
platformInstanceId={data.dataPlatformInstance?.instanceId}
name={data.properties?.name}
Expand Down Expand Up @@ -222,6 +225,7 @@ export class ChartEntity implements Entity<Chart> {
type: EntityType.Chart,
icon: entity?.platform?.properties?.logoUrl || undefined,
platform: entity?.platform,
subtype: entity?.subTypes?.typeNames?.[0] || undefined,
};
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
EntityPath,
} from '../../../../types.generated';
import DefaultPreviewCard from '../../../preview/DefaultPreviewCard';
import { capitalizeFirstLetterOnly } from '../../../shared/textUtil';
import { useEntityRegistry } from '../../../useEntityRegistry';
import { IconStyleType } from '../../Entity';
import { ChartStatsSummary as ChartStatsSummaryView } from '../shared/ChartStatsSummary';
Expand Down Expand Up @@ -43,6 +44,7 @@ export const ChartPreview = ({
snippet,
degree,
paths,
subType,
}: {
urn: string;
platform?: string;
Expand All @@ -67,6 +69,7 @@ export const ChartPreview = ({
snippet?: React.ReactNode | null;
degree?: number;
paths?: EntityPath[];
subType?: string | null;
}): JSX.Element => {
const entityRegistry = useEntityRegistry();

Expand All @@ -76,7 +79,7 @@ export const ChartPreview = ({
name={name || ''}
urn={urn}
description={description || ''}
type="Chart"
type={capitalizeFirstLetterOnly(subType) || 'Chart'}
typeIcon={entityRegistry.getIcon(EntityType.Chart, 14, IconStyleType.ACCENT)}
logoUrl={logoUrl || ''}
platform={platform}
Expand Down
3 changes: 3 additions & 0 deletions datahub-web-react/src/graphql/chart.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ query getChart($urn: String!) {
canEditLineage
canEditEmbed
}
subTypes {
typeNames
}
}
}

Expand Down
3 changes: 3 additions & 0 deletions datahub-web-react/src/graphql/lineage.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,9 @@ fragment lineageNodeProperties on EntityWithRelationships {
status {
removed
}
subTypes {
typeNames
}
}
... on Dataset {
name
Expand Down
6 changes: 6 additions & 0 deletions datahub-web-react/src/graphql/search.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ fragment autoCompleteFields on Entity {
parentContainers {
...parentContainersFields
}
subTypes {
typeNames
}
}
... on DataFlow {
orchestrator
Expand Down Expand Up @@ -550,6 +553,9 @@ fragment searchResultFields on Entity {
}
}
}
subTypes {
typeNames
}
}
... on DataFlow {
flowId
Expand Down
1 change: 1 addition & 0 deletions metadata-models/src/main/resources/entity-registry.yml
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ entities:
- globalTags
- glossaryTerms
- browsePathsV2
- subTypes
- name: dashboard
keyAspect: dashboardKey
aspects:
Expand Down

0 comments on commit 028ff78

Please sign in to comment.