Skip to content

Commit 2c59909

Browse files
committed
fix(ui): show full names and transform kinds in column lineage
Traced identifiers and node names wrap instead of truncating, column types stay on one line, and transformed edges name the compiler's transform kind, such as Cast or Aggregation.
1 parent 2994b2a commit 2c59909

5 files changed

Lines changed: 42 additions & 28 deletions

File tree

‎ui/src/lib/api/http-catalog.test.ts‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ describe('column lineage mapping', () => {
102102
const nodes = toCatalogNodes([node('model:raw_orders', { materialization: 'view' }), node('model:orders', { materialization: 'table' })]);
103103
const edge = (source: string, target: string, transform: string): W['ColumnLineageEdge'] => ({ source_key: 'model:raw_orders', source_column: source, target_key: 'model:orders', target_column: target, transform });
104104

105-
it('keeps a name through direct or star as a passthrough, a new name as a rename, and anything else as a transform', () => {
105+
it('keeps a name through direct or star as a passthrough, a new name as a rename, and names any other transform', () => {
106106
const lineage = toColumnLineage(
107107
{
108108
snapshot_id: 's',
@@ -115,11 +115,11 @@ describe('column lineage mapping', () => {
115115
},
116116
nodes
117117
);
118-
expect(lineage?.edges.map(([, target, lens]) => [target, lens])).toEqual([
119-
['model:orders.id', 'passthrough'],
120-
['model:orders.note', 'passthrough'],
121-
['model:orders.customer_id', 'rename'],
122-
['model:orders.amount', 'transform']
118+
expect(lineage?.edges.map(([, target, lens, label]) => [target, lens, label])).toEqual([
119+
['model:orders.id', 'passthrough', undefined],
120+
['model:orders.note', 'passthrough', undefined],
121+
['model:orders.customer_id', 'rename', undefined],
122+
['model:orders.amount', 'transform', 'Cast']
123123
]);
124124
expect(lineage?.models.map((m) => [m.id, m.name, m.kind, m.columns])).toEqual([
125125
['model:raw_orders', 'raw_orders', 'view', [{ name: 'amount', type: '' }]],

‎ui/src/lib/api/http-catalog.ts‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,12 @@ function lensOf(edge: Wire['ColumnLineageEdge']): ColumnLens {
112112
return edge.source_column === edge.target_column ? 'passthrough' : 'rename';
113113
}
114114

115+
/** The compiler's transform kind as a label, such as `Cast`; passthroughs and renames keep the lens's own name. */
116+
function transformLabel(edge: Wire['ColumnLineageEdge']): string | undefined {
117+
if (lensOf(edge) !== 'transform') return undefined;
118+
return edge.transform === 'unknown' ? 'Transformed' : edge.transform.charAt(0).toUpperCase() + edge.transform.slice(1);
119+
}
120+
115121
/**
116122
* Column lineage around one node, named and coloured from the catalog listing. The read carries no
117123
* SQL or expressions, so those stay empty; null before a snapshot publishes lineage for the node.
@@ -125,7 +131,7 @@ export function toColumnLineage(read: Wire['ColumnLineageRead'], nodes: CatalogN
125131
const columns = n.columns.map((c) => ({ name: c.name, type: c.data_type ?? '' }));
126132
return node ? [{ id: n.node_key, name: shortName(n.node_key), kind: node.kind, status: cardStatus(node), columns }] : [];
127133
}),
128-
edges: read.edges.map((e) => [`${e.source_key}.${e.source_column}`, `${e.target_key}.${e.target_column}`, lensOf(e)]),
134+
edges: read.edges.map((e) => [`${e.source_key}.${e.source_column}`, `${e.target_key}.${e.target_column}`, lensOf(e), transformLabel(e)]),
129135
sql: {},
130136
expressions: {}
131137
};

‎ui/src/lib/api/types/build.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,8 @@ export type ColumnLens = 'raw' | 'passthrough' | 'rename' | 'transform';
194194

195195
export type ColumnLineage = {
196196
models: { id: string; name: string; kind: string; status: 'ok' | 'fail' | 'warn' | 'stale' | 'src' | 'none'; columns: { name: string; type: string }[] }[];
197-
/** `model.column` pairs from upstream to downstream. */
198-
edges: [string, string, ColumnLens][];
197+
/** `model.column` pairs from upstream to downstream, with an optional label naming the transform, such as `Cast`. */
198+
edges: [string, string, ColumnLens, string?][];
199199
sql: Record<string, string>;
200200
/** The defining expression of each column, per model. */
201201
expressions: Record<string, Record<string, string>>;

‎ui/src/lib/components/lineage/col-cell-node.svelte‎

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
kind: string;
1010
status: 'ok' | 'fail' | 'warn' | 'stale' | 'src' | 'none';
1111
lens?: Lens;
12-
lensLabel?: Record<Lens, string>;
12+
/** What the incoming edge does, such as `Cast`. */
13+
label?: string;
1314
focal?: boolean;
1415
active?: boolean;
1516
};
@@ -32,21 +33,22 @@
3233
<div
3334
class="overflow-hidden rounded-[2px] border bg-[var(--card)]"
3435
data-colid={id}
35-
style:width="190px"
36+
style:min-width="190px"
37+
style:max-width="320px"
3638
style:border-color={d.focal || d.active ? 'var(--primary)' : 'var(--node-border)'}
3739
style:box-shadow={d.focal ? '0 0 0 1px var(--primary)' : 'none'}
3840
>
3941
<Handle type="target" position={Position.Left} style="width:7px;height:7px;background:var(--sb-edge);border:none;" />
4042
<!-- column (primary) -->
4143
<div class="flex items-center gap-2 px-3 py-2" style:border-left="3px solid {statusColor[d.status]}">
42-
<span class="truncate font-mono text-[12.5px] font-medium text-foreground">{d.column}</span>
44+
<span class="font-mono text-[12.5px] font-medium text-foreground [overflow-wrap:anywhere]">{d.column}</span>
4345
</div>
4446
<!-- model (context) -->
4547
<div class="flex items-center gap-1.5 border-t border-[var(--border-subtle)] px-3 py-1.5">
46-
<KindIcon size={11} color={kindColor} />
47-
<span class="text-muted-foreground truncate text-[12px]">{d.model}</span>
48-
{#if d.lens && d.lensLabel}
49-
<span class="ml-auto shrink-0 text-[11.5px]" class:font-semibold={d.lens === 'transform'} style:color={d.lens === 'transform' ? 'var(--foreground)' : 'var(--sb-text-faint)'}>{d.lensLabel[d.lens]}</span>
48+
<KindIcon size={11} color={kindColor} class="shrink-0" />
49+
<span class="text-muted-foreground min-w-0 text-[12px] [overflow-wrap:anywhere]">{d.model}</span>
50+
{#if d.lens && d.label}
51+
<span class="ml-auto shrink-0 pl-2 text-[11.5px]" class:font-semibold={d.lens === 'transform'} style:color={d.lens === 'transform' ? 'var(--foreground)' : 'var(--sb-text-faint)'}>{d.label}</span>
5052
{:else}
5153
<span class="text-[var(--sb-text-faint)] ml-auto text-[11px]">{d.kind}</span>
5254
{/if}

‎ui/src/lib/lineage/column-lineage.svelte‎

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
}: {
2525
focal: string;
2626
models: ColModel[];
27-
colEdges: [string, string, Lens][];
27+
colEdges: [string, string, Lens, string?][];
2828
/** per-model SQL: modelId -> SQL text */
2929
modelSql?: Record<string, string>;
3030
/** per-model column expressions: modelId -> { colName -> defining substring } */
@@ -70,6 +70,9 @@
7070
const kindOf = (id: string) => models.find((m) => m.id === id)?.kind ?? 'table';
7171
const statusOf = (id: string) => models.find((m) => m.id === id)?.status ?? 'ok';
7272
const incomingLens = $derived(new Map<string, Lens>(colEdges.map(([, t, lens]) => [t, lens])));
73+
// What a column's incoming edge does: the published transform, such as Cast, or the lens's name.
74+
const incomingLabel = $derived(new Map<string, string>(colEdges.map(([, t, lens, label]) => [t, label ?? lensLabel[lens]])));
75+
const labelOf = (cid: string) => incomingLabel.get(cid) ?? lensLabel.raw;
7376
7477
const focalModel = $derived(models.find((m) => m.id === focal));
7578
let colQuery = $state('');
@@ -223,7 +226,7 @@
223226
kind: kindOf(modelOf(cid)),
224227
status: statusOf(modelOf(cid)),
225228
lens: incomingLens.get(cid),
226-
lensLabel,
229+
label: incomingLens.has(cid) ? labelOf(cid) : undefined,
227230
focal: cid === selectedCol,
228231
active: cid === activeStep
229232
}
@@ -284,9 +287,9 @@
284287
onclick={() => (selectedCol = cid)}
285288
>
286289
{#if selectedCol === cid}<span class="bg-primary absolute left-0 h-5 w-[2px]"></span>{/if}
287-
<span class="truncate" style:color={selectedCol === cid ? 'var(--foreground)' : 'var(--muted-foreground)'}>{c.name}</span>
288-
<span class="ml-auto shrink-0 text-[11.5px]" class:text-foreground={lens === 'transform'} class:text-muted-foreground={lens !== 'transform'}>{lens ? lensLabel[lens] : ''}</span>
289-
<span class="text-[var(--sb-text-faint)] w-[52px] shrink-0 text-right font-mono text-[11px]">{c.type.toLowerCase()}</span>
290+
<span class="col-name" style:color={selectedCol === cid ? 'var(--foreground)' : 'var(--muted-foreground)'}>{c.name}</span>
291+
<span class="ml-auto shrink-0 text-[11.5px]" class:text-foreground={lens === 'transform'} class:text-muted-foreground={lens !== 'transform'}>{lens ? labelOf(cid) : ''}</span>
292+
{#if c.type}<span class="text-[var(--sb-text-faint)] shrink-0 whitespace-nowrap text-right font-mono text-[11px]">{c.type.toLowerCase()}</span>{/if}
290293
</button>
291294
{:else}
292295
<div class="text-[var(--sb-text-faint)] px-3 py-4 text-center text-[11.5px]">No columns match.</div>
@@ -369,8 +372,8 @@
369372
<li class:focal={st.depth === 0} class:active={activeStep === st.cid}>
370373
<button onmouseenter={() => (hoverNode = st.cid)} onmouseleave={() => (hoverNode = null)} onclick={() => (pinnedNode = pinnedNode === st.cid ? null : st.cid)}>
371374
<i></i>
372-
<span class="dv-name"><span class="m">{st.model}.</span>{st.col}</span>
373-
<span class="dv-lens" class:strong={st.lens === 'transform'}>{lensLabel[st.lens]}</span>
375+
<span class="dv-name" title="{st.model}.{st.col}"><span class="m">{st.model}.</span>{st.col}</span>
376+
<span class="dv-lens" class:strong={st.lens === 'transform'}>{labelOf(st.cid)}</span>
374377
{#if st.expr && st.lens !== 'raw'}<code>{@html highlightSqlbuild(st.expr)}</code>{/if}
375378
</button>
376379
</li>
@@ -383,8 +386,8 @@
383386
<li class:active={activeStep === st.cid}>
384387
<button onmouseenter={() => (hoverNode = st.cid)} onmouseleave={() => (hoverNode = null)} onclick={() => (pinnedNode = pinnedNode === st.cid ? null : st.cid)}>
385388
<i></i>
386-
<span class="dv-name"><span class="m">{st.model}.</span>{st.col}</span>
387-
<span class="dv-lens" class:strong={st.lens === 'transform'}>{lensLabel[st.lens]}</span>
389+
<span class="dv-name" title="{st.model}.{st.col}"><span class="m">{st.model}.</span>{st.col}</span>
390+
<span class="dv-lens" class:strong={st.lens === 'transform'}>{labelOf(st.cid)}</span>
388391
{#if st.expr}<code>{@html highlightSqlbuild(st.expr)}</code>{/if}
389392
</button>
390393
</li>
@@ -498,11 +501,14 @@
498501
border-color: var(--primary);
499502
background: var(--primary);
500503
}
504+
/* The identifier being traced wraps rather than truncates. */
501505
.dv-name {
502-
overflow: hidden;
503506
font: 12.5px var(--font-mono);
504-
text-overflow: ellipsis;
505-
white-space: nowrap;
507+
overflow-wrap: anywhere;
508+
}
509+
.col-name {
510+
min-width: 0;
511+
overflow-wrap: anywhere;
506512
}
507513
.dv-name .m {
508514
color: var(--muted-foreground);

0 commit comments

Comments
 (0)