@@ -137,10 +137,10 @@ async def list_tools() -> List[Tool]:
137137 description = textwrap .dedent (
138138 """
139139 Get the lineage diff between production(base) and session(current) for changed models.
140- Returns nodes, parent_map (node dependencies), and change_status/impacted information in compact dataframe format.
140+ Returns nodes and edges (node dependencies) in compact dataframe format.
141141
142- In parent_map: key is a node index, value is list of parent node indices
143142 Nodes dataframe includes: idx, id, name, resource_type, materialized, change_status, impacted.
143+ Edges dataframe includes: from (parent node idx), to (child node idx).
144144
145145 Rendering guidance for Mermaid diagram:
146146 Use graph LR and apply these styles based on change_status and impacted:
@@ -450,16 +450,25 @@ async def _tool_lineage_diff(self, arguments: Dict[str, Any]) -> Dict[str, Any]:
450450 data = nodes_data ,
451451 )
452452
453- # Map parent_map IDs to indices
454- parent_map_indexed = {}
453+ # Build edges from parent_map
454+ edges_data = []
455455 for node_id , parents in parent_map .items ():
456456 if node_id in id_to_idx :
457- node_idx = id_to_idx [node_id ]
458- parent_indices = [id_to_idx [p ] for p in parents if p in id_to_idx ]
459- parent_map_indexed [node_idx ] = parent_indices
457+ for parent_id in parents :
458+ if parent_id in id_to_idx :
459+ edges_data .append ((id_to_idx [parent_id ], id_to_idx [node_id ]))
460+
461+ # Create edges DataFrame
462+ edges_df = DataFrame .from_data (
463+ columns = {
464+ "from" : "integer" ,
465+ "to" : "integer" ,
466+ },
467+ data = edges_data ,
468+ )
460469
461470 # Build simplified result
462- result = {"nodes" : nodes_df .model_dump (mode = "json" ), "parent_map " : parent_map_indexed }
471+ result = {"nodes" : nodes_df .model_dump (mode = "json" ), "edges " : edges_df . model_dump ( mode = "json" ) }
463472
464473 return result
465474
0 commit comments