Jump to content

Connect Leeroopedia MCP: Equip your AI agents to search best practices, build plans, verify code, diagnose failures, and look up hyperparameter defaults.

Implementation:TobikoData Sqlmesh Graph Help

From Leeroopedia


Knowledge Sources
Domains Web_UI, Graph_Algorithms, Data_Lineage
Last Updated 2026-02-07 20:00 GMT

Overview

Concrete tool for lineage graph computation and layout algorithms provided by the SQLMesh web client.

Description

Graph_Help is a utility module providing core algorithms for lineage graph processing. It includes functions for graph layout generation using ELK (Eclipse Layout Kernel) with layered algorithms, edge creation from lineage data (both model-level and column-level), node map generation with automatic sizing, lineage merging for incremental updates, connection management for column-level lineage, active node computation based on filters, and visibility determination for nodes and edges based on user selections. The module handles encoding/decoding of model names, fingerprint-based indexing, and ancestor traversal for impact analysis.

Usage

Import specific helper functions when building or updating the lineage graph. These utilities are primarily used by ModelLineage and ModelColumns components to process lineage data and generate layouts.

Code Reference

Source Location

Signature

export function createGraphLayout({
  nodesMap,
  nodes,
  edges,
}: {
  nodesMap: Record<string, Node>
  nodes: Node[]
  edges: Edge[]
}): {
  create: () => Promise<{ nodes: Node[]; edges: Edge[] }>
  terminate: () => void
}

export function getEdges(lineage: Record<string, Lineage>): Edge[]

export function getNodeMap({
  lineage,
  models,
  unknownModels,
  withColumns,
}: {
  models: Map<string, ModelSQLMeshModel>
  withColumns: boolean
  unknownModels: Set<string>
  lineage?: Record<string, Lineage>
}): Record<string, Node>

export function mergeLineageWithColumns(
  currentLineage: Record<string, Lineage>,
  newLineage: Record<string, Record<string, LineageColumn>>,
): Record<string, Lineage>

export function mergeConnections(
  connections: Map<string, Connections>,
  lineage: Record<string, Record<string, LineageColumn>>,
): {
  connections: Map<string, Connections>
  activeEdges: Array<[string, string]>
}

export function hasActiveEdge(
  activeEdges: ActiveEdges,
  [leftConnect, rightConnect]: [Maybe<string>, Maybe<string>],
): boolean

export function getModelAncestors(
  lineage: Record<string, Lineage>,
  name: string,
  output?: Set<string>,
): Set<string>

Import

import {
  createGraphLayout,
  getEdges,
  getNodeMap,
  mergeLineageWithColumns,
  mergeConnections,
  hasActiveEdge,
  getModelAncestors,
} from './help'

I/O Contract

Inputs

Function Input Type Description
createGraphLayout { nodesMap, nodes, edges } Creates ELK-based graph layout
getEdges Record<string, Lineage> Extracts all edges from lineage data
getNodeMap { lineage, models, unknownModels, withColumns } Generates node map with sizing
mergeLineageWithColumns (currentLineage, newLineage) Merges column lineage incrementally
mergeConnections (connections, lineage) Builds column connection map
hasActiveEdge (activeEdges, [left, right]) Checks if edge is active
getModelAncestors (lineage, name, output?) Recursively finds upstream models

Outputs

Function Output Type Description
createGraphLayout { create, terminate } Promise-based layout generator
getEdges Edge[] Array of ReactFlow edges
getNodeMap Record<string, Node> Map of node IDs to Node objects
mergeLineageWithColumns Record<string, Lineage> Updated lineage with columns
mergeConnections { connections, activeEdges } Connection state and active edges
hasActiveEdge boolean True if edge is active
getModelAncestors Set<string> Set of ancestor model names

Usage Examples

// Create graph layout
const layout = createGraphLayout({ nodesMap, nodes, edges })
layout.create().then(({ nodes, edges }) => {
  setNodes(nodes)
  setEdges(edges)
})

// Extract edges from lineage
const edges = getEdges(lineageData)

// Generate node map
const nodesMap = getNodeMap({
  lineage: lineageData,
  models: modelsMap,
  unknownModels: new Set(),
  withColumns: true,
})

// Merge column lineage
const updatedLineage = mergeLineageWithColumns(
  currentLineage,
  columnLineageResponse
)

// Check edge activation
const isActive = hasActiveEdge(activeEdges, [
  'left::model::column',
  'right::upstream::column'
])

// Find all upstream models
const ancestors = getModelAncestors(lineage, 'project.my_model')

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment