From 1ca6329f9b30e5458707757d51ad51bb4f6565f9 Mon Sep 17 00:00:00 2001 From: Chirag Madlani <12962843+chirag-madlani@users.noreply.github.com> Date: Fri, 4 Dec 2026 10:28:12 +0530 Subject: [PATCH 1/2] Fixes #39529: Show nested column paths in lineage and draw in-model column edges on the right column rows - Edge drawer and node column list show a nested column's path inside its own entity (Orders.customer_id) instead of the ambiguous leaf name. - Deep paths truncate the parent path first; the column name stays visible and the full path is in the tooltip. - Edge drawer resolves source and target nodes separately, so an edge within one model shows its Target row. - A column edge inside one model loops on the node's right side between the two column rows instead of reusing the node-level arc behind the node. - Move the edge drawer's overview builders to EdgeInfoDrawer.utils.ts. --- .../EdgeInfoDrawer.component.tsx | 191 +--------------- .../EntityInfoDrawer/EdgeInfoDrawer.test.tsx | 48 +++- .../EntityInfoDrawer/EdgeInfoDrawer.utils.ts | 205 ++++++++++++++++++ .../EntityLineage/CustomNode.utils.test.tsx | 19 ++ .../Entity/EntityLineage/CustomNode.utils.tsx | 45 +++- .../NodeChildren/NodeChildren.component.tsx | 4 + .../VirtualColumnList.component.test.tsx | 54 ++++- .../VirtualColumnList.component.tsx | 17 +- .../ui/src/utils/CanvasUtils.test.ts | 20 ++ .../resources/ui/src/utils/CanvasUtils.ts | 8 +- .../src/utils/EntityLineageEdgeUtils.test.ts | 36 ++- .../ui/src/utils/EntityLineageEdgeUtils.ts | 26 +++ .../resources/ui/src/utils/FqnUtils.test.ts | 52 ++++- .../main/resources/ui/src/utils/FqnUtils.ts | 32 +++ 14 files changed, 549 insertions(+), 208 deletions(-) create mode 100644 openmetadata-ui/src/main/resources/ui/src/components/Entity/EntityInfoDrawer/EdgeInfoDrawer.utils.ts diff --git a/openmetadata-ui/src/main/resources/ui/src/components/Entity/EntityInfoDrawer/EdgeInfoDrawer.component.tsx b/openmetadata-ui/src/main/resources/ui/src/components/Entity/EntityInfoDrawer/EdgeInfoDrawer.component.tsx index 94d228103def..06b1167a9f2f 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/Entity/EntityInfoDrawer/EdgeInfoDrawer.component.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/Entity/EntityInfoDrawer/EdgeInfoDrawer.component.tsx @@ -24,10 +24,8 @@ import { Trash01, XClose, } from '@openmetadata/ui-core-components/icons'; -import { TFunction } from 'i18next'; import { lazy, useCallback, useEffect, useMemo, useState } from 'react'; import { useTranslation } from 'react-i18next'; -import { Edge, Node } from 'reactflow'; import DescriptionSection from '../../../components/common/DescriptionSection/DescriptionSection'; import OverviewSection from '../../../components/common/OverviewSection/OverviewSection'; import SectionWithEdit from '../../../components/common/SectionWithEdit/SectionWithEdit'; @@ -36,23 +34,15 @@ import { LINEAGE_SOURCE } from '../../../constants/Lineage.constants'; import { CSMode } from '../../../enums/codemirror.enum'; import { EntityType } from '../../../enums/entity.enum'; import { AddLineage } from '../../../generated/api/lineage/addLineage'; -import { - ColumnLineage, - EntityReference as LineagePipelineReference, - LineageDetails, - Source, -} from '../../../generated/type/entityLineage'; -import { getRelativeTime } from '../../../utils/date-time/DateTimeUtils'; +import { ColumnLineage, Source } from '../../../generated/type/entityLineage'; import { getLineageDetailsObject, updateColumnLineageFunction, } from '../../../utils/EntityLineageEdgeUtils'; import { getColumnFunctionValue } from '../../../utils/EntityLineagePureUtils'; -import { getEntityName } from '../../../utils/EntityNameUtils'; -import entityUtilClassBase from '../../../utils/EntityUtilClassBase'; -import { getNameFromFQN } from '../../../utils/FqnUtils'; import withSuspenseFallback from '../../AppRouter/withSuspenseFallback'; import Loader from '../../common/Loader/Loader'; +import { buildEdgeOverviewData } from './EdgeInfoDrawer.utils'; import { EdgeInfoDrawerInfo } from './EntityInfoDrawer.interface'; const SchemaEditor = withSuspenseFallback( lazy(() => import('../../Database/SchemaEditor/SchemaEditor')) @@ -74,171 +64,6 @@ const ModalWithQueryEditor = withSuspenseFallback( ) ); -const getUserTimeValue = (user?: string, timestamp?: number) => { - const valueParts = [user, getRelativeTime(timestamp)].filter(Boolean); - - return valueParts.length > 0 ? valueParts.join(' ') : NO_DATA_PLACEHOLDER; -}; - -type OverviewDataItem = { - name: string; - value?: React.ReactNode; - url?: string; - isLink?: boolean; - visible?: string[]; -}; - -const getSourceOverviewItem = ( - sourceData: Node | undefined, - t: TFunction -): OverviewDataItem | undefined => { - if (!sourceData) { - return undefined; - } - const { - entityType: sourceEntityType = '', - fullyQualifiedName: sourceFqn = '', - } = sourceData?.data?.node ?? {}; - - return { - name: t('label.source'), - value: getEntityName(sourceData?.data?.node), - url: entityUtilClassBase.getEntityLink(sourceEntityType, sourceFqn), - isLink: true, - }; -}; - -const getTargetOverviewItem = ( - targetData: Node | undefined, - t: TFunction -): OverviewDataItem | undefined => { - if (!targetData) { - return undefined; - } - const { - entityType: targetEntityType = '', - fullyQualifiedName: targetFqn = '', - } = targetData?.data?.node ?? {}; - - return { - name: t('label.target'), - value: getEntityName(targetData?.data?.node), - url: entityUtilClassBase.getEntityLink(targetEntityType, targetFqn), - isLink: true, - }; -}; - -const getHandleOverviewItem = ( - handle: string | null | undefined, - labelKey: string, - t: TFunction -): OverviewDataItem | undefined => - handle ? { name: t(labelKey), value: getNameFromFQN(handle) } : undefined; - -const getColumnMappingsOverviewItem = ( - columns: ColumnLineage[] | undefined, - isColumnLineage: boolean, - t: TFunction -): OverviewDataItem | undefined => { - const mappings = (columns ?? []).reduce( - (result, { fromColumns, toColumn }) => { - if (toColumn && fromColumns?.length) { - result.push( - `${fromColumns.map(getNameFromFQN).join(', ')} → ${getNameFromFQN( - toColumn - )}` - ); - } - - return result; - }, - [] - ); - - return isColumnLineage || mappings.length === 0 - ? undefined - : { name: t('label.column-plural'), value: mappings.join('; ') }; -}; - -// A rollup edge stands for several lineage edges, so its drawer says how many -// rather than reading as one of them. -const getRollupOverviewItem = ( - weight: number | undefined, - t: TFunction -): OverviewDataItem | undefined => - weight && weight > 1 - ? { name: t('label.edge-plural'), value: String(weight) } - : undefined; - -const getPipelineOverviewItem = ( - pipeline: LineagePipelineReference | undefined, - pipelineEntityType: string | undefined, - t: TFunction -): OverviewDataItem | undefined => { - if (!pipeline) { - return undefined; - } - - return { - name: t('label.edge'), - value: getEntityName(pipeline), - url: entityUtilClassBase.getEntityLink( - pipelineEntityType as string, - pipeline.fullyQualifiedName as string - ), - isLink: true, - }; -}; - -const getCreatedByOverviewItem = ( - edgeInfo: LineageDetails | undefined, - t: TFunction -): OverviewDataItem | undefined => - edgeInfo?.createdBy || edgeInfo?.createdAt - ? { - name: t('label.created-by'), - value: getUserTimeValue(edgeInfo?.createdBy, edgeInfo?.createdAt), - } - : undefined; - -const getUpdatedByOverviewItem = ( - edgeInfo: LineageDetails | undefined, - t: TFunction -): OverviewDataItem | undefined => - edgeInfo?.updatedBy || edgeInfo?.updatedAt - ? { - name: t('label.updated-by'), - value: getUserTimeValue(edgeInfo?.updatedBy, edgeInfo?.updatedAt), - } - : undefined; - -const buildEdgeOverviewData = ( - edge: Edge, - sourceData: Node | undefined, - targetData: Node | undefined, - t: TFunction -): OverviewDataItem[] => { - const { sourceHandle, targetHandle, data } = edge; - const edgeInfo: LineageDetails | undefined = data?.edge; - const { pipeline, pipelineEntityType } = edgeInfo ?? {}; - - return [ - getSourceOverviewItem(sourceData, t), - getHandleOverviewItem(sourceHandle, 'label.source-column', t), - getTargetOverviewItem(targetData, t), - getHandleOverviewItem(targetHandle, 'label.target-column', t), - getRollupOverviewItem(data?.weight, t), - getColumnMappingsOverviewItem( - data?.edge?.columns, - Boolean(data?.isColumnLineage), - t - ), - getPipelineOverviewItem(pipeline, pipelineEntityType, t), - getCreatedByOverviewItem(edgeInfo, t), - getUpdatedByOverviewItem(edgeInfo, t), - ].filter((item): item is OverviewDataItem => Boolean(item)); -}; - const EdgeActionsMenu = ({ onEditPipeline, onDelete, @@ -478,14 +303,10 @@ const EdgeInfoDrawer = ({ const getEdgeInfo = () => { const { source, target } = edge; - let sourceData: Node | undefined, targetData: Node | undefined; - nodes.forEach((node) => { - if (source === node.id) { - sourceData = node; - } else if (target === node.id) { - targetData = node; - } - }); + // A self-edge (column to column inside one data model) has the same + // source and target node. + const sourceData = nodes.find((node) => node.id === source); + const targetData = nodes.find((node) => node.id === target); setEdgeData(buildEdgeOverviewData(edge, sourceData, targetData, t)); setIsLoading(false); diff --git a/openmetadata-ui/src/main/resources/ui/src/components/Entity/EntityInfoDrawer/EdgeInfoDrawer.test.tsx b/openmetadata-ui/src/main/resources/ui/src/components/Entity/EntityInfoDrawer/EdgeInfoDrawer.test.tsx index bcbc32a98c04..cfd75903d475 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/Entity/EntityInfoDrawer/EdgeInfoDrawer.test.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/Entity/EntityInfoDrawer/EdgeInfoDrawer.test.tsx @@ -20,7 +20,6 @@ import { import userEvent from '@testing-library/user-event'; import { Edge, Node } from 'reactflow'; import OverviewSection from '../../../components/common/OverviewSection/OverviewSection'; -import { getNameFromFQN } from '../../../utils/FqnUtils'; import EdgeInfoDrawer from './EdgeInfoDrawer.component'; jest.mock( @@ -50,10 +49,6 @@ jest.mock('../../../components/common/OverviewSection/OverviewSection', () => { )); }); -jest.mock('../../../utils/FqnUtils', () => ({ - getNameFromFQN: jest.fn().mockReturnValue('getNameFromFQN'), -})); - jest.mock('../../../utils/EntityNameUtils', () => ({ getEntityName: jest.fn().mockReturnValue('username'), })); @@ -305,9 +300,6 @@ describe('EdgeInfoDrawer Component', () => { }); it('lists the column mappings of a table edge and the edge count of a rollup', async () => { - (getNameFromFQN as jest.Mock).mockImplementation( - (fqn: string) => fqn.split('.').pop() ?? fqn - ); const edge = { ...mockEdgeInfoDrawer.edge, data: { @@ -339,6 +331,46 @@ describe('EdgeInfoDrawer Component', () => { }); }); + it('qualifies source and target columns with their parent table inside one data model', async () => { + const modelFqn = 'svc.sales_model'; + const modelNode: Node = { + id: 'model-id', + position: { x: 0, y: 0 }, + data: { + node: { + id: 'model-id', + name: 'sales_model', + fullyQualifiedName: modelFqn, + entityType: 'dashboardDataModel', + }, + }, + }; + const edge = { + ...mockEdgeInfoDrawer.edge, + source: 'model-id', + target: 'model-id', + sourceHandle: `${modelFqn}.Orders.customer_id`, + targetHandle: `${modelFqn}.Customers.customer_id`, + } as Edge; + + render( + + ); + + await waitFor(() => { + const calls = (OverviewSection as jest.Mock).mock.calls; + const items: Array<{ name: string; value?: unknown }> = + calls[calls.length - 1]?.[0]?.entityInfoV1 ?? []; + + expect(items).toEqual( + expect.arrayContaining([ + { name: 'label.source-column', value: 'Orders.customer_id' }, + { name: 'label.target-column', value: 'Customers.customer_id' }, + ]) + ); + }); + }); + it('should pass empty componentType to OverviewSection', async () => { render(); diff --git a/openmetadata-ui/src/main/resources/ui/src/components/Entity/EntityInfoDrawer/EdgeInfoDrawer.utils.ts b/openmetadata-ui/src/main/resources/ui/src/components/Entity/EntityInfoDrawer/EdgeInfoDrawer.utils.ts new file mode 100644 index 000000000000..239d951caf61 --- /dev/null +++ b/openmetadata-ui/src/main/resources/ui/src/components/Entity/EntityInfoDrawer/EdgeInfoDrawer.utils.ts @@ -0,0 +1,205 @@ +/* + * Copyright 2026 Collate. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { TFunction } from 'i18next'; +import { ReactNode } from 'react'; +import { Edge, Node } from 'reactflow'; +import { NO_DATA_PLACEHOLDER } from '../../../constants/constants'; +import { + ColumnLineage, + EntityReference as LineagePipelineReference, + LineageDetails, +} from '../../../generated/type/entityLineage'; +import { getRelativeTime } from '../../../utils/date-time/DateTimeUtils'; +import { getEntityName } from '../../../utils/EntityNameUtils'; +import entityUtilClassBase from '../../../utils/EntityUtilClassBase'; +import { getChildPathFromFQN } from '../../../utils/FqnUtils'; + +const getUserTimeValue = (user?: string, timestamp?: number) => { + const valueParts = [user, getRelativeTime(timestamp)].filter(Boolean); + + return valueParts.length > 0 ? valueParts.join(' ') : NO_DATA_PLACEHOLDER; +}; + +export type OverviewDataItem = { + name: string; + value?: ReactNode; + url?: string; + isLink?: boolean; + visible?: string[]; +}; + +const getSourceOverviewItem = ( + sourceData: Node | undefined, + t: TFunction +): OverviewDataItem | undefined => { + if (!sourceData) { + return undefined; + } + const { + entityType: sourceEntityType = '', + fullyQualifiedName: sourceFqn = '', + } = sourceData?.data?.node ?? {}; + + return { + name: t('label.source'), + value: getEntityName(sourceData?.data?.node), + url: entityUtilClassBase.getEntityLink(sourceEntityType, sourceFqn), + isLink: true, + }; +}; + +const getTargetOverviewItem = ( + targetData: Node | undefined, + t: TFunction +): OverviewDataItem | undefined => { + if (!targetData) { + return undefined; + } + const { + entityType: targetEntityType = '', + fullyQualifiedName: targetFqn = '', + } = targetData?.data?.node ?? {}; + + return { + name: t('label.target'), + value: getEntityName(targetData?.data?.node), + url: entityUtilClassBase.getEntityLink(targetEntityType, targetFqn), + isLink: true, + }; +}; + +const getNodeFqn = (node: Node | undefined): string | undefined => + node?.data?.node?.fullyQualifiedName; + +const getHandleOverviewItem = ( + handle: string | null | undefined, + node: Node | undefined, + labelKey: string, + t: TFunction +): OverviewDataItem | undefined => + handle + ? { + name: t(labelKey), + value: getChildPathFromFQN(handle, getNodeFqn(node)), + } + : undefined; + +const getColumnMappingsOverviewItem = ( + columns: ColumnLineage[] | undefined, + isColumnLineage: boolean, + sourceData: Node | undefined, + targetData: Node | undefined, + t: TFunction +): OverviewDataItem | undefined => { + const sourceFqn = getNodeFqn(sourceData); + const targetFqn = getNodeFqn(targetData); + const mappings = (columns ?? []).reduce( + (result, { fromColumns, toColumn }) => { + if (toColumn && fromColumns?.length) { + const from = fromColumns + .map((column) => getChildPathFromFQN(column, sourceFqn)) + .join(', '); + result.push(`${from} → ${getChildPathFromFQN(toColumn, targetFqn)}`); + } + + return result; + }, + [] + ); + + return isColumnLineage || mappings.length === 0 + ? undefined + : { name: t('label.column-plural'), value: mappings.join('; ') }; +}; + +// A rollup edge stands for several lineage edges, so its drawer says how many +// rather than reading as one of them. +const getRollupOverviewItem = ( + weight: number | undefined, + t: TFunction +): OverviewDataItem | undefined => + weight && weight > 1 + ? { name: t('label.edge-plural'), value: String(weight) } + : undefined; + +const getPipelineOverviewItem = ( + pipeline: LineagePipelineReference | undefined, + pipelineEntityType: string | undefined, + t: TFunction +): OverviewDataItem | undefined => { + if (!pipeline) { + return undefined; + } + + return { + name: t('label.edge'), + value: getEntityName(pipeline), + url: entityUtilClassBase.getEntityLink( + pipelineEntityType as string, + pipeline.fullyQualifiedName as string + ), + isLink: true, + }; +}; + +const getCreatedByOverviewItem = ( + edgeInfo: LineageDetails | undefined, + t: TFunction +): OverviewDataItem | undefined => + edgeInfo?.createdBy || edgeInfo?.createdAt + ? { + name: t('label.created-by'), + value: getUserTimeValue(edgeInfo?.createdBy, edgeInfo?.createdAt), + } + : undefined; + +const getUpdatedByOverviewItem = ( + edgeInfo: LineageDetails | undefined, + t: TFunction +): OverviewDataItem | undefined => + edgeInfo?.updatedBy || edgeInfo?.updatedAt + ? { + name: t('label.updated-by'), + value: getUserTimeValue(edgeInfo?.updatedBy, edgeInfo?.updatedAt), + } + : undefined; + +export const buildEdgeOverviewData = ( + edge: Edge, + sourceData: Node | undefined, + targetData: Node | undefined, + t: TFunction +): OverviewDataItem[] => { + const { sourceHandle, targetHandle, data } = edge; + const edgeInfo: LineageDetails | undefined = data?.edge; + const { pipeline, pipelineEntityType } = edgeInfo ?? {}; + + return [ + getSourceOverviewItem(sourceData, t), + getHandleOverviewItem(sourceHandle, sourceData, 'label.source-column', t), + getTargetOverviewItem(targetData, t), + getHandleOverviewItem(targetHandle, targetData, 'label.target-column', t), + getRollupOverviewItem(data?.weight, t), + getColumnMappingsOverviewItem( + data?.edge?.columns, + Boolean(data?.isColumnLineage), + sourceData, + targetData, + t + ), + getPipelineOverviewItem(pipeline, pipelineEntityType, t), + getCreatedByOverviewItem(edgeInfo, t), + getUpdatedByOverviewItem(edgeInfo, t), + ].filter((item): item is OverviewDataItem => Boolean(item)); +}; diff --git a/openmetadata-ui/src/main/resources/ui/src/components/Entity/EntityLineage/CustomNode.utils.test.tsx b/openmetadata-ui/src/main/resources/ui/src/components/Entity/EntityLineage/CustomNode.utils.test.tsx index 1ed00696094c..7d2a16d8bae9 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/Entity/EntityLineage/CustomNode.utils.test.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/Entity/EntityLineage/CustomNode.utils.test.tsx @@ -164,6 +164,25 @@ describe('Custom Node Utils', () => { expect(getByText('NOT NULL')).toBeInTheDocument(); }); + it('keeps the column name in its own segment after the parent path', () => { + const { getByTestId, getByText } = render( + + + + ); + + expect(getByText('Region.Country.State.')).toBeInTheDocument(); + expect(getByText('test column')).toBeInTheDocument(); + expect(getByTestId('column-test.column')).toHaveTextContent( + 'Region.Country.State.test column' + ); + }); + it('should apply tracing class when isColumnTraced is true', () => { const { getByTestId } = render( diff --git a/openmetadata-ui/src/main/resources/ui/src/components/Entity/EntityLineage/CustomNode.utils.tsx b/openmetadata-ui/src/main/resources/ui/src/components/Entity/EntityLineage/CustomNode.utils.tsx index de832e599a6e..3ca8ab474a46 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/Entity/EntityLineage/CustomNode.utils.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/Entity/EntityLineage/CustomNode.utils.tsx @@ -13,6 +13,7 @@ import { ButtonUtility, Skeleton, + Tooltip, Typography, } from '@openmetadata/ui-core-components'; import { @@ -193,9 +194,36 @@ export const getCollapseHandle = ( ); }; +// The parent path gives way first, so a deep path never hides the column name; +// the name keeps at most 3/4 so some of the path always shows. +const ColumnNameLabel = ({ + name, + parentPath, +}: { + name: string; + parentPath?: string; +}) => + parentPath ? ( + + {`${parentPath}.`} + {name} + + ) : ( + + {name} + + ); + const getColumnNameContent = ( column: EntityChildrenItem, - isLoading: boolean + isLoading: boolean, + parentPath?: string ) => { if (isLoading) { return ; @@ -211,12 +239,7 @@ const getColumnNameContent = ( })} )} - - {getEntityName(column)} - + ); }; @@ -227,6 +250,8 @@ interface ColumnContentProps { isLoading: boolean; summary?: ColumnTestSummaryDefinition; depth?: number; + // Shown before the name when the list is flattened and parent rows are hidden. + parentPath?: string; className?: string; onColumnHover?: (columnFqn?: string) => void; onColumnSelect?: (columnFqn?: string) => void; @@ -243,6 +268,7 @@ const ColumnContentInner = ({ isLoading, summary, depth = 0, + parentPath, className = '', onColumnHover, onColumnSelect, @@ -281,8 +307,8 @@ const ColumnContentInner = ({ }, [onColumnHover, selectedColumn, setTracedColumns]); const columnNameContentRender = useMemo( - () => getColumnNameContent(column, isLoading), - [column, isLoading] + () => getColumnNameContent(column, isLoading, parentPath), + [column, isLoading, parentPath] ); return ( @@ -346,6 +372,7 @@ export const ColumnContent = memo(ColumnContentInner, (prev, next) => { const renderPropsEqual = prev.summary === next.summary && prev.depth === next.depth && + prev.parentPath === next.parentPath && prev.className === next.className; const columnCallbacksEqual = prev.onColumnHover === next.onColumnHover && diff --git a/openmetadata-ui/src/main/resources/ui/src/components/Entity/EntityLineage/NodeChildren/NodeChildren.component.tsx b/openmetadata-ui/src/main/resources/ui/src/components/Entity/EntityLineage/NodeChildren/NodeChildren.component.tsx index dd4ff2759aa6..3c99ba3bb71a 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/Entity/EntityLineage/NodeChildren/NodeChildren.component.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/Entity/EntityLineage/NodeChildren/NodeChildren.component.tsx @@ -197,10 +197,14 @@ const NodeChildren = ({
({ ColumnContent: ({ column, className, + parentPath, }: { column: Column; className: string; + parentPath?: string; }) => (
- {column.name} + {parentPath ? `${parentPath}.${column.name}` : column.name}
), })); @@ -330,6 +332,56 @@ describe('VirtualColumnList', () => { }); }); + it('shows nested columns by leaf name while the hierarchy is visible', () => { + const flatItems = [ + createFlatItem( + createColumn('customer_id', 'svc.model.Orders.customer_id'), + 1 + ), + ]; + + render( + + ); + + expect( + screen.getByTestId('column-svc.model.Orders.customer_id') + ).toHaveTextContent(/^customer_id$/); + }); + + it('qualifies same-named nested columns with their parent path when flattened', () => { + const flatItems = [ + createFlatItem( + createColumn('customer_id', 'svc.model.Orders.customer_id'), + 1 + ), + createFlatItem( + createColumn('customer_id', 'svc.model.Customers.customer_id'), + 1 + ), + ]; + + render( + + ); + + expect( + screen.getByTestId('column-svc.model.Orders.customer_id') + ).toHaveTextContent('Orders.customer_id'); + expect( + screen.getByTestId('column-svc.model.Customers.customer_id') + ).toHaveTextContent('Customers.customer_id'); + }); + it('handles empty traced columns set', () => { mockUseLineageStore.tracedColumns = new Set(); diff --git a/openmetadata-ui/src/main/resources/ui/src/components/Entity/EntityLineage/NodeChildren/VirtualColumnList.component.tsx b/openmetadata-ui/src/main/resources/ui/src/components/Entity/EntityLineage/NodeChildren/VirtualColumnList.component.tsx index f54f967f5a05..0391051bc5bf 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/Entity/EntityLineage/NodeChildren/VirtualColumnList.component.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/Entity/EntityLineage/NodeChildren/VirtualColumnList.component.tsx @@ -22,12 +22,19 @@ import { EntityChildrenItem, } from '../../../../interface/lineage.interface'; import EntityLink from '../../../../utils/EntityLink'; +import { getParentPathFromFQN } from '../../../../utils/FqnUtils'; import { ColumnContent } from '../CustomNode.utils'; export interface VirtualColumnListProps { flatItems: EntityChildren; isLoading: boolean; nodeId?: string; + entityFqn?: string; + /** + * Search and the lineage filter drop parent rows, so nested columns are + * shown flat with their path inside the entity (`Orders.customer_id`). + */ + showChildPath?: boolean; onColumnHover?: (columnFqn?: string) => void; onColumnSelect?: (columnFqn?: string) => void; onColumnLineageEdit?: ( @@ -44,6 +51,8 @@ const VirtualColumnList = ({ flatItems, isLoading, nodeId, + entityFqn, + showChildPath = false, onColumnHover, onColumnSelect, onColumnLineageEdit, @@ -137,14 +146,18 @@ const VirtualColumnList = ({ (column: EntityChildrenItem, className: string) => { const { depth = 0 } = 'depth' in column ? column : {}; const columnSummary = getColumnSummary(column); + const parentPath = showChildPath + ? getParentPathFromFQN(column.fullyQualifiedName ?? '', entityFqn) + : undefined; return ( { expect(result?.targetX).toBe(500); }); + it('ends a column edge inside one node on the right side of its target column', () => { + const edge = createMockEdge('edge1', 'node1', 'node1', true); + edge.sourceHandle = 'col1'; + edge.targetHandle = 'col2'; + + const node = createNodeWithFlattenColumns('node1', 5); + node.position = { x: 100, y: 0 }; + + const result = getEdgeCoordinates( + edge, + node, + node, + new Map([['node1', ['col1', 'col2']]]) + ); + + expect(result?.sourceX).toBe(500); + expect(result?.targetX).toBe(500); + expect(result?.targetY).toBeGreaterThan(result?.sourceY ?? 0); + }); + it('falls back to entity lineage when columnsInCurrentPages not provided', () => { const edge = createMockEdge('edge1', 'node1', 'node2', true); const sourceNode = createMockNode('node1', 5); diff --git a/openmetadata-ui/src/main/resources/ui/src/utils/CanvasUtils.ts b/openmetadata-ui/src/main/resources/ui/src/utils/CanvasUtils.ts index a5a885db8d76..2b16f38e434f 100644 --- a/openmetadata-ui/src/main/resources/ui/src/utils/CanvasUtils.ts +++ b/openmetadata-ui/src/main/resources/ui/src/utils/CanvasUtils.ts @@ -248,10 +248,14 @@ function getColumnLineageCoordinates( targetData.isFilterActive ); + const sourceX = sourceNode.position.x + NODE_WIDTH; + return { - sourceX: sourceNode.position.x + NODE_WIDTH, + sourceX, sourceY: sourceNode.position.y + sourceY, - targetX: targetNode.position.x, + // Within one node, enter the target column beside its source so the edge + // can loop on the node's right side rather than cross the node body. + targetX: sourceNode.id === targetNode.id ? sourceX : targetNode.position.x, targetY: targetNode.position.y + targetY, }; } diff --git a/openmetadata-ui/src/main/resources/ui/src/utils/EntityLineageEdgeUtils.test.ts b/openmetadata-ui/src/main/resources/ui/src/utils/EntityLineageEdgeUtils.test.ts index ad067392784e..14a5359ccf99 100644 --- a/openmetadata-ui/src/main/resources/ui/src/utils/EntityLineageEdgeUtils.test.ts +++ b/openmetadata-ui/src/main/resources/ui/src/utils/EntityLineageEdgeUtils.test.ts @@ -10,11 +10,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { Connection, Edge } from 'reactflow'; +import { Connection, Edge, Position } from 'reactflow'; import { ColumnLineage } from '../generated/type/entityLineage'; import { EdgeDetails } from '../interface/lineage.interface'; import { getColumnLineageData, + getEdgePathData, getUpdatedColumnsFromEdge, updateColumnLineageFunction, } from './EntityLineageEdgeUtils'; @@ -251,3 +252,36 @@ describe('updateColumnLineageFunction', () => { ); }); }); + +describe('getEdgePathData', () => { + const positions = { + sourcePosition: Position.Right, + targetPosition: Position.Left, + }; + + it('loops a column edge inside one node out to the right and back in', () => { + const { edgePath, edgeCenterX, edgeCenterY } = getEdgePathData('n1', 'n1', { + ...positions, + sourceX: 400, + sourceY: 120, + targetX: 400, + targetY: 180, + }); + + expect(edgePath).toBe('M 400 120 C 440 120 440 180 400 180'); + expect(edgeCenterX).toBeGreaterThan(400); + expect(edgeCenterY).toBe(150); + }); + + it('keeps the arc over the node for a node-level self edge', () => { + const { edgePath } = getEdgePathData('n1', 'n1', { + ...positions, + sourceX: 400, + sourceY: 58, + targetX: 0, + targetY: 58, + }); + + expect(edgePath).toContain(' A '); + }); +}); diff --git a/openmetadata-ui/src/main/resources/ui/src/utils/EntityLineageEdgeUtils.ts b/openmetadata-ui/src/main/resources/ui/src/utils/EntityLineageEdgeUtils.ts index 87e0916b9bc9..b670268d1c10 100644 --- a/openmetadata-ui/src/main/resources/ui/src/utils/EntityLineageEdgeUtils.ts +++ b/openmetadata-ui/src/main/resources/ui/src/utils/EntityLineageEdgeUtils.ts @@ -487,11 +487,37 @@ const getEdgePath = ( : edgePath; }; +const SIDE_LOOP_WIDTH = 40; + +// A column edge inside one node starts and ends on the node's right side, so it +// loops out to the right and back in, instead of the node-level arc over the +// header that would run behind the node body. +const getSideLoopPathData = ({ + sourceX, + sourceY, + targetY, +}: EdgeAlignmentPathDataProps) => { + const loopX = sourceX + SIDE_LOOP_WIDTH; + + return { + edgePath: `M ${sourceX} ${sourceY} C ${loopX} ${sourceY} ${loopX} ${targetY} ${sourceX} ${targetY}`, + edgeCenterX: sourceX + SIDE_LOOP_WIDTH * 0.75, + edgeCenterY: (sourceY + targetY) / 2, + }; +}; + export const getEdgePathData = ( source: string, target: string, edgePathData: EdgeAlignmentPathDataProps ) => { + if ( + isSelfConnectingEdge(source, target) && + edgePathData.sourceX === edgePathData.targetX + ) { + return getSideLoopPathData(edgePathData); + } + const { sourceX, sourceY, targetX, targetY } = getEdgePathAlignmentData( source, target, diff --git a/openmetadata-ui/src/main/resources/ui/src/utils/FqnUtils.test.ts b/openmetadata-ui/src/main/resources/ui/src/utils/FqnUtils.test.ts index 5c1b77fdd2f4..570143dd9c57 100644 --- a/openmetadata-ui/src/main/resources/ui/src/utils/FqnUtils.test.ts +++ b/openmetadata-ui/src/main/resources/ui/src/utils/FqnUtils.test.ts @@ -11,7 +11,11 @@ * limitations under the License. */ -import { getTableFQNFromColumnFQN } from './FqnUtils'; +import { + getChildPathFromFQN, + getParentPathFromFQN, + getTableFQNFromColumnFQN, +} from './FqnUtils'; describe('FqnUtils', () => { describe('getTableFQNFromColumnFQN', () => { @@ -29,4 +33,50 @@ describe('FqnUtils', () => { expect(result).toBe(tableFQN); }); }); + + describe('getChildPathFromFQN', () => { + it('returns the path of a nested column inside its entity', () => { + expect( + getChildPathFromFQN('svc.model.Orders.customer_id', 'svc.model') + ).toBe('Orders.customer_id'); + }); + + it('returns the leaf name for a top-level column', () => { + expect(getChildPathFromFQN('svc.db.sch.tbl.id', 'svc.db.sch.tbl')).toBe( + 'id' + ); + }); + + it('keeps quotes on names containing the separator', () => { + expect( + getChildPathFromFQN('svc.model."Order.Lines".qty', 'svc.model') + ).toBe('"Order.Lines".qty'); + }); + + it('falls back to the leaf name when the entity is unknown or unrelated', () => { + expect(getChildPathFromFQN('svc.model.Orders.customer_id')).toBe( + 'customer_id' + ); + expect( + getChildPathFromFQN('svc.model.Orders.customer_id', 'other.model') + ).toBe('customer_id'); + }); + }); + + describe('getParentPathFromFQN', () => { + it('returns every parent of a deeply nested column', () => { + expect( + getParentPathFromFQN( + 'svc.model.Region.Country.State.City.id', + 'svc.model' + ) + ).toBe('Region.Country.State.City'); + }); + + it('is empty for a top-level or unrelated column', () => { + expect(getParentPathFromFQN('svc.model.id', 'svc.model')).toBe(''); + expect(getParentPathFromFQN('svc.model.Orders.id', 'other')).toBe(''); + expect(getParentPathFromFQN('svc.model.Orders.id')).toBe(''); + }); + }); }); diff --git a/openmetadata-ui/src/main/resources/ui/src/utils/FqnUtils.ts b/openmetadata-ui/src/main/resources/ui/src/utils/FqnUtils.ts index c53293250e5b..c99bc0b6570f 100644 --- a/openmetadata-ui/src/main/resources/ui/src/utils/FqnUtils.ts +++ b/openmetadata-ui/src/main/resources/ui/src/utils/FqnUtils.ts @@ -155,3 +155,35 @@ export const getNameFromFQN = (fqn: string): string => { return arr[arr.length - 1]; }; + +const getChildPathParts = ( + childFqn: string, + entityFqn?: string +): string[] | undefined => + entityFqn && childFqn.startsWith(`${entityFqn}${FQN_SEPARATOR_CHAR}`) + ? Fqn.split(childFqn).slice(Fqn.split(entityFqn).length) + : undefined; + +/** + * Path of a child (column, field) inside its entity, e.g. `Orders.customer_id` + * for `service.model.Orders.customer_id`. Nested children of one entity can + * share a leaf name, so the leaf alone is ambiguous. + */ +export const getChildPathFromFQN = ( + childFqn: string, + entityFqn?: string +): string => + getChildPathParts(childFqn, entityFqn)?.join(FQN_SEPARATOR_CHAR) ?? + getNameFromFQN(childFqn); + +/** + * The parents of a child inside its entity (`Orders` for + * `service.model.Orders.customer_id`); empty for a top-level child. + */ +export const getParentPathFromFQN = ( + childFqn: string, + entityFqn?: string +): string => + getChildPathParts(childFqn, entityFqn) + ?.slice(0, -1) + .join(FQN_SEPARATOR_CHAR) ?? ''; From a1732ba273aa3ba7f0a55873a09597a0ce0dc101 Mon Sep 17 00:00:00 2001 From: Chirag Madlani <12962843+chirag-madlani@users.noreply.github.com> Date: Fri, 4 Dec 2026 11:53:54 +0530 Subject: [PATCH 2/2] Use Typography for the nested column label segments The parent path takes its muted colour from the color prop instead of a text-colour class, matching the plain-name branch. --- .../Entity/EntityLineage/CustomNode.utils.tsx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/openmetadata-ui/src/main/resources/ui/src/components/Entity/EntityLineage/CustomNode.utils.tsx b/openmetadata-ui/src/main/resources/ui/src/components/Entity/EntityLineage/CustomNode.utils.tsx index 3ca8ab474a46..ecb394c84401 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/Entity/EntityLineage/CustomNode.utils.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/Entity/EntityLineage/CustomNode.utils.tsx @@ -208,8 +208,15 @@ const ColumnNameLabel = ({ excludeTriggerFromTabOrder title={`${parentPath}.${name}`} triggerClassName="custom-node-column-label tw:flex tw:min-w-0 tw:max-w-full"> - {`${parentPath}.`} - {name} + + {`${parentPath}.`} + + + {name} + ) : (