{"ok":true,"cached":true,"plan":{"sql":"WITH matched_unicorns AS (\n  SELECT\n    id, name, valuation_billion, valuation_text, country, city, industry, industry_domain,\n    space_segment, is_launch_provider, detail_url,\n    COALESCE(NULLIF(CAST(space_segment AS text), ''), 'Unknown') AS unicorn_group\n  FROM unicorn.company\n  WHERE (industry_domain = 'space' OR is_launch_provider IS TRUE OR space_segment <> 'none')\n),\ngroup_stats AS (\n  SELECT\n    unicorn_group,\n    CAST(COUNT(*) AS int) AS group_unicorn_count,\n    CAST(COUNT(*) FILTER (WHERE COALESCE(valuation_billion, 0) >= 10.0) AS int) AS group_over_valuation_unicorns,\n    CAST(ROUND(100.0 * COUNT(*) FILTER (WHERE COALESCE(valuation_billion, 0) >= 10.0) / NULLIF(COUNT(*), 0), 2) AS double precision) AS group_over_valuation_pct,\n    CAST(MAX(COALESCE(valuation_billion, 0)) AS double precision) AS top_valuation_billion,\n    (ARRAY_AGG(name ORDER BY COALESCE(valuation_billion, 0) DESC NULLS LAST))[1] AS top_company\n  FROM matched_unicorns\n  GROUP BY unicorn_group\n),\nsummary AS (\n  SELECT\n    CAST(COUNT(*) AS int) AS total_unicorns,\n    CAST(COUNT(DISTINCT unicorn_group) AS int) AS unicorn_group_count,\n    CAST(10.0 AS double precision) AS valuation_threshold_billion,\n    CAST(COUNT(*) FILTER (WHERE COALESCE(valuation_billion, 0) >= 10.0) AS int) AS over_valuation_unicorns,\n    CAST(ROUND(100.0 * COUNT(*) FILTER (WHERE COALESCE(valuation_billion, 0) >= 10.0) / NULLIF(COUNT(*), 0), 2) AS double precision) AS over_valuation_pct,\n    CAST(SUM(COALESCE(valuation_billion, 0)) AS double precision) AS total_valuation_billion\n  FROM matched_unicorns\n)\nSELECT\n  0 AS sort_order,\n  scope_name || ' summary' AS title,\n  scope_name,\n  group_by,\n  NULL::text AS unicorn_group,\n  total_unicorns, unicorn_group_count, valuation_threshold_billion,\n  over_valuation_unicorns, over_valuation_pct, total_valuation_billion,\n  NULL::int AS group_unicorn_count, NULL::int AS group_over_valuation_unicorns,\n  NULL::double precision AS group_over_valuation_pct,\n  NULL::text AS top_company, NULL::double precision AS top_valuation_billion\nFROM summary, (SELECT 'space unicorns' AS scope_name, 'space_segment' AS group_by) p\nUNION ALL\nSELECT\n  CAST(ROW_NUMBER() OVER (ORDER BY group_unicorn_count DESC, top_valuation_billion DESC) AS int) AS sort_order,\n  'Group - ' || unicorn_group AS title,\n  'space unicorns' AS scope_name,\n  'space_segment' AS group_by,\n  unicorn_group,\n  NULL::int, NULL::int, CAST(10.0 AS double precision),\n  NULL::int, NULL::double precision, NULL::double precision,\n  group_unicorn_count, group_over_valuation_unicorns, group_over_valuation_pct,\n  top_company, top_valuation_billion\nFROM group_stats\nORDER BY sort_order, group_unicorn_count DESC NULLS LAST\nLIMIT 8","mode":"sql","notes":[],"rationale":"pg sql path (Text-to-SQL / vector over pgvector)"},"results":[{"key":"name:space unicorns summary","url":null,"score":null,"title":"space unicorns summary","group_by":"space_segment","scope_name":"space unicorns","total_unicorns":14,"over_valuation_pct":7.14,"unicorn_group_count":4,"over_valuation_unicorns":1,"total_valuation_billion":425.109985351562,"valuation_threshold_billion":10},{"key":"name:Group - satellite","url":null,"score":null,"title":"Group - satellite","group_by":"space_segment","scope_name":"space unicorns","top_company":"K2 Space","unicorn_group":"satellite","group_unicorn_count":5,"top_valuation_billion":3,"group_over_valuation_pct":0,"valuation_threshold_billion":10,"group_over_valuation_unicorns":0},{"key":"name:Group - launch","url":null,"score":null,"title":"Group - launch","group_by":"space_segment","scope_name":"space unicorns","top_company":"SpaceX","unicorn_group":"launch","group_unicorn_count":4,"top_valuation_billion":400,"group_over_valuation_pct":25,"valuation_threshold_billion":10,"group_over_valuation_unicorns":1},{"key":"name:Group - none","url":null,"score":null,"title":"Group - none","group_by":"space_segment","scope_name":"space unicorns","top_company":"Skydio","unicorn_group":"none","group_unicorn_count":3,"top_valuation_billion":2.20000004768372,"group_over_valuation_pct":0,"valuation_threshold_billion":10,"group_over_valuation_unicorns":0},{"key":"name:Group - orbital_infrastructure","url":null,"score":null,"title":"Group - orbital_infrastructure","group_by":"space_segment","scope_name":"space unicorns","top_company":"Starcloud","unicorn_group":"orbital_infrastructure","group_unicorn_count":2,"top_valuation_billion":1.10000002384186,"group_over_valuation_pct":0,"valuation_threshold_billion":10,"group_over_valuation_unicorns":0}],"answer":null,"meta":{"q":"how many space unicorns by segment and what share are valued over $10B","mode":"query","view":"auto","page":1,"limit":10}}