feat: federated query spans all 5 databases (not just 3)

The marquee panel only joined 3 region-keyed sources. Add a
"one SQL across every database" reach matrix that fans a single
Trino query out to PostgreSQL, MySQL, MongoDB, Cassandra and the
Hadoop/Iceberg lake in one UNION ALL (telemetry has no region, so
a per-source summary is used instead of a misleading join).

- New MATRIX_SQL + concurrent execution alongside the region
  scorecard so total latency stays ~ the slower query
- Federated tab shows the 5-source matrix (records + headline
  metric per engine) above the relabelled 3-source region scorecard
This commit is contained in:
mo
2026-06-28 18:51:55 +00:00
parent 28bdbaf13a
commit 437574f0bb
2 changed files with 103 additions and 4 deletions
@@ -189,6 +189,9 @@ export function TrinoFederationView({ embedded = false, activeTab }: { embedded?
const m = marquee?.marquee
const totals = catalogs?.source_totals || {}
const mxRows: any[] = m?.matrix?.rows || []
const mxMax = Math.max(1, ...mxRows.map((r) => Number(r.records) || 0))
const mxCatalogs: string[] = m?.matrix?.catalogs || ['postgres_sales', 'mysql_hr', 'mongodb_supplychain', 'cassandra_telemetry', 'iceberg']
const body = (
<>
@@ -218,7 +221,64 @@ export function TrinoFederationView({ embedded = false, activeTab }: { embedded?
</Panel>
<Panel
title="Cross-source federated query — one SQL, three databases"
title="One SQL across every database"
subtitle={m?.matrix?.elapsed_ms != null ? `${mxCatalogs.length} databases · ${(m.matrix.elapsed_ms / 1000).toFixed(1)}s` : marquee?.running ? 'computing…' : `${mxCatalogs.length} databases`}
icon={Network}
>
<p className="mb-2 text-[10px] text-foreground-muted">
A single Trino query fanned out to <span className="text-docker">five engines at once</span> relational, document, wide-column and the Hadoop lakehouse no copies, no ETL.
</p>
<div className="mb-2 flex flex-wrap items-center gap-1.5">
{mxCatalogs.map((c) => (
<span key={c} className="rounded-full bg-docker/15 px-2 py-0.5 text-[9px] font-medium text-docker">{c}</span>
))}
<button type="button" onClick={refreshMarquee} className="ml-auto inline-flex items-center gap-1 rounded border border-border px-2 py-0.5 text-[9px] text-foreground-muted hover:bg-surface-overlay">
{marquee?.running ? <Loader2 className="h-3 w-3 animate-spin" /> : <RefreshCw className="h-3 w-3" />} re-run
</button>
</div>
<pre className="mb-2 overflow-x-auto rounded-md border border-border bg-surface p-2 font-mono text-[9px] leading-relaxed text-foreground-muted">{m?.matrix?.sql}</pre>
{mxRows.length ? (
<div className="overflow-x-auto">
<table className="w-full text-[10px]">
<thead>
<tr className="border-b border-border text-left text-foreground-muted">
<th className="py-1 pr-3">Source</th>
<th className="py-1 pr-3">Catalog · dataset</th>
<th className="py-1 pr-3">Records</th>
<th className="py-1 pr-3 text-right">Headline metric</th>
</tr>
</thead>
<tbody>
{mxRows.map((r, i) => {
const isMoney = /revenue|value/i.test(r.metric_label || '')
const pct = Math.max(3, (Number(r.records) / mxMax) * 100)
const color = COLORS[i % COLORS.length]
return (
<tr key={i} className="border-b border-border/40">
<td className="py-1 pr-3 font-medium text-foreground">
<span className="inline-flex items-center gap-1.5"><span className="h-2 w-2 rounded-full" style={{ backgroundColor: color }} />{r.source}</span>
</td>
<td className="py-1 pr-3 font-mono text-foreground-muted">{r.catalog}<span className="text-foreground-faint"> · {r.dataset}</span></td>
<td className="py-1 pr-3">
<div className="flex items-center gap-2">
<div className="relative h-2.5 w-24 overflow-hidden rounded bg-surface-overlay"><div className="h-full rounded" style={{ width: `${pct}%`, backgroundColor: color }} /></div>
<span className="font-mono text-foreground">{fmtNum(r.records)}</span>
</div>
</td>
<td className="py-1 pr-3 text-right font-mono text-emerald-400">{isMoney ? fmtMoney(r.metric) : fmtNum(r.metric)} <span className="text-foreground-faint">{r.metric_label}</span></td>
</tr>
)
})}
</tbody>
</table>
</div>
) : (
<p className="py-4 text-center text-[10px] text-foreground-faint">{marquee?.running ? <><Loader2 className="mr-1 inline h-3 w-3 animate-spin" /> Federating across all databases</> : 'No result yet — click re-run.'}</p>
)}
</Panel>
<Panel
title="Region scorecard — live join across 3 OLTP sources"
subtitle={m?.elapsed_ms != null ? `${(m.elapsed_ms / 1000).toFixed(1)}s` : marquee?.running ? 'computing…' : ''}
icon={Network}
>