From 731e519fb30842d18e9e87a2ee7a96f9fcef9ba7 Mon Sep 17 00:00:00 2001 From: Sachin Chaurasiya Date: Thu, 9 Dec 2021 21:45:16 +0530 Subject: [PATCH] Fix #1626 Profiler should show primary key, non null column information in profiler tab (#1649) * Fix #1626 Profiler should show primary key, non null column information in profiler tab * Minor fix --- .../DatasetDetails.component.tsx | 5 +- .../TableProfiler/TableProfiler.component.tsx | 110 ++++++++++-------- .../resources/ui/src/utils/TableUtils.tsx | 5 +- 3 files changed, 68 insertions(+), 52 deletions(-) diff --git a/openmetadata-ui/src/main/resources/ui/src/components/DatasetDetails/DatasetDetails.component.tsx b/openmetadata-ui/src/main/resources/ui/src/components/DatasetDetails/DatasetDetails.component.tsx index 7b1e2e6f944..8827be984e6 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/DatasetDetails/DatasetDetails.component.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/DatasetDetails/DatasetDetails.component.tsx @@ -394,7 +394,10 @@ const DatasetDetails: React.FC = ({ {activeTab === 2 && (
col.name)} + columns={columns.map((col) => ({ + constraint: col.constraint as string, + colName: col.name, + }))} tableProfiles={tableProfile} />
diff --git a/openmetadata-ui/src/main/resources/ui/src/components/TableProfiler/TableProfiler.component.tsx b/openmetadata-ui/src/main/resources/ui/src/components/TableProfiler/TableProfiler.component.tsx index 72d7587bd0c..fb1aff61c82 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/TableProfiler/TableProfiler.component.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/TableProfiler/TableProfiler.component.tsx @@ -15,11 +15,12 @@ import classNames from 'classnames'; import React, { Fragment, useState } from 'react'; import { Link } from 'react-router-dom'; import { Table, TableProfile } from '../../generated/entity/data/table'; +import { getConstraintIcon } from '../../utils/TableUtils'; import TableProfilerGraph from './TableProfilerGraph.component'; type Props = { tableProfiles: Table['tableProfile']; - columns: Array; + columns: Array<{ constraint: string; colName: string }>; }; type ProfilerGraphData = Array<{ @@ -45,7 +46,7 @@ const TableProfiler = ({ tableProfiles, columns }: Props) => { const columnSpecificData = columns.map((column) => { const data = modifiedData?.map((md) => { const currentColumn = md.columnProfile?.find( - (colProfile) => colProfile.name === column + (colProfile) => colProfile.name === column.colName ); return { profilDate: md.profileDate, ...currentColumn, rows: md.rows }; @@ -85,19 +86,19 @@ const TableProfiler = ({ tableProfiles, columns }: Props) => { -

+

setExpandedColumn((prevState) => ({ - name: col.name, + name: col.name.colName, isExpanded: - prevState.name === col.name + prevState.name === col.name.colName ? !prevState.isExpanded : true, })) }> - {expandedColumn.name === col.name ? ( + {expandedColumn.name === col.name.colName ? ( expandedColumn.isExpanded ? ( ) : ( @@ -107,8 +108,16 @@ const TableProfiler = ({ tableProfiles, columns }: Props) => { )} - {col.name} -

+ {colIndex === 0 && ( + + {getConstraintIcon( + col.name.constraint, + 'tw-relative' + )} + + )} + {col.name.colName} +
{ - {expandedColumn.name === col.name && expandedColumn.isExpanded && ( - - {col.data?.map((colData, index) => ( - - - {colData.profilDate} - - - {colData.rows} - - - {colData.uniqueProportion ?? 0} - - - {colData.nullProportion ?? 0} - - - {colData.min ?? 0} - - - {colData.max ?? 0} - - - {colData.median ?? 0} - - - {colData.stddev ?? 0} - - - ))} - - )} + {expandedColumn.name === col.name.colName && + expandedColumn.isExpanded && ( + + {col.data?.map((colData, index) => ( + + + + {colData.profilDate} + + + + {colData.rows} + + + {colData.uniqueProportion ?? 0} + + + {colData.nullProportion ?? 0} + + + {colData.min ?? 0} + + + {colData.max ?? 0} + + + {colData.median ?? 0} + + + {colData.stddev ?? 0} + + + ))} + + )} ); })} diff --git a/openmetadata-ui/src/main/resources/ui/src/utils/TableUtils.tsx b/openmetadata-ui/src/main/resources/ui/src/utils/TableUtils.tsx index b4aef0d4363..4d126340c01 100644 --- a/openmetadata-ui/src/main/resources/ui/src/utils/TableUtils.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/utils/TableUtils.tsx @@ -11,6 +11,7 @@ * limitations under the License. */ +import classNames from 'classnames'; import { EntityTags, TableDetail } from 'Models'; import React from 'react'; import AppState from '../AppState'; @@ -144,7 +145,7 @@ export const getFollowerDetail = (id: string) => { return follower; }; -export const getConstraintIcon = (constraint = '') => { +export const getConstraintIcon = (constraint = '', className = '') => { let title: string, icon: string; switch (constraint) { case ConstraintTypes.PRIMARY_KEY: @@ -174,7 +175,7 @@ export const getConstraintIcon = (constraint = '') => { return (