Skip to content

Commit

Permalink
Merge pull request #872 from InfuseAI/bug/sc-32214/bug-lineage-diff-e…
Browse files Browse the repository at this point in the history
…rror-in-jaffle-sl-template

[Bug] Add semantic models to lineage graph
  • Loading branch information
popcornylu authored Sep 4, 2023
2 parents fb1bbdc + 9cfd6bd commit 83293a0
Show file tree
Hide file tree
Showing 12 changed files with 1,402 additions and 373 deletions.
1,251 changes: 962 additions & 289 deletions static_report/schema/dbt-manifest-schema.json

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion static_report/src/components/Icons/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { FaChartBar } from 'react-icons/fa';
import { FiCloud, FiGrid, FiPlus } from 'react-icons/fi';
import { TbCircleHalf } from 'react-icons/tb';
import { TiSortNumerically } from 'react-icons/ti';
import { RxCube } from 'react-icons/rx';
import {
VscDiffAdded,
VscDiffModified,
Expand Down Expand Up @@ -152,12 +153,14 @@ export function getIconForResourceType(resourceType?: string): {
return { color: '#c0eafd', icon: FiGrid };
} else if (resourceType === 'source' || resourceType === 'seed') {
return { color: '#a6dda6', icon: FiGrid };
} else if (resourceType === 'semantic_model') {
return { color: '#fb8caf', icon: RxCube };
} else if (
resourceType === 'metric' ||
resourceType === 'exposure' ||
resourceType === 'analysis'
) {
return { color: 'rgb(255 230 238)', icon: FaChartBar };
return { color: '#ffe6ee', icon: FaChartBar };
} else {
return { color: 'inherit', icon: undefined };
}
Expand Down
2 changes: 1 addition & 1 deletion static_report/src/components/LineageGraph/GraphNode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export function GraphNode({ selected, data }: GraphNodeProps) {
>
<Flex
width="300px"
_hover={{ backgroundColor: 'gray.100' }}
_hover={{ backgroundColor: showContent ? 'gray.100' : color }}
borderColor={borderColor}
borderWidth={borderWidth}
borderStyle={borderStyle}
Expand Down
4 changes: 2 additions & 2 deletions static_report/src/components/LineageGraph/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export function selectUpstream(
return getUpstreamSet(
keys,
(id) => {
return Object.keys(lineageGraph[id].dependsOn);
return Object.keys(lineageGraph[id]?.dependsOn ?? {});
},
degree,
);
Expand All @@ -131,7 +131,7 @@ export function selectDownstream(
return getDownstreamSet(
keys,
(id) => {
return Object.keys(lineageGraph[id].children);
return Object.keys(lineageGraph[id]?.children ?? {});
},
degree,
);
Expand Down
6 changes: 6 additions & 0 deletions static_report/src/pages/CRPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,13 @@ import {
MODEL_DETAILS_ROUTE_PATH,
MODEL_COLUMN_DETAILS_ROUTE_PATH,
METRIC_DETAILS_ROUTE_PATH,
SEMANTIC_MODEL_DETAILS_ROUTE_PATH,
} from '../utils/routes';
import { CRAssertionListPage } from './CRAssertionListPage';
import { CRBMPage } from './CRBMPage';
import CRColumnDetailPage from './CRColumnDetailPage';
import { CROverviewPage } from './CROverviewPage';
import { CRSemanticModelPage } from './CRSemanticModelPage';
import CRTableDetailPage from './CRTableDetailPage';
import { CRTablesListPage } from './CRTableListPage';

Expand Down Expand Up @@ -93,6 +95,10 @@ export function CRPage({ data, cloud, sideNavTop = '0px' }: Props) {
<CRBMPage />
</Route>

<Route path={SEMANTIC_MODEL_DETAILS_ROUTE_PATH}>
<CRSemanticModelPage />
</Route>

<Route path={SSR_ROUTE_PATH}>
<Loading />
</Route>
Expand Down
52 changes: 52 additions & 0 deletions static_report/src/pages/CRSemanticModelPage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import { useRoute } from 'wouter';
import { getIconForResourceType } from '../components/Icons';
import {
EVENTS,
NoData,
SR_TYPE_LABEL,
TableColumnHeader,
useReportStore,
useTrackOnMount,
} from '../lib';
import { SEMANTIC_MODEL_DETAILS_ROUTE_PATH } from '../utils/routes';

export function CRSemanticModelPage() {
const [match, params] = useRoute(SEMANTIC_MODEL_DETAILS_ROUTE_PATH);

useTrackOnMount({
eventName: EVENTS.PAGE_VIEW,
eventProperties: {
type: SR_TYPE_LABEL,
page: 'resource-page',
},
});

if (!match) {
return <>Something wrong.</>;
}

const { tableColumnsOnly = [] } = useReportStore.getState();
const entry = tableColumnsOnly.find(([key]) => key === params?.uniqueId);
if (!entry) {
return <NoData text={`No data found for '${params?.uniqueId}'`} />;
}

const [, { base, target }] = entry;
const fallback = target ?? base;

const name = fallback?.name;
const description = fallback?.description;
const resourceType = fallback?.resource_type;
const { icon } = getIconForResourceType(resourceType);

return (
<>
<TableColumnHeader
subtitle="Semantic Model"
title={name}
icon={icon}
infoTip={description}
/>
</>
);
}
6 changes: 6 additions & 0 deletions static_report/src/pages/SRPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,13 @@ import {
TABLE_DETAILS_ROUTE_PATH,
TABLE_LIST_ROUTE_PATH,
METRIC_DETAILS_ROUTE_PATH,
SEMANTIC_MODEL_DETAILS_ROUTE_PATH,
} from '../utils/routes';
import { SRAssertionListPage } from './SRAssertionListPage';
import { SRBMPage } from './SRBMPage';
import SRColumnDetailPage from './SRColumnDetailPage';
import { SROverviewPage } from './SROverviewPage';
import { SRSemanticModelPage } from './SRSemanticModelPage';
import SRTableDetailPage from './SRTableDetailPage';
import { SRTablesListPage } from './SRTablesListPage';

Expand Down Expand Up @@ -96,6 +98,10 @@ export function SRPage({ data, cloud, sideNavTop = '0px' }: Props) {
<SRBMPage />
</Route>

<Route path={SEMANTIC_MODEL_DETAILS_ROUTE_PATH}>
<SRSemanticModelPage />
</Route>

<Route path={SSR_ROUTE_PATH}>
<Loading />
</Route>
Expand Down
51 changes: 51 additions & 0 deletions static_report/src/pages/SRSemanticModelPage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import { useRoute } from 'wouter';
import { getIconForResourceType } from '../components/Icons';
import {
EVENTS,
NoData,
SR_TYPE_LABEL,
TableColumnHeader,
useReportStore,
useTrackOnMount,
} from '../lib';
import { SEMANTIC_MODEL_DETAILS_ROUTE_PATH } from '../utils/routes';

export function SRSemanticModelPage() {
const [match, params] = useRoute(SEMANTIC_MODEL_DETAILS_ROUTE_PATH);

useTrackOnMount({
eventName: EVENTS.PAGE_VIEW,
eventProperties: {
type: SR_TYPE_LABEL,
page: 'resource-page',
},
});

if (!match) {
return <>Something wrong.</>;
}

const { tableColumnsOnly = [] } = useReportStore.getState();
const entry = tableColumnsOnly.find(([key]) => key === params?.uniqueId);
if (!entry) {
return <NoData text={`No data found for '${params?.uniqueId}'`} />;
}

const [, { base: data }] = entry;

const name = data?.name;
const description = data?.description;
const resourceType = data?.resource_type;
const { icon } = getIconForResourceType(resourceType);

return (
<>
<TableColumnHeader
subtitle="Semantic Model"
title={name}
icon={icon}
infoTip={description}
/>
</>
);
}
Loading

0 comments on commit 83293a0

Please sign in to comment.