Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Show disclaimer if report from manifest #892

Merged
merged 11 commits into from
Sep 28, 2023
3 changes: 3 additions & 0 deletions piperider_cli/profiler/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,9 @@
},
"git_sha": {
"type": "string"
},
"skip_datasource": {
"type": "boolean"
}
}
},
Expand Down
4 changes: 3 additions & 1 deletion piperider_cli/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -844,7 +844,9 @@ def _slim_dbt_manifest(manifest):
run_result['id'] = run_id
run_result['created_at'] = datetime_to_str(created_at)
git_branch, git_sha = get_git_branch()
run_result['datasource'] = dict(name=ds.name, type=ds.type_name, git_branch=git_branch, git_sha=git_sha)
run_result['datasource'] = dict(name=ds.name, type=ds.type_name,
git_branch=git_branch, git_sha=git_sha,
skip_datasource=skip_datasource_connection)

decorate_with_metadata(run_result)

Expand Down
14 changes: 14 additions & 0 deletions static_report/src/components/Common/SkipDataSource.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { Alert, AlertIcon, AlertDescription } from '@chakra-ui/react';

export function SkipDataSource() {
return (
<Alert status="error" mb={3} rounded={10}>
<AlertIcon />
<AlertDescription>
Schemas and reports generated from manifest files are limited to
information in those manifests. For a more detailed report, follow these
instructions
</AlertDescription>
</Alert>
);
}
6 changes: 6 additions & 0 deletions static_report/src/components/Overview/Overview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import { LineageGraphData } from '../../utils/dbt';
import { topologySort } from '../../utils/graph';
import { CompDbtNodeEntryItem, useReportStore } from '../../utils/store';
import { SearchTextInput } from '../Common/SearchTextInput';
import { SkipDataSource } from '../Common/SkipDataSource';
import { ModelList } from './ModelList';
import { MetricList } from './MetricList';
import { NodeList } from './NodeList';
Expand Down Expand Up @@ -213,6 +214,7 @@ export function Overview({ singleOnly }: Props) {
tableColumnsOnly = [],
lineageGraph,
rawData,
reportDataSource,
} = useReportStore.getState();
const isBrokenByMetrics = rawData.broken_by_metrics || false;
const [sortMethod, setSortMethod] = useState('topology');
Expand All @@ -231,6 +233,9 @@ export function Overview({ singleOnly }: Props) {
}
};

const skipDataSource =
reportDataSource?.base?.skip_datasource ||
reportDataSource?.target?.skip_datasource;
const tabItems = getTabItems(tableColumnsOnly);
const resourceType = tabItems[resourceIndex].resourceType;
const isNoProfiled = singleOnly
Expand Down Expand Up @@ -364,6 +369,7 @@ export function Overview({ singleOnly }: Props) {
return (
<>
<Flex direction="column" w={'100%'} minHeight="650px">
{skipDataSource && <SkipDataSource />}
<Flex w={'100%'} paddingBottom="10px" marginBottom="20px">
<Heading fontSize={24}>
{singleOnly ? 'Overview' : 'Impact Summary'}
Expand Down
72 changes: 70 additions & 2 deletions static_report/src/components/Reports/ReportContextBar.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import { Box, Flex, FlexProps, Link, Text } from '@chakra-ui/react';
import { Box, Flex, FlexProps, Link, Text, Tooltip } from '@chakra-ui/react';
import { ReactNode } from 'react';
import { BiPlug } from 'react-icons/bi';
import { BsGearWideConnected } from 'react-icons/bs';
import { FiInfo } from 'react-icons/fi';
import { GoGitBranch } from 'react-icons/go';
import { TbBuildingWarehouse } from 'react-icons/tb';
import { VscGitPullRequest } from 'react-icons/vsc';

import {
Comparable,
ComparisonReportSchema,
Expand Down Expand Up @@ -31,13 +34,20 @@ export function ReportContextBar({
let gitBranch: string | undefined = undefined;
let githubPr: string | undefined = undefined;
let githubPrUrl: string | undefined = undefined;
let baseFrom: string | undefined = undefined;
let targetFrom: string | undefined = undefined;
let skipDataSource: boolean | undefined = false;

if (data) {
if (singleOnly) {
const report = data as SingleReportSchema;
datasource = report.datasource?.name;
version = report.version;
gitBranch = report.datasource?.git_branch;
skipDataSource = report.datasource?.skip_datasource;
baseFrom = report.datasource?.skip_datasource
? 'Manifest file'
: `${report.datasource.type} connection`;
} else {
const report = data as ComparisonReportSchema;
const fallback = report.input ?? report.base;
Expand All @@ -60,9 +70,66 @@ export function ReportContextBar({

githubPrUrl = report.metadata?.github_pr_url;
}

skipDataSource =
report.base?.datasource.skip_datasource ||
report.input?.datasource.skip_datasource;

baseFrom = report.base?.datasource.skip_datasource
? 'Manifest file'
: `${report.base?.datasource.type} connection`;
targetFrom = report.input?.datasource.skip_datasource
? 'Manifest file'
: `${report.input?.datasource.type} connection`;
}
}

const showIcon = (skipDataSource: boolean | undefined) => {
return skipDataSource ? (
<Tooltip
shouldWrapChildren
label="Connect PipeRider to your datasource for full schema info"
placement="top-start"
>
<FiInfo />
</Tooltip>
) : (
<TbBuildingWarehouse />
);
};

const showReportSource = (
singleOnly: boolean | undefined,
baseFrom: string | undefined,
targetFrom: string | undefined,
skipDataSource: boolean | undefined,
) => {
let source: string | undefined = undefined;
if (singleOnly) {
source = baseFrom;
} else {
if (baseFrom !== targetFrom) {
source = `${baseFrom} ↔ ${targetFrom}`;
} else {
source = baseFrom;
}
}
return (
<Flex alignItems={'center'} gap={2} flex="1" overflow="hidden">
{showIcon(skipDataSource)}
<Text
flex="1"
color={'gray.500'}
whiteSpace="nowrap"
textOverflow="ellipsis"
overflow="hidden"
>
source: {source}
</Text>
</Flex>
);
};

return (
<Flex
gap={5}
Expand Down Expand Up @@ -125,7 +192,7 @@ export function ReportContextBar({
</Flex>
)}
{gitBranch && (
<Flex alignItems={'center'} gap={2} flex="1" overflow="hidden">
<Flex alignItems={'center'} gap={2} overflow="hidden">
<GoGitBranch />
<Text
flex="1"
Expand All @@ -138,6 +205,7 @@ export function ReportContextBar({
</Text>
</Flex>
)}
{showReportSource(singleOnly, baseFrom, targetFrom, skipDataSource)}
</Flex>
{actionArea && <Box flex="0 0 auto">{actionArea}</Box>}
</Flex>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,13 @@ import { CompColEntryItem } from '../../../lib';
interface Props extends Comparable {
columns?: CompColEntryItem[];
visibleDetail?: boolean; //for reuse in other pages
skipDataSource?: boolean;
}
export function TableColumnSchemaList({
columns,
singleOnly,
visibleDetail = false,
skipDataSource,
}: Props) {
const isNotSingle = !singleOnly;

Expand Down Expand Up @@ -101,7 +103,9 @@ export function TableColumnSchemaList({
borderRight={isNotSingle ? '1px solid lightgray' : ''}
>
<Text as={'span'} fontSize={'xs'}>
{baseColumn?.schema_type ?? NO_VALUE}
{skipDataSource
? '-'
: baseColumn?.schema_type ?? NO_VALUE}
</Text>
</Td>
{isNotSingle ? (
Expand All @@ -128,7 +132,9 @@ export function TableColumnSchemaList({
}
>
<Text as={'span'} fontSize={'xs'}>
{targetColumn?.schema_type ?? NO_VALUE}
{skipDataSource
? '-'
: targetColumn?.schema_type ?? NO_VALUE}
</Text>
</Td>
</>
Expand Down
24 changes: 17 additions & 7 deletions static_report/src/pages/CRTableDetailPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { useTableRoute } from '../utils/routes';
import { NO_VALUE } from '../components/Columns/constants';
import { TableGeneralStats } from '../components/Tables/TableMetrics/TableGeneralStats';
import { DupedTableRowsWidget } from '../components/Widgets/DupedTableRowsWidget';
import { SkipDataSource } from '../components/Common/SkipDataSource';

export default function CRTableDetailPage() {
let { tableName, uniqueId } = useTableRoute();
Expand All @@ -38,14 +39,17 @@ export default function CRTableDetailPage() {
},
});

const { tableColumnsOnly = [] } = useReportStore.getState();
const { tableColumnsOnly = [], reportDataSource } = useReportStore.getState();
const nodeKey = uniqueId ? uniqueId : `table.${tableName}`;

const currentTableEntry = tableColumnsOnly.find(([key]) => key === nodeKey);
if (!currentTableEntry) {
return <NoData text={`No data found for table '${nodeKey}'`} />;
}

const skipDataSource =
reportDataSource?.base?.skip_datasource ||
reportDataSource?.target?.skip_datasource;
const [, { base, target }] = currentTableEntry;
const fallback = target || base;

Expand Down Expand Up @@ -178,6 +182,7 @@ export default function CRTableDetailPage() {

return (
<Box>
{skipDataSource && <SkipDataSource />}
<HStack alignItems="flex-start">
<TableColumnHeader
title={name}
Expand All @@ -200,13 +205,16 @@ export default function CRTableDetailPage() {
Show Dependencies
</Button> */}
</HStack>

<ComparableGridHeader />
<ComparisonContent>
<VStack spacing={10}>
<SeparateView title="Table Statistics" Comp={TableGeneralStats} />
<MergedView title="Schema">
<TableColumnSchemaCompList tableEntry={currentTableEntry} />
<TableColumnSchemaCompList
tableEntry={currentTableEntry}
skipBase={reportDataSource?.base?.skip_datasource}
skipTarget={reportDataSource?.target?.skip_datasource}
/>
</MergedView>
<SeparateView title="Duplicate Rows" Comp={DupedTableRowsWidget} />
</VStack>
Expand Down Expand Up @@ -243,7 +251,7 @@ function ComparableGridHeader() {
);
}

function TableColumnSchemaCompList({ tableEntry }) {
function TableColumnSchemaCompList({ tableEntry, skipBase, skipTarget }) {
const [
,
{ base: baseTableColEntry, target: targetTableColEntry },
Expand Down Expand Up @@ -296,7 +304,7 @@ function TableColumnSchemaCompList({ tableEntry }) {
borderRightColor="gray.200"
>
<Text as={'span'} fontSize={'xs'}>
{baseColumn?.schema_type ?? NO_VALUE}
{skipBase ? '-' : baseColumn?.schema_type ?? NO_VALUE}
</Text>
</Td>

Expand All @@ -316,7 +324,9 @@ function TableColumnSchemaCompList({ tableEntry }) {
</Td>
<Td color={metadata?.mismatched ? 'red.500' : 'inherit'}>
<Text as={'span'} fontSize={'xs'}>
{targetColumn?.schema_type ?? NO_VALUE}
{skipTarget
? '-'
: targetColumn?.schema_type ?? NO_VALUE}
</Text>
</Td>
</Tr>
Expand Down Expand Up @@ -365,7 +375,7 @@ function TableColumnSchemaCompList({ tableEntry }) {
</Td>
<Td>
<Text as={'span'} fontSize={'xs'}>
{column?.schema_type ?? NO_VALUE}
{skipBase ? '-' : column?.schema_type ?? NO_VALUE}
</Text>
</Td>
</Tr>
Expand Down
11 changes: 9 additions & 2 deletions static_report/src/pages/SRTableDetailPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
import { TableColumnHeader } from '../components/Tables/TableColumnHeader';
import { useReportStore } from '../utils/store';
import { useTableRoute } from '../utils/routes';
import { SkipDataSource } from '../components/Common/SkipDataSource';

export default function SRTableDetailPage() {
let { tableName, uniqueId } = useTableRoute();
Expand All @@ -23,7 +24,7 @@ export default function SRTableDetailPage() {
},
});

const { tableColumnsOnly = [] } = useReportStore.getState();
const { tableColumnsOnly = [], reportDataSource } = useReportStore.getState();

const tableKey = tableName || uniqueId;
if (tableKey === undefined) {
Expand All @@ -36,6 +37,7 @@ export default function SRTableDetailPage() {
return <NoData text={`No data found for '${tableKey}'`} />;
}

const skipDataSource = reportDataSource?.base?.skip_datasource || undefined;
const [, { base: data }, { columns }] = currentTableEntry;
const name = data?.name;
const description = data?.description || undefined;
Expand All @@ -59,6 +61,7 @@ export default function SRTableDetailPage() {

return (
<>
{skipDataSource && <SkipDataSource />}
<TableColumnHeader
title={name}
subtitle={'Table'}
Expand All @@ -84,7 +87,11 @@ export default function SRTableDetailPage() {
</VStack>

<Divider orientation="vertical" />
<TableColumnSchemaList columns={columns} singleOnly />
<TableColumnSchemaList
columns={columns}
singleOnly
skipDataSource={skipDataSource}
/>
</Grid>
</>
);
Expand Down
1 change: 1 addition & 0 deletions static_report/src/sdlc/single-report-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,7 @@ export interface DataSource {
type: string;
git_branch?: string;
git_sha?: string;
skip_datasource?: boolean;
}
export interface Cloud {
[k: string]: unknown;
Expand Down
Loading
Loading