Skip to content

Commit 6adbe28

Browse files
satender-kumar-collateSatender
andauthored
Fixes <2370>: made required changes to accommodate tempLineageTable in the Lineage grapgh Tab (#27709)
* added necessary changes to accomodate tempLineageTables nodes * updated code as per comments from Gitar --------- Co-authored-by: Satender <sommy@Satenders-MacBook-Pro.local>
1 parent 7e33fd3 commit 6adbe28

7 files changed

Lines changed: 617 additions & 240 deletions

File tree

openmetadata-ui/src/main/resources/ui/src/components/Entity/EntityLineage/LineageNodeLabelV1.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,11 @@ const EntityLabel = ({ node }: Pick<LineageNodeLabelProps, 'node'>) => {
8484
childrenCount > 0 ? 'with-footer' : ''
8585
)}>
8686
<Col className="d-flex items-center" flex="auto">
87-
<div className="d-flex entity-service-icon m-r-xs">
88-
{getServiceIcon(node)}
89-
</div>
87+
{!node.isTempTable && (
88+
<div className="d-flex entity-service-icon m-r-xs">
89+
{getServiceIcon(node)}
90+
</div>
91+
)}
9092
<Space align="start" className="flex-1" direction="vertical" size={0}>
9193
<Typography.Text
9294
className="m-b-0 d-block text-left entity-header-display-name text-md font-medium w-54"

openmetadata-ui/src/main/resources/ui/src/components/Lineage/Lineage.interface.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@ import { MessageSchemaObject } from '../../generated/entity/data/topic';
2121
import { EntityReference } from '../../generated/entity/type';
2222
import { TagLabel } from '../../generated/tests/testCase';
2323
import { APISchema } from '../../generated/type/apiSchema';
24-
import { ColumnLineage } from '../../generated/type/entityLineage';
24+
import {
25+
ColumnLineage,
26+
TempLineageTable,
27+
} from '../../generated/type/entityLineage';
2528
import {
2629
SearchSourceAlias,
2730
TableSearchSource,
@@ -65,6 +68,7 @@ export interface EdgeDetails {
6568
pipelineEntityType?: EntityType.PIPELINE | EntityType.STORED_PROCEDURE;
6669
docId?: string;
6770
extraInfo?: EdgeDetails;
71+
tempLineageTables?: TempLineageTable[];
6872
}
6973

7074
export interface ColumnLevelLineageNode
@@ -168,4 +172,5 @@ export interface LineageNodeType
168172
responseSchema?: APISchema;
169173
requestSchema?: APISchema;
170174
fields?: SearchIndexField[];
175+
isTempTable?: boolean;
171176
}

openmetadata-ui/src/main/resources/ui/src/context/LineageProvider/LineageProvider.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1231,6 +1231,10 @@ const LineageProvider = ({ children }: LineageProviderProps) => {
12311231
return;
12321232
}
12331233

1234+
if (node.data?.node?.isTempTable) {
1235+
return;
1236+
}
1237+
12341238
if (node.type === EntityLineageNodeType.LOAD_MORE) {
12351239
selectLoadMoreNode(node);
12361240
} else {

openmetadata-ui/src/main/resources/ui/src/utils/CanvasUtils.test.ts

Lines changed: 56 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
* limitations under the License.
1212
*/
1313
import { Edge, Node, Viewport } from 'reactflow';
14+
import { EntityType } from '../enums/entity.enum';
1415
import {
1516
BoundingBox,
1617
boundsIntersect,
@@ -218,11 +219,12 @@ describe('CanvasUtils', () => {
218219

219220
const result = getEdgeCoordinates(edge, sourceNode, targetNode);
220221

222+
// Y uses node.height (100) from createMockNode, so midpoint = 50
221223
expect(result).toEqual({
222224
sourceX: 400,
223-
sourceY: 33,
225+
sourceY: 50,
224226
targetX: 490,
225-
targetY: 33,
227+
targetY: 50,
226228
});
227229
});
228230

@@ -237,9 +239,9 @@ describe('CanvasUtils', () => {
237239

238240
expect(result).not.toBeNull();
239241
expect(result?.sourceX).toBe(500);
240-
expect(result?.sourceY).toBe(233);
242+
expect(result?.sourceY).toBe(250); // 200 + 100/2
241243
expect(result?.targetX).toBe(590);
242-
expect(result?.targetY).toBe(333);
244+
expect(result?.targetY).toBe(350); // 300 + 100/2
243245
});
244246
});
245247

@@ -391,6 +393,54 @@ describe('CanvasUtils', () => {
391393
expect(result?.targetX).toBe(490);
392394
});
393395
});
396+
397+
describe('temp lineage nodes', () => {
398+
const createTempNode = (id: string, measuredHeight: number): Node => ({
399+
id,
400+
position: { x: 0, y: 0 },
401+
data: {
402+
node: {
403+
id,
404+
name: id,
405+
entityType: EntityType.TABLE,
406+
isTempTable: true,
407+
columns: [],
408+
},
409+
isRootNode: false,
410+
},
411+
width: 400,
412+
height: measuredHeight,
413+
});
414+
415+
it('uses measured node.height for temp node entity-level edge', () => {
416+
const edge = createMockEdge('edge1', 'temp_staging', 'node2', false);
417+
const tempNode = createTempNode('temp_staging', 80);
418+
const targetNode = createMockNode('node2');
419+
targetNode.position = { x: 500, y: 0 };
420+
421+
const result = getEdgeCoordinates(edge, tempNode, targetNode);
422+
423+
expect(result).not.toBeNull();
424+
expect(result?.sourceY).toBe(40); // 0 + 80/2 (measured height), not 33 (getNodeHeight formula)
425+
expect(result?.targetY).toBe(50); // 0 + 100/2
426+
});
427+
428+
it('centers edge at actual midpoint when measured height differs from computed height', () => {
429+
const edge = createMockEdge('edge1', 'node1', 'node2', false);
430+
const sourceNode = createMockNode('node1');
431+
sourceNode.height = 150;
432+
sourceNode.position = { x: 0, y: 100 };
433+
const targetNode = createMockNode('node2');
434+
targetNode.height = 200;
435+
targetNode.position = { x: 500, y: 100 };
436+
437+
const result = getEdgeCoordinates(edge, sourceNode, targetNode);
438+
439+
expect(result).not.toBeNull();
440+
expect(result?.sourceY).toBe(175); // 100 + 150/2
441+
expect(result?.targetY).toBe(200); // 100 + 200/2
442+
});
443+
});
394444
});
395445

396446
describe('getEdgeBounds', () => {
@@ -414,7 +464,8 @@ describe('CanvasUtils', () => {
414464
expect(result).not.toBeNull();
415465
expect(result!.minX).toBeLessThan(351);
416466
expect(result!.maxX).toBeGreaterThan(500);
417-
expect(result!.minY).toBeLessThan(0);
467+
// sourceY = 50 (node.height=100 / 2), padding=50 → minY = 0
468+
expect(result!.minY).toBeLessThanOrEqual(0);
418469
expect(result!.maxY).toBeGreaterThan(100);
419470
});
420471
});

openmetadata-ui/src/main/resources/ui/src/utils/CanvasUtils.ts

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,19 @@ const getBaseNodeHeightFromType = (
9393
return isRootNode ? baseHeight + 10 : baseHeight;
9494
};
9595

96+
const getNodeYPadding = (node: Node): number => {
97+
const { children } = getEntityChildrenAndLabel(node.data.node);
98+
99+
const sourceYPadding = children.length > 0 ? 48 : 0;
100+
101+
return sourceYPadding;
102+
};
103+
96104
export function getNodeHeight(
97105
node: Node,
98-
isColumnLineage: boolean,
106+
isColumnLineage?: boolean,
99107
columnCount?: number
100-
) {
108+
): number {
101109
const isRootNode = node.data?.isRootNode ?? false;
102110

103111
const visibleColumnCount = isColumnLineage
@@ -124,15 +132,6 @@ export function getNodeHeight(
124132
return height;
125133
}
126134

127-
const getNodeYPadding = (node: Node): number => {
128-
const { children } = getEntityChildrenAndLabel(node.data.node);
129-
130-
const sourceYPadding = children.length > 0 ? 48 : 0;
131-
132-
// Add padding for the node's border
133-
return sourceYPadding;
134-
};
135-
136135
interface ColumnLineageData {
137136
columnIds: string[];
138137
columnIndex: number;
@@ -252,10 +251,10 @@ function getColumnLineageCoordinates(
252251
function getEntityLineageCoordinates(
253252
sourceNode: Node,
254253
targetNode: Node,
255-
isColumnLineage: boolean
254+
_isColumnLineage: boolean
256255
): EdgeCoordinates {
257-
const sourceHeight = getNodeHeight(sourceNode, isColumnLineage, 0);
258-
const targetHeight = getNodeHeight(targetNode, isColumnLineage, 0);
256+
const sourceHeight = sourceNode.height ?? 0;
257+
const targetHeight = targetNode.height ?? 0;
259258

260259
return {
261260
sourceX: sourceNode.position.x + (sourceNode.width ?? 0),

0 commit comments

Comments
 (0)