Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

feat(bi): show catalog starters and source context (#113627)

Marius Andra410b4a1d5e8c
diff --git a/docs/published/handbook/engineering/data-warehouse.md b/docs/published/handbook/engineering/data-warehouse.md
index 0bf2eba933eb..0b07e2766831 100644
--- a/docs/published/handbook/engineering/data-warehouse.md
+++ b/docs/published/handbook/engineering/data-warehouse.md
@@ -336,12 +336,16 @@ Repeated dimension pills use distinct result columns so their chart and table bi
BI chart settings preserve custom scatter axes and implicit count formatting. Numeric date parts can be used as scatter axes and remain numeric in **Keep only** and drill-down filters. Scatter selection shows a highlighted count with **Keep only** and **Clear selection** buttons. Switching between chart types reuses results when only their presentation changes, including with auto-update off; pending data changes still require a run. Switching to a box plot initializes statistic mappings from matching result column names. Generated axis labels follow field renames, while custom axis labels remain unchanged.
-## Connected fields in BI mode
+## Catalog metrics in BI mode
Catalog SQL metrics can open as BI query snapshots. Their dates, grouping, and bound values come from the metric definition; shelf edits, worksheet date filters, pivots, and result drilling are unavailable. Changing the chart changes the presentation of those results. Saved snapshots do not follow later catalog edits.
After running a worksheet, **Propose as catalog metric** sends its resolved SQL and date window through catalog review. A pending or failed query cannot be proposed. Proposing an existing metric name updates its definition for review. Direct-connection worksheets cannot be proposed as catalog metrics.
+The worksheet library suggests approved, non-drifted SQL metrics and certified sources. Each list requests at most three eligible candidates; drifted metrics are omitted without scanning more pages. Source context shows certification, descriptions, and relationship review status. Relationship proposals open the catalog with the source prefilled; they become usable joins only after approval. Optional catalog suggestions do not prevent opening the worksheet library when the catalog is unavailable.
+
+## Connected fields in BI mode
+
Below Dimensions and Measures, **Connections** lists the selected table's linked tables and views.
Expand a connection to load its dimensions, measures, and nested connections. Inside connections,
fields and further links appear without section headings.
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index f06ce3b3b7fa..390952df23da 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -6723,37 +6723,37 @@ snapshots:
products-business-intelligence-scatter--read-only--light:
hash: v1.k794b7964.21cf4e3c6d31ac5d3653d176f876dbec5894d2569bd082e4fc5117a7dbe40af3.b-Dnoj2QTxOlUnZTMZuBqQGvSNk2lnMS0V6wnY_Aud0
products-business-intelligence-worksheet-exploration--daily-1500-groups--dark:
- hash: v1.k794b7964.d08598b0c007cde5ab96ffde20d7949541f156f94f9fde229e4b114c9ad97f0c.J1EDVgjR63xWObf5gipEKPfB69hUj6AQFuUs8Hw4PhA
+ hash: v1.k794b7964.7f24380331923ad18b327e3ee20624a2f67869958b7a45b4d963ea940f708c3e.2c89E8mgVRM284sG-f6EP-1-9vA9Pc-yDcT6Px4OTXc
products-business-intelligence-worksheet-exploration--daily-1500-groups--light:
- hash: v1.k794b7964.e09b60eeebdaa92a7c6b625ae5c0b17a342d88f89e7273d0bda5b0a9169a1c15.drdMw36ZHXatmOFS5ao-90666UPg9JVQCWoRDwgEoKQ
+ hash: v1.k794b7964.576e1c3d4651127152e33cb35a34dcef0969593733ee8247ec076ee629ca9fc4.hO62qLuOIngHf2JV00Vcc_NeBeN5qlnxXW2LF8WHN40
products-business-intelligence-worksheet-exploration--filters-and-hierarchy--dark:
- hash: v1.k794b7964.23d21c048f1bb0a63fdb329a6a43bd4905aa5b1e00ca96494ac61b1e4c48793d.SsD_if8LTzrr_e0qegxbvD2QKfuSDmYfY3NlQJY_wq0
+ hash: v1.k794b7964.e4cef51a703ab4a4eca19cef32de8792115a1ed20be34b2c0eda43f30ee5c86f.28n5DnUYRKTSrF16GkVWHnxBaOF_uw42BgG6KlJAHd0
products-business-intelligence-worksheet-exploration--filters-and-hierarchy--light:
- hash: v1.k794b7964.8c2bff687cbc922da82ba749edd32061fe5191582e8baac9ddd20b777f297fb2.EgsY3Ud8wKXl6CuNR2L55vxZb1xMvZuNvR42pxQvV8U
+ hash: v1.k794b7964.48882d147bfce92e1c332573e795840718ee53ce08b2dab5559dfa1a8f62d007.jkZzMxS9__f3ii-nOv6FwAEcaQDxYd1gcCsfurMunEw
products-business-intelligence-worksheet-exploration--narrow--dark:
- hash: v1.k794b7964.c2ecc6cea28c5701a2d7d72002317ce67e5f9ffe8548797e824069308c082f2b.J6G38qE1SLlWrkppkrJ7mD7maWZ6pzlBCABkjXCWSEY
+ hash: v1.k794b7964.f0f4cd878c141ef8154bf82d31674761e5b259a4454019424dc9b8b1c5b24f55.rehU9UOKSjVBkzWe4Zs9K1clF6MhTP46sBb4RDKtAzk
products-business-intelligence-worksheet-exploration--narrow--light:
- hash: v1.k794b7964.0d6f93656d101dd8d5600f11cd6643c6f5fabdfad5c006bac1ab702429dd9a66.gd-uhTHz6jIKdVgTOBhUj0WLEOXA_m-SjEU5Zu9aUHo
+ hash: v1.k794b7964.eda04f7a69ea0d74d19b756de7a65542770baf7091abfc1c1ce752e9d9078fbf.7fkXcQq-Qhnv7eQYFq6F80KzhBTz2K78QXCSRzzK1kg
products-business-intelligence-worksheet-exploration--nested-panes--dark:
- hash: v1.k794b7964.218b7fd4d24667390e1666c115f21c90e9b3957129c528bf6760e2e39c194992.gUYAGBuFquGN4LgdYwStgjDQuUYZ2qxLWY_08EI2Iuk
+ hash: v1.k794b7964.3d5186b80d5f852fc420b27f0c76ee179fc683700f1d9fcfdae17b3f66f429b6.7gDDXGuojPcMElnLu29nlUpJnvPlT66Und4-IKQfgrg
products-business-intelligence-worksheet-exploration--nested-panes--light:
- hash: v1.k794b7964.2ebc6150777a12d9c398410bfaf2820108e122e6c07407af2d126a83d2ddc439.PKf3bczXtp35m1DXPQ4so_boXl93aNUz0DooE4lzFsQ
+ hash: v1.k794b7964.410854db24b5ae2230f2444a206bb54d893f5f56863555a754dfd8e485bee852.PDfWYocNfLQZmiFL_tUbw6Kh17rRCiI05pZtufBmZ40
products-business-intelligence-worksheet-exploration--nested-panes-narrow--dark:
- hash: v1.k794b7964.ed61aa59e082662cb1914a6e72ebae13475c86808b58955fa1f69695f90bee95.Pn7HURm4BPFeBrfSNXCFA3LDLbnkcPXrh2AIRIyx100
+ hash: v1.k794b7964.eb71137de2d733a1b76a7995521dde8bb861eb156cd6d61445abe373273296c5.ccGsUy097cHiqlO4vM3-K0Asyt6q9hQsvLaxbrbujTg
products-business-intelligence-worksheet-exploration--nested-panes-narrow--light:
- hash: v1.k794b7964.c2ab12c4528d86d9932c6fd9713ef82d030e9dc0f946f903dd7396880d0e7cea.4QqDEMssL-yVsRYmtHdPGFlionrXtG4Ju9O7jT7ewgc
+ hash: v1.k794b7964.2db55da29951abd8faaa6da3a2bfb7a4d65d1db8f67e300301edc0472b471917.hOgEJCThXz2BgwgSkI6rFvZIvD3AZ6H2EYdv-e331_M
products-business-intelligence-worksheet-exploration--scatter-selection--dark:
- hash: v1.k794b7964.773c169e93e46e3dafdc884a47e048fbc2fed63f795120710ec8cea09de09ab8.DazQyK-hWdi19M-HAMBeSk3ChlLEKI0PjQjKVt9qMk8
+ hash: v1.k794b7964.be207bfcc39b5dddbb3811dc16ddb727d43cad39214aa1bdf8e217ba41d63445.v-bpXyyP4M4IskpBb__5i2eO9UNmtoQDBa5VVSOOOls
products-business-intelligence-worksheet-exploration--scatter-selection--light:
- hash: v1.k794b7964.04c507a97cd1974daa89666b36095e130261a28bad09caa9eef143bcc709028a.tKuO2pdvEX1RAxk59DMG9ah_C4sFSFNhm80BYlokjso
+ hash: v1.k794b7964.a20fd109efc67c7f865613411da730fadc92c2e8806e7536aed0b00aa70444d0.-HpnjY1-TxJ8s86G0Z4ultflLyTlM4BCPsq9WnScckY
products-business-intelligence-worksheet-exploration--sql-preview--dark:
- hash: v1.k794b7964.0c799dde5f45d0132adea9cd565d4ef7d074b78255da1138a1b9c76b5030373c.1fmdtlQ1z0XQlGBswx8rJNK2wmfkwWYd-WdqLJaAMyg
+ hash: v1.k794b7964.54f8eb4ac329765a5e1fec07e5adeefcba0c7f33dd52018d809c9d391d37769d.r9f6H30d5bj6XpQ1aKJvzoRxOnhylVg3vM7RTmx0U9U
products-business-intelligence-worksheet-exploration--sql-preview--light:
- hash: v1.k794b7964.65bca19aec73213bc3606b3703ac40d96e5b19a4c917b71b42081b6a59b113f2.1WFaE2x0Bhl2SnlkCWQgHOYAf07GR4IisxPxFuF4jEY
+ hash: v1.k794b7964.b8569ec9b2979da3d802f171fcd04928aea1aa553a4dd1839a6542faa543b131.AoZIJ5cizWWPtwLgAoQ-QNJxEgwFa59truknG0aIrCM
products-business-intelligence-worksheets--worksheets--dark:
- hash: v1.k794b7964.3998501a45652d1982a4ae8217c905e0482c6979a4f54642cbc8739d991730ef.x5TzvSg7zyGoyTdnBYKHG__tv6ytXrmifpxCAgkyItg
+ hash: v1.k794b7964.415c9082cf92256a775c1f21b314625a10282c76e91ed9373560c7e983aafde4.syfMPTOr1J9lrSDz6M0HWZn25hDTtND6yg9pQ9tP6Ww
products-business-intelligence-worksheets--worksheets--light:
- hash: v1.k794b7964.4555ec007faf662eec95759dfa8eb37393e76e45a88cda912ba99ce6c8b219d6.dvKnhFxE9Rs1ruwCF0EWXB0x2rromI5oC_n3pjq2Grc
+ hash: v1.k794b7964.6ff56d29db46966fd344a3779d4656ce2812ef8bd71ffb53572461ebb919dea3.EErtoA0a22PSvSEuEfN_2Q-Nlb2bwx6Lt3ovNC9NTSw
products-dashboards--dashboard-states--dark:
hash: v1.k794b7964.cc591635f83447f7bcfb802062302b8b1bbcd51826110b12fa0f68d4830dcfd3.CIgt_KxCyQRgbn7DPF4MDXc5JBlSxbaCPS0Snyx3cRs
products-dashboards--dashboard-states--light:
@@ -10074,74 +10074,82 @@ snapshots:
hash: v1.k794b7964.87b9871ba40527e15aff583d855822e3d4bd58d0dfbba0c5ebab4f6fc6f28d59.G36fGeQ5awgRh8N2pp3qgS7p3J5-56CokKJitervSQk
scenes-app-data-warehouse-sql-editor--bi-calculated-measure-editor--light:
hash: v1.k794b7964.69c71d482b1b19aa18a81b5ba0fc0bb038d8f3bdc9bdb0a7286c9addb4893dc2.LjgKhmcTELX-Cd50ZnnKmKLTGxv3AH0cD5BfLrBKfQ8
+ scenes-app-data-warehouse-sql-editor--bi-catalog-snapshot--dark:
+ hash: v1.k794b7964.b52b1342405552a434e059a2c6356149b7eec93c55c0add78e4a4ed498a63351.ZlHoXE5McNiADRhSnXPG4ce1qZdMJK65I4b0fgMdjEk
+ scenes-app-data-warehouse-sql-editor--bi-catalog-snapshot--light:
+ hash: v1.k794b7964.ccee947706656e7bc3bc4f1c83610196346351067b2e406e222f6021180a92b7.WJlU-aUOOEEMQN9SppIHk6yIPbTrU9VrCOSME-hQAjQ
+ scenes-app-data-warehouse-sql-editor--bi-catalog-source--dark:
+ hash: v1.k794b7964.5063a2ffa4974d3db91d89739d182fb32966b40e54c81642a2f54ed931f82b16.iLFa19kF_o7DrHL0e-0ZDg1DSF-hOzif8fyS1Tz2wsw
+ scenes-app-data-warehouse-sql-editor--bi-catalog-source--light:
+ hash: v1.k794b7964.967903a38d5ca0e462e2e7dddc8b623b784f32dd23deb6671aa36a615a36ef7f.hrwenBfFV6gOpx1tsOHns2-bYWsliVKNxeP-qQLW834
scenes-app-data-warehouse-sql-editor--bi-category-groups--dark:
- hash: v1.k794b7964.5486cfd4fbec00ef6dfce4af0c0b6227fccb585e51428af1152c2b301a116f8e.pb_byOmoFqC1G6b5HCLTGbohiMMLZYjIq_CG4CNDGBI
+ hash: v1.k794b7964.4a5b83cb6f2840d3762ad2b56c62dd3c90e376b9cad2850d2d4bce4311299662.jd5yI6fdhWyNgJcNig5J25sW5sSNh6KS--1v_Zcvbug
scenes-app-data-warehouse-sql-editor--bi-category-groups--light:
- hash: v1.k794b7964.77089560df14ae7eea62b6e946584cbde100897607a5024da7afb7b610eb9178.lPvbJOhNK9XWXXIj10hftrcenyJr0zwRVWf7FtQlb2Y
+ hash: v1.k794b7964.483842bb281a2de62d1b4304c4a9b0fd72ff425086a069afe495936c306e6e60.LuqAnRPfSM59dzSBSDePslc6e8lCPuYROxHfy7X-uOI
scenes-app-data-warehouse-sql-editor--bi-combined-measures--dark:
- hash: v1.k794b7964.039dfc5ac1a3224b1358554580f5345b074438a646e3b5605bf8e7ad8c9e7948.AjLIYjRJTdHfTNb3UhE0g4-5IBkbo23rsnbptb7S8-0
+ hash: v1.k794b7964.8a5f24e2f15aefdbad4ffca39f469dabb1c1ca8668a54a0f6084c9c3784fad3d.sU8D8dQj_UBrcuwB9gERI_H7lFJvk0TEQKrwSMtQ76s
scenes-app-data-warehouse-sql-editor--bi-combined-measures--light:
- hash: v1.k794b7964.582748cd75a7ea4d5422219d44a7565803c569d2b4e271672057a313b416d012.nDtqgPf06i4bncbB6Uvdp8w0LzJs2_jVJu5qR3c6g5M
+ hash: v1.k794b7964.1a7df2fe6d1f727a5a39283e4e7fa0b84de71af16d17ad5506995e85a88df0f3.5TMob9wkvylU2InzLQ2nwle2z2cIVpf_CSJw8jEkCzE
scenes-app-data-warehouse-sql-editor--bi-connections--dark:
- hash: v1.k794b7964.40b945046a6e236c5c01c078e82631437277569944eb821fccae1edf9474ed26.kwLpD-OQo0u_WfYl7SiDuIMh-6wfQXA-BaZau9oGtX4
+ hash: v1.k794b7964.20e455e016c0d14b6fa6194e97bfa1efb5a78c4c1d113ed6012dbaf0b9b5b295.Khingq35QCQzbZmdi_X_LfoHXaKGYYhgTUmOnAMiMMw
scenes-app-data-warehouse-sql-editor--bi-connections--light:
- hash: v1.k794b7964.3e2ea89c46eb704cf469456601f1775d8da1a49c4ead8faf671f254d33791772.psHiqZUEdESJbBR01RXbczrWCVQttnCagOGiGWIgiME
+ hash: v1.k794b7964.8d73e999e9a058168f643dc3a86cfb1b966b91b7764b1b79adc18a025d8dcf33.RCVSaONQAq_CExJ6ZXYVHF4GnU8U1h-U41BbmfvhJes
scenes-app-data-warehouse-sql-editor--bi-data-source-picker--dark:
- hash: v1.k794b7964.f400b545df5a6c219abd5cdb85e7c419ba9a31352088d2790e8e259e45ada6c6.wRMD5oyHdIuAcce53FVT7EkWSP0boyafPHIhZen5A9A
+ hash: v1.k794b7964.e52e0e6b5bbafcc49b7a403283ea2582623830f201f0f2cebde96694df76a434.cJCCG5oSz14yhFdrPG9GFg-3o3SeAPcCDiY7r0B2MVE
scenes-app-data-warehouse-sql-editor--bi-data-source-picker--light:
- hash: v1.k794b7964.1fb81956b9085ac122bf31468978b467d1d1b0de28c1cd4cf6e7813453b68eef.9CXg4SN3f79zu6CyrAgjQtGHk-f0nmB-wdc1fdvPprA
+ hash: v1.k794b7964.2b52437065c62287b16468e8bcbaddad744423b5293288ab3094f78faf618dfb.7aEiYNMWShTp9l6KWxD-1GouTk_dqFp_dtsIu3F4514
scenes-app-data-warehouse-sql-editor--bi-drilldown--dark:
- hash: v1.k794b7964.68ae5a2217951bbe57ab020a5c2f480c527652f64cd0e7c1569d2f6c3c89e5a2.G7_jPjpNVTuk4_6CVl67UZo6EekgmkQXTrlzz5FYo0Y
+ hash: v1.k794b7964.64bb56a49fb27c4b5565420e8ef786e09aaa68e631c20b00dd44b157c8360615.iNgzWOSQA-YNWVTuFVBrflHl_kJJXfHTAAvOBQ4rVEg
scenes-app-data-warehouse-sql-editor--bi-drilldown--light:
- hash: v1.k794b7964.51e20f9ed3a5f71042d79308c84e8e8f69e16e9fb08fa0ffffd9d07962d7f7c3.-vKccSWyHN6kWTyUG2uog8aNS0DRBIm8oOxOpcxX-7E
+ hash: v1.k794b7964.17425e90961381749cfc5f29a6648045fc2823bb8e239393b9801d2194e8b887.sqGRqMiXBdZxzpm-duX1-vj4SrOlKfwFtNl5Qh5o6VA
scenes-app-data-warehouse-sql-editor--bi-edit-saved-insight--dark:
- hash: v1.k794b7964.2117538c4b7e9e266f7b456acedc8c64216a93297a1b82467b0c203f6e1aafb3.8kUP50nopTeHMRQqWxTln7SHcYDvw8cr5iyuR-NOHcc
+ hash: v1.k794b7964.bb961b255cd6561500d69559373f91070bc3b64b58a2a38474beda3b16d3021a.8U8Odg-DQuf2OOzhEcmxbdf4ieZSEIZ0gtcrm4-DwtQ
scenes-app-data-warehouse-sql-editor--bi-edit-saved-insight--light:
- hash: v1.k794b7964.158e1f21f396bd7871a8f891dba3e4089ead9b7f74b7a37569a3d2adf5545fe3.PjAX5DqE6hNBtEBT56hhR82awngZoE8c0bB2M4LQKI8
+ hash: v1.k794b7964.08c698105dcedbbc6507c842976e386fda5fc5382eecda9f3acfe93b0960d5b5.8Z0KplEwTXGa0J2CUv6qQ1jldVddlpPQn1grxjanWxI
scenes-app-data-warehouse-sql-editor--bi-empty-worksheet--dark:
hash: v1.k794b7964.9cdaf1b941fa6fac0d8839b4165ddd0506ce1c1ac263ae447087461a77e85a93.gXKbXKNUGG_zCLxpBvyfnmrOVGKBJj4sYQLELwogzNE
scenes-app-data-warehouse-sql-editor--bi-empty-worksheet--light:
hash: v1.k794b7964.99ecf94f32c88b943651332b786c3ab33d4497730016ec325f279c53683bfd59.UE1Sw435eYovzC5VHT6kQceuUqT8J1rNMicQQlbSOL0
scenes-app-data-warehouse-sql-editor--bi-measure-display--dark:
- hash: v1.k794b7964.51f59642bed45cd9dfbe798bbd3536eaa54b55924fae7a5256c77d3b273605fa.ltiQQviBGOzy-QRdFr2uOImGmmE9Vb1G8i2rrWeGEnQ
+ hash: v1.k794b7964.285d3b0652df44f0abbc37490be06be0d37295e3c2cd90dec3b9ba686e94e226.E68htKmQ7-55dVI3ntl1GiZ7F4phBSgI-dESHmfSa5o
scenes-app-data-warehouse-sql-editor--bi-measure-display--light:
- hash: v1.k794b7964.ff215a24b23e97f27faa7af7a77191cc2211fffebfdc98da6d03706cb5617c3b.IGxOinR-UZLLXlTwHaS6a5pP1LHIjPe80P5KSHsrUmU
+ hash: v1.k794b7964.94be47a8f6297556e3a52ff0406ef376ac747c8a238f26fb0732bedc3458bb0d.LDGJR8HnWyzYwSaLd6mmvIOvVsvoXI4v5UKGajUp6uM
scenes-app-data-warehouse-sql-editor--bi-mode-worksheet--dark:
hash: v1.k794b7964.6309ca3f3ecb88032969e856079e14cda460aa306a5172863693ff8a95ea011c.dIXWRHfmipDgezW97RK0MYne72aosXhe0o1S_uXrt_w
scenes-app-data-warehouse-sql-editor--bi-mode-worksheet--light:
hash: v1.k794b7964.d60ca4f154f5b6aa7dfe97f5907d32aeb07d408ef2ccfdd9b86bd8880c17ba6b.m2J3D-2Zw-ub5S6SSZk2MFZf3rAXWA6146N6UMKx2Xo
scenes-app-data-warehouse-sql-editor--bi-named-hierarchy--dark:
- hash: v1.k794b7964.180f3b83cbbf5f1b708ea46d095685e5570df1846efe5d450c7b2434edda5ae1.De74xaLyCoJRi295g5ChO00yqaKxf0j2HVNagioDRs4
+ hash: v1.k794b7964.63bc34e411b972a3014ab15f34997009bcb8221674630e8c893c683dca030794.vIOC126Xccqj1qHXT4AfSFN_Jj5nqzzdGUYSskXEJy8
scenes-app-data-warehouse-sql-editor--bi-named-hierarchy--light:
- hash: v1.k794b7964.9874234c76d2c58ad97cdf71da93b03f6fedb482c0978185e6ad1602aeb42249.nzTwYRAxxTDrANQu-17ktAwKi1IAx8R8YEWiDAU1usY
+ hash: v1.k794b7964.4782c05aa2882568d321dc2e4279ff4fbc941c89981568f99ccf9520aa367661.Qu14j4A7Z_Ipey958BcWksERq3KXSnLSWVquwQsDplU
scenes-app-data-warehouse-sql-editor--bi-numeric-bins--dark:
- hash: v1.k794b7964.43fb0813c76a3150bc7d9822039c21ac4ea7afe64942aede00adff5fbf7aaca8.MWXIoEhyFjUR6VgfQq2c1CqX_vpWMh3Nlp-HmraJuyU
+ hash: v1.k794b7964.a1e58d329dd081d4ddad9ab42809a292557b16f4332b7c5dc033514197f6e456.si6X7Eq2qEYOYNpbh-WyrfhztA5m6Yv9xxRG8x802G0
scenes-app-data-warehouse-sql-editor--bi-numeric-bins--light:
- hash: v1.k794b7964.098fa2b52e946c8a8a00e7d6e57ae8e09106be1096b84c40df246fe2591e4ab9.BjUZmUH58fdYZ02zTNpjrWu5Egzs6qO7iKiIUihZerk
+ hash: v1.k794b7964.f481b2dbffeb539a58d734b53d101fb6faaf3c030c36aa8004718a5a96862dc3.TvLxQm-fA52VnkzkBIdfykJlTeBwQ-bZrsIzLc4q7zY
scenes-app-data-warehouse-sql-editor--bi-one-click-comparison--dark:
- hash: v1.k794b7964.c6b39669db3163a1446f19e827a1a19ecaba0147d6315d0c86acb7f34f120e20.mxLctVjcrANyDO_D-QE5mtOAIzwOx8ZYIQvvV_TP0hs
+ hash: v1.k794b7964.ca3574d560dceeca22b572252d2bf6a628e809ce56e3369792daefcf5bd12217.mS7XTjrH0HiARysg99L3O1OkWb94O1iQ0rqCkWeei1o
scenes-app-data-warehouse-sql-editor--bi-one-click-comparison--light:
- hash: v1.k794b7964.f23d78e056b8ffbeb9864d12ed14986bded77107199d4ac8cec76f6dacd58155.qwvkjVG4ahNNXSzbgLJ3APNdN6sE92-5XlwCH75MzV0
+ hash: v1.k794b7964.3af5fdf03f573407de0d9bf6a459d4f89c1f2cecbc5e6e296dee33dc46ffe8fb.1XR_hWBwWFx8-cgqg9j_QaXpzMB5x8lZgLS9JkeXoxQ
scenes-app-data-warehouse-sql-editor--bi-pivot-totals--dark:
- hash: v1.k794b7964.ab316d5b27ed8e3babbeffeaf9c121ed27e17e448054ef9b92454557d3b5072f.7lAjMFoi5uIUAZDKLOmmfXWrP7kFYqOarTO-3SvtXKo
+ hash: v1.k794b7964.c1c999f52a8f6aaa2b937f09ed1218420fbf22717b256b5746f83a857ffdb456.GV5s-1z80XNrg1kiEK3rkWlwPw3al5QxyViFErjW8_Q
scenes-app-data-warehouse-sql-editor--bi-pivot-totals--light:
- hash: v1.k794b7964.eb1aea6031e30bcfe43e27164ff819824d11629618fd663fa5bdde8cc9017633.jfPZq39IiqS7_BWpn_l-jnBTj9YRv3CxcGk9T8fwC9M
+ hash: v1.k794b7964.c1a5a9e6925a99c5442d5b9c5cac146826104df0be56951853ff8ca656a5711c.1X2Gb4NVgF3zF9fOYmP8XI04X1UdEZpyA6QU_cCJt44
scenes-app-data-warehouse-sql-editor--bi-quick-filters--dark:
- hash: v1.k794b7964.7f1945f31b95452ed99b30ebb2b2eef7c0caacb36abc054a265ee53449e37f9e.ykm55yd9KG8eAFIxVM93v_K1Diq06RroOnQbnJxfCJQ
+ hash: v1.k794b7964.cb93198bfbc39e7551bbb2afb089b262a4feb09783428423313164199953c2ea.yZVTW4sCJxN3og54hyxVpSi5MDPIsU-iXoV4WjhBFqA
scenes-app-data-warehouse-sql-editor--bi-quick-filters--light:
- hash: v1.k794b7964.270586f7fef306862223ea244ef58ba8e4254c870875a713b2fdcea14b2c5e14.IOxSQL1mcIhfKphM1slmtrJd1fpco_nXUCB1jhG1AKo
+ hash: v1.k794b7964.c869c53035ab8999de17064f328e55a98e2d630e0798523b7546c7e37d566a51.7JCWR9o8WI_n5E5GPe3VyiQy-h2lLPh5olskN0aEJX8
scenes-app-data-warehouse-sql-editor--bi-quick-filters-narrow--dark:
- hash: v1.k794b7964.61c1871d782552c623ed4b53b8cbbf5a74109c58c17a1efec32bf90499d1355f.0ewioRgpY540Ex6B6vk7wbB5mnXcCBoVhdnxIOTZq5o
+ hash: v1.k794b7964.f1a652e4ed52ade1bea7690f5bee354a819e7b95a7265baa9c616caf13e61f90.DsjWYPHS114oT41R9WcLbQdX5eCxJdqUCH6D6x6fFA4
scenes-app-data-warehouse-sql-editor--bi-quick-filters-narrow--light:
- hash: v1.k794b7964.7988ded7ac073159043f62d9e123c093b1eda90e77bd59209931ca97e10711d7.3jjgY4ose6bTwS4iaT56UJVc9idxnub6wKoIHR9z9MA
+ hash: v1.k794b7964.f8d5ab63e05e8f9199c85faf8eab900180c9ef443b812bfbdb3b9642ee6dc066.kt-8oDI3zW6KzCgxv3u6ECjvwnfcrhrFRnRi_rWE5d4
scenes-app-data-warehouse-sql-editor--bi-saved-insight--dark:
hash: v1.k794b7964.06df092616d217a4ebdaf0f5f35015c05fe63f5bc1e9b9c39dcdf6594293c0e3.D8zEjaefT5868HRYC8F6GkfsuMMlcxSxekM5z-VoXyM
scenes-app-data-warehouse-sql-editor--bi-saved-insight--light:
hash: v1.k794b7964.2c5f15b06d4347f767fc34bf934ea1bd53e988c443d528edb457795e778cc556.FcMHWv530RuOEcqg3G_bnos4zzZ4mku3Q9pdsK-VCXU
scenes-app-data-warehouse-sql-editor--bi-table-analysis--dark:
- hash: v1.k794b7964.1a6e828bdefabdc1df2bb5ea01d9a17247ae488bb1ca995505e28e70c2ccc2fd.7etXY6I03eGvxnZk0GMG_T4sSJDXbyj1DnIMhGltQJk
+ hash: v1.k794b7964.a2f0aeb7739ef1d91f0d5ffdf47ba9013cb25a2853092180265a132347fd59f2.BcvLZ0iTpnnGxgl9j-ZEw9Mm6BZsB7fd6UsmEDx0tls
scenes-app-data-warehouse-sql-editor--bi-table-analysis--light:
- hash: v1.k794b7964.d1ec619da02c29bb935289a2b37e564d9bcd7ac12404dc5b3205514981d0cf7b.kFAFIi0y3cmT-hGNH_aQWdzrDPnHl1GglzBNbu1I6r4
+ hash: v1.k794b7964.6738d6bf86ffbca51e925b3230ac4b66c0808260fed0d0750804b33734dfd889.MKkIrRDTnof49tYgECLwbv_WqugRJB11sJjPBkf8-YA
scenes-app-data-warehouse-sql-editor--edited-insight--dark:
hash: v1.k794b7964.334b216a8359c768613cdec5b99a8a8ee26b6b5fac76397eaed8d6d1401a23c0.0pI7NMTufzUIfDel9Ngmhv3P3sdBu6IgpSj5xYNmYrY
scenes-app-data-warehouse-sql-editor--edited-insight--light:
diff --git a/frontend/src/scenes/data-warehouse/editor/SQLEditorScene.stories.tsx b/frontend/src/scenes/data-warehouse/editor/SQLEditorScene.stories.tsx
index 4927bc8ee6d2..8362739ecf33 100644
--- a/frontend/src/scenes/data-warehouse/editor/SQLEditorScene.stories.tsx
+++ b/frontend/src/scenes/data-warehouse/editor/SQLEditorScene.stories.tsx
@@ -23,7 +23,11 @@ import {
import type { DataWarehouseSavedQuery, InsightShortId } from '~/types'
import { AccessControlLevel, AccessControlResourceType, ChartDisplayType } from '~/types'
-import { buildBIQuery, getBIResultDimensions } from 'products/business_intelligence/frontend/biEditorTypes'
+import {
+ buildBIQuery,
+ getBIResultDimensions,
+ getBIResultMeasureColumns,
+} from 'products/business_intelligence/frontend/biEditorTypes'
import { biSceneLogic } from 'products/business_intelligence/frontend/biSceneLogic'
import { expect, userEvent } from 'storybook/test'
@@ -1566,3 +1570,100 @@ export const BINumericBins: Story = {
await userEvent.click(await body.findByText('Create numeric bins', { exact: true }))
},
}
+export const BICatalogSource: Story = {
+ ...BIModeWorksheet,
+ parameters: {
+ ...BIModeWorksheet.parameters,
+ msw: {
+ mocks: {
+ get: {
+ '/api/projects/:team_id/warehouse_expressions/': { results: [] },
+ '/api/projects/:team_id/data_catalog/relationship_proposals/': {
+ count: 1,
+ next: null,
+ results: [
+ {
+ id: 'proposal-example',
+ source_table_name: 'events',
+ source_table_key: 'account_id',
+ joining_table_name: 'accounts',
+ joining_table_key: 'id',
+ field_name: 'account',
+ status: 'proposed',
+ reasoning: 'Connect each event to its account.',
+ },
+ ],
+ },
+ },
+ post: {
+ '/api/environments/:team_id/query/HogQLQuery/': {
+ columns: [
+ ...getBIResultDimensions(BI_WORKSHEET_CONFIG).map(({ column }) => column),
+ ...getBIResultMeasureColumns(BI_WORKSHEET_CONFIG).map(({ column }) => column),
+ ],
+ types: ['DateTime', 'String', 'Float64'],
+ results: [
+ ['2026-06-01', 'purchase', 120],
+ ['2026-06-02', 'purchase', 180],
+ ['2026-06-03', 'purchase', 150],
+ ],
+ hasMore: false,
+ },
+ '/api/environments/:team_id/query/DatabaseSchemaQuery/': {
+ tables: {
+ events: {
+ id: 'events',
+ name: 'events',
+ type: 'posthog',
+ fields: BI_EVENTS_FIELDS,
+ certification: {
+ status: 'certified',
+ notes: 'Use this source for product activity worksheets.',
+ },
+ },
+ },
+ joins: [],
+ },
+ },
+ },
+ },
+ },
+}
+
+export const BICatalogSnapshot: Story = {
+ ...BIModeWorksheet,
+ parameters: {
+ ...BIModeWorksheet.parameters,
+ pageUrl: `${urls.businessIntelligenceNew()}?metric=weekly_revenue`,
+ testOptions: { waitForSelector: '[data-attr="bi-catalog-snapshot"]' },
+ msw: {
+ mocks: {
+ get: {
+ '/api/projects/:team_id/data_catalog/metrics/weekly_revenue/': {
+ name: 'weekly_revenue',
+ display_name: 'Weekly revenue',
+ definition: {
+ kind: NodeKind.HogQLQuery,
+ query: "SELECT sum(revenue) AS revenue FROM events WHERE timestamp >= toDateTime('2026-06-01') AND timestamp < toDateTime('2026-06-08')",
+ },
+ },
+ '/api/projects/:team_id/warehouse_expressions/': { results: [] },
+ },
+ post: {
+ '/api/environments/:team_id/query/HogQLQuery/': {
+ columns: ['revenue'],
+ types: ['Float64'],
+ results: [[450]],
+ hasMore: false,
+ },
+ },
+ },
+ },
+ },
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement)
+ await canvas.findByRole('link', { name: 'View catalog definition' }, { timeout: 15000 })
+ await userEvent.click(await canvas.findByRole('button', { name: /^Run$/ }))
+ await expect(canvas.findByText('450', { exact: true })).resolves.toBeVisible()
+ },
+}
diff --git a/products/business_intelligence/frontend/BISourceContext.tsx b/products/business_intelligence/frontend/BISourceContext.tsx
new file mode 100644
index 000000000000..10448fa29174
--- /dev/null
+++ b/products/business_intelligence/frontend/BISourceContext.tsx
@@ -0,0 +1,91 @@
+import { useActions, useValues } from 'kea'
+
+import { LemonButton, LemonTag, Link } from '@posthog/lemon-ui'
+
+import { urls } from 'scenes/urls'
+
+import { DatabaseSchemaTable } from '~/queries/schema/schema-general'
+
+import { TableCertificationTag } from 'products/data_warehouse/frontend/shared/components/TableCertificationBadge'
+
+import { captureBIWorksheetAction } from './biEditorAnalytics'
+import { biEditorLogic } from './biEditorLogic'
+import { biSourceContextLogic } from './biSourceContextLogic'
+
+export function BISourceContext({ table }: { table: DatabaseSchemaTable }): JSX.Element {
+ const { config } = useValues(biEditorLogic)
+ const { description, relationships, relationshipsLoading, joins, contextError } = useValues(
+ biSourceContextLogic({ table })
+ )
+ const { loadRelationships } = useActions(biSourceContextLogic({ table }))
+ const catalog = `${urls.dataCatalog('relationships')}&table=${encodeURIComponent(table.name)}`
+ return (
+ <div className="flex min-w-0 flex-col gap-1 text-xs" data-attr="bi-source-context">
+ <div>
+ <TableCertificationTag certification={table.certification} />
+ </div>
+ {description && <p className="m-0 break-words text-secondary">{description}</p>}
+ {table.certification?.notes && <p className="m-0 break-words">{table.certification.notes}</p>}
+ <Link
+ to={`${urls.dataCatalog('certifications')}&table=${encodeURIComponent(table.name)}`}
+ onClick={() => captureBIWorksheetAction('catalog_source_opened', config)}
+ >
+ View catalog details
+ </Link>
+ <details>
+ <summary className="cursor-pointer">Relationships and review status</summary>
+ <div className="flex flex-col gap-2 py-2">
+ {joins.map((join) => (
+ <div key={join.id} className="break-words">
+ {join.source_table_name}.{join.source_table_key} → {join.joining_table_name}.
+ {join.joining_table_key}
+ <div className="text-secondary">Access with {join.field_name}</div>
+ <LemonTag type="success">Configured</LemonTag>
+ </div>
+ ))}
+ {relationships?.results.map((proposal) => (
+ <div key={proposal.id} className="break-words">
+ {proposal.source_table_name}.{proposal.source_table_key} → {proposal.joining_table_name}.
+ {proposal.joining_table_key}
+ <div>
+ <LemonTag
+ type={
+ proposal.status === 'accepted'
+ ? 'success'
+ : proposal.status === 'rejected'
+ ? 'danger'
+ : 'warning'
+ }
+ >
+ {proposal.status === 'proposed'
+ ? 'Awaiting review'
+ : proposal.status === 'accepted'
+ ? 'Accepted'
+ : 'Rejected'}
+ </LemonTag>
+ </div>
+ {proposal.reasoning && <div className="text-secondary">{proposal.reasoning}</div>}
+ </div>
+ ))}
+ {!relationshipsLoading && !contextError && !joins.length && !relationships?.results.length && (
+ <span>No configured or proposed relationships.</span>
+ )}
+ {contextError && <span>Could not load relationship reviews.</span>}
+ {(contextError || relationships?.hasMore) && (
+ <LemonButton size="xsmall" loading={relationshipsLoading} onClick={() => loadRelationships()}>
+ {contextError ? 'Retry' : 'Load more'}
+ </LemonButton>
+ )}
+ <Link to={catalog}>Review in catalog</Link>
+ </div>
+ </details>
+ <LemonButton
+ size="xsmall"
+ to={`${catalog}&propose_table=${encodeURIComponent(table.name)}`}
+ onClick={() => captureBIWorksheetAction('catalog_relationship_requested', config)}
+ >
+ Propose a relationship
+ </LemonButton>
+ </div>
+ )
+}
diff --git a/products/business_intelligence/frontend/BIStarters.tsx b/products/business_intelligence/frontend/BIStarters.tsx
index 06f5950835ba..92fe974a6557 100644
--- a/products/business_intelligence/frontend/BIStarters.tsx
+++ b/products/business_intelligence/frontend/BIStarters.tsx
@@ -1,4 +1,6 @@
-import { LemonButton } from '@posthog/lemon-ui'
+import { useValues } from 'kea'
+
+import { LemonButton, LemonTag } from '@posthog/lemon-ui'
import { urls } from 'scenes/urls'
@@ -8,6 +10,7 @@ import { ChartDisplayType } from '~/types'
import { captureBIWorksheetAction } from './biEditorAnalytics'
import { buildBIQuery, DEFAULT_BI_CONFIG } from './biEditorTypes'
+import { biStartersLogic } from './biStartersLogic'
export function starterWorksheetUrl(config: BIConfig): string {
const built = buildBIQuery(config)!
@@ -33,10 +36,52 @@ const EVENTS_CONFIG: BIConfig = {
}
export function BIStarters(): JSX.Element {
+ const { metrics, sources } = useValues(biStartersLogic)
return (
<section className="flex flex-col gap-2" aria-label="Worksheet starting points">
<h3 className="m-0">Start with a question</h3>
<div className="flex flex-wrap gap-2">
+ {metrics.map((metric) => (
+ <LemonButton
+ key={metric.id}
+ type="secondary"
+ size="small"
+ className="max-w-full"
+ to={`${urls.businessIntelligenceNew()}?metric=${encodeURIComponent(metric.name)}`}
+ tooltip={`${metric.description} · Fixed query snapshot; dates and dimensions are not editable.`}
+ onClick={() =>
+ captureBIWorksheetAction('starter_selected', DEFAULT_BI_CONFIG, { starter_kind: 'metric' })
+ }
+ >
+ <span className="flex items-center gap-1 min-w-0">
+ <span className="truncate">Explore {metric.display_name || metric.name}</span>
+ <LemonTag type="success">Approved metric</LemonTag>
+ </span>
+ </LemonButton>
+ ))}
+ {sources.map((source) => {
+ const config = { ...DEFAULT_BI_CONFIG, source: { table: source.target_name } }
+ return (
+ <LemonButton
+ key={source.id}
+ type="secondary"
+ size="small"
+ className="max-w-full"
+ to={starterWorksheetUrl(config)}
+ tooltip={source.notes}
+ onClick={() =>
+ captureBIWorksheetAction('starter_selected', config, {
+ starter_kind: 'certified_source',
+ })
+ }
+ >
+ <span className="flex items-center gap-1 min-w-0">
+ <span className="truncate">Explore {source.target_name}</span>
+ <LemonTag type="success">Certified</LemonTag>
+ </span>
+ </LemonButton>
+ )
+ })}
<LemonButton
type="secondary"
size="small"
diff --git a/products/business_intelligence/frontend/BIWorksheetsScene.stories.tsx b/products/business_intelligence/frontend/BIWorksheetsScene.stories.tsx
index 04f35bbfae0c..c2f01b6128ed 100644
--- a/products/business_intelligence/frontend/BIWorksheetsScene.stories.tsx
+++ b/products/business_intelligence/frontend/BIWorksheetsScene.stories.tsx
@@ -17,6 +17,29 @@ const meta: Meta = {
msw: {
mocks: {
get: {
+ '/api/projects/:team_id/data_catalog/metrics/': {
+ results: [
+ {
+ id: 'metric-example',
+ name: 'weekly_revenue',
+ display_name: 'Weekly revenue',
+ description: 'Revenue from completed purchases.',
+ definition_kind: 'HogQLQuery',
+ status: 'approved',
+ is_drifted: false,
+ },
+ ],
+ },
+ '/api/projects/:team_id/data_catalog/certifications/': {
+ results: [
+ {
+ id: 'certification-example',
+ target_name: 'events',
+ status: 'certified',
+ notes: 'Product activity',
+ },
+ ],
+ },
'/api/projects/:team_id/insights/': {
count: 2,
results: [
diff --git a/products/business_intelligence/frontend/biSourceContextLogic.ts b/products/business_intelligence/frontend/biSourceContextLogic.ts
new file mode 100644
index 000000000000..d650b27f572c
--- /dev/null
+++ b/products/business_intelligence/frontend/biSourceContextLogic.ts
@@ -0,0 +1,152 @@
+import { MakeLogicType, afterMount, connect, kea, key, path, props, reducers, selectors } from 'kea'
+import { loaders } from 'kea-loaders'
+
+import { databaseTableListLogic } from 'scenes/data-management/database/databaseTableListLogic'
+import { teamLogic } from 'scenes/teamLogic'
+
+import { DatabaseSchemaQueryResponse, DatabaseSchemaTable } from '~/queries/schema/schema-general'
+import { DataWarehouseViewLink } from '~/types'
+
+import { dataCatalogRelationshipProposalsList } from 'products/data_catalog/frontend/generated/api'
+import { DataCatalogRelationshipProposalApi } from 'products/data_catalog/frontend/generated/api.schemas'
+import {
+ warehouseColumnAnnotationsList,
+ warehouseSavedQueriesRetrieve,
+} from 'products/data_warehouse/frontend/generated/api'
+
+export interface BISourceContextProps {
+ table: DatabaseSchemaTable
+}
+
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface biSourceContextLogicValues {
+ database: Required<DatabaseSchemaQueryResponse> | null // databaseTableListLogic
+ contextError: boolean
+ description: string
+ descriptionLoading: boolean
+ joins: DataWarehouseViewLink[]
+ relationships: {
+ hasMore: boolean
+ results: DataCatalogRelationshipProposalApi[]
+ } | null
+ relationshipsLoading: boolean
+}
+
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface biSourceContextLogicActions {
+ loadDescription: () => any
+ loadDescriptionFailure: (
+ error: string,
+ errorObject?: any
+ ) => {
+ error: string
+ errorObject?: any
+ }
+ loadDescriptionSuccess: (
+ description: string,
+ payload?: any
+ ) => {
+ description: string
+ payload?: any
+ }
+ loadRelationships: () => any
+ loadRelationshipsFailure: (
+ error: string,
+ errorObject?: any
+ ) => {
+ error: string
+ errorObject?: any
+ }
+ loadRelationshipsSuccess: (
+ relationships: {
+ hasMore: boolean
+ results: DataCatalogRelationshipProposalApi[]
+ },
+ payload?: any
+ ) => {
+ relationships: {
+ hasMore: boolean
+ results: DataCatalogRelationshipProposalApi[]
+ }
+ payload?: any
+ }
+}
+
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface biSourceContextLogicMeta {
+ key: string
+ __keaTypeGenInternalSelectorTypes: {
+ joins: (database: Required<DatabaseSchemaQueryResponse> | null, arg: any) => DataWarehouseViewLink[]
+ }
+}
+
+export type biSourceContextLogicType = MakeLogicType<
+ biSourceContextLogicValues,
+ biSourceContextLogicActions,
+ BISourceContextProps,
+ biSourceContextLogicMeta
+>
+
+export const biSourceContextLogic = kea<biSourceContextLogicType>([
+ props({} as BISourceContextProps),
+ key(({ table }) => table.id + ':' + table.name),
+ path((key) => ['products', 'business_intelligence', 'biSourceContextLogic', key]),
+ connect({ values: [databaseTableListLogic, ['database']] }),
+ loaders(({ props, values }) => ({
+ description: [
+ '',
+ {
+ loadDescription: async (): Promise<string> => {
+ const project = String(teamLogic.values.currentTeamId)
+ if (props.table.type === 'view' || props.table.type === 'materialized_view') {
+ return (await warehouseSavedQueriesRetrieve(project, props.table.id)).description ?? ''
+ }
+ if (props.table.type === 'data_warehouse' && props.table.id) {
+ const result = await warehouseColumnAnnotationsList(project, { table_id: props.table.id })
+ return result.results.find((annotation) => annotation.column_name === '')?.description ?? ''
+ }
+ return ''
+ },
+ },
+ ],
+ relationships: [
+ null as { results: DataCatalogRelationshipProposalApi[]; hasMore: boolean } | null,
+ {
+ loadRelationships: async (): Promise<{
+ results: DataCatalogRelationshipProposalApi[]
+ hasMore: boolean
+ }> => {
+ const existing = values.relationships?.results ?? []
+ const result = await dataCatalogRelationshipProposalsList(String(teamLogic.values.currentTeamId), {
+ table_name: props.table.name,
+ limit: 20,
+ offset: existing.length,
+ })
+ return { results: [...existing, ...result.results], hasMore: !!result.next }
+ },
+ },
+ ],
+ })),
+ reducers({
+ contextError: [
+ false,
+ {
+ loadRelationships: () => false,
+ loadRelationshipsFailure: () => true,
+ },
+ ],
+ }),
+ selectors({
+ joins: [
+ (s) => [s.database, (_, props) => props.table.name],
+ (database: Required<DatabaseSchemaQueryResponse> | null, name) =>
+ database?.joins?.filter(
+ (join) => join.source_table_name === name || join.joining_table_name === name
+ ) ?? [],
+ ],
+ }),
+ afterMount(({ actions }) => {
+ actions.loadDescription()
+ actions.loadRelationships()
+ }),
+])
diff --git a/products/business_intelligence/frontend/biStartersLogic.test.ts b/products/business_intelligence/frontend/biStartersLogic.test.ts
new file mode 100644
index 000000000000..f471f7aa0d9d
--- /dev/null
+++ b/products/business_intelligence/frontend/biStartersLogic.test.ts
@@ -0,0 +1,65 @@
+import { expectLogic } from 'kea-test-utils'
+
+import { useMocks } from '~/mocks/jest'
+import { initKeaTests } from '~/test/init'
+
+import { biStartersLogic } from './biStartersLogic'
+
+it('requests one bounded, server-filtered page per starter list and excludes drifted definitions', async () => {
+ initKeaTests()
+ let metricParams: Record<string, string> = {}
+ let certificationParams: Record<string, string> = {}
+ const metrics = jest.fn(({ request }: { request: Request }) => {
+ metricParams = Object.fromEntries(new URL(request.url).searchParams)
+ return {
+ results: [
+ { name: 'current', status: 'approved', is_drifted: false, definition_kind: 'HogQLQuery' },
+ { name: 'drifted', status: 'approved', is_drifted: true, definition_kind: 'HogQLQuery' },
+ ],
+ next: 'next-page',
+ }
+ })
+ const certifications = jest.fn(({ request }: { request: Request }) => {
+ certificationParams = Object.fromEntries(new URL(request.url).searchParams)
+ return { results: [], next: 'next-page' }
+ })
+ useMocks({
+ get: {
+ '/api/projects/:team_id/data_catalog/metrics/': metrics,
+ '/api/projects/:team_id/data_catalog/certifications/': certifications,
+ },
+ })
+ const logic = biStartersLogic()
+ const unmount = logic.mount()
+ try {
+ await expectLogic(logic).toFinishAllListeners()
+ expect(logic.values.metrics.map((metric) => metric.name)).toEqual(['current'])
+ expect(metrics).toHaveBeenCalledTimes(1)
+ expect(certifications).toHaveBeenCalledTimes(1)
+ expect(metricParams).toEqual({ status: 'approved', definition_kind: 'HogQLQuery', limit: '3' })
+ expect(certificationParams).toEqual({ status: 'certified', limit: '3' })
+ } finally {
+ unmount()
+ }
+})
+
+it('keeps the library usable when optional catalog endpoints are unavailable', async () => {
+ initKeaTests()
+ useMocks({
+ get: {
+ '/api/projects/:team_id/data_catalog/metrics/': [403, { detail: 'Unavailable' }],
+ '/api/projects/:team_id/data_catalog/certifications/': [403, { detail: 'Unavailable' }],
+ },
+ })
+ const logic = biStartersLogic()
+ const unmount = logic.mount()
+ try {
+ await expectLogic(logic).toFinishAllListeners()
+ expect(logic.values.metrics).toEqual([])
+ expect(logic.values.sources).toEqual([])
+ expect(logic.values.metricsLoading).toBe(false)
+ expect(logic.values.sourcesLoading).toBe(false)
+ } finally {
+ unmount()
+ }
+})
diff --git a/products/business_intelligence/frontend/biStartersLogic.ts b/products/business_intelligence/frontend/biStartersLogic.ts
new file mode 100644
index 000000000000..2269822aa185
--- /dev/null
+++ b/products/business_intelligence/frontend/biStartersLogic.ts
@@ -0,0 +1,96 @@
+import { MakeLogicType, afterMount, kea, path } from 'kea'
+import { loaders } from 'kea-loaders'
+
+import { teamLogic } from 'scenes/teamLogic'
+
+import { dataCatalogCertificationsList, dataCatalogMetricsList } from 'products/data_catalog/frontend/generated/api'
+import { DataCatalogCertificationApi, DataCatalogMetricApi } from 'products/data_catalog/frontend/generated/api.schemas'
+
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface biStartersLogicValues {
+ metrics: DataCatalogMetricApi[]
+ metricsLoading: boolean
+ sources: DataCatalogCertificationApi[]
+ sourcesLoading: boolean
+}
+
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface biStartersLogicActions {
+ loadMetrics: () => any
+ loadMetricsFailure: (
+ error: string,
+ errorObject?: any
+ ) => {
+ error: string
+ errorObject?: any
+ }
+ loadMetricsSuccess: (
+ metrics: DataCatalogMetricApi[],
+ payload?: any
+ ) => {
+ metrics: DataCatalogMetricApi[]
+ payload?: any
+ }
+ loadSources: () => any
+ loadSourcesFailure: (
+ error: string,
+ errorObject?: any
+ ) => {
+ error: string
+ errorObject?: any
+ }
+ loadSourcesSuccess: (
+ sources: DataCatalogCertificationApi[],
+ payload?: any
+ ) => {
+ sources: DataCatalogCertificationApi[]
+ payload?: any
+ }
+}
+
+export type biStartersLogicType = MakeLogicType<biStartersLogicValues, biStartersLogicActions>
+
+export const biStartersLogic = kea<biStartersLogicType>([
+ path(['products', 'business_intelligence', 'biStartersLogic']),
+ loaders({
+ metrics: [
+ [] as DataCatalogMetricApi[],
+ {
+ loadMetrics: async (): Promise<DataCatalogMetricApi[]> => {
+ try {
+ const response = await dataCatalogMetricsList(String(teamLogic.values.currentTeamId), {
+ status: 'approved',
+ definition_kind: 'HogQLQuery',
+ limit: 3,
+ })
+ return response.results.filter((metric) => !metric.is_drifted)
+ } catch {
+ // Optional starters must not block the worksheet library when the catalog is unavailable.
+ return []
+ }
+ },
+ },
+ ],
+ sources: [
+ [] as DataCatalogCertificationApi[],
+ {
+ loadSources: async (): Promise<DataCatalogCertificationApi[]> => {
+ try {
+ const response = await dataCatalogCertificationsList(String(teamLogic.values.currentTeamId), {
+ status: 'certified',
+ limit: 3,
+ })
+ return response.results
+ } catch {
+ // Catalog suggestions are optional; the library remains usable without them.
+ return []
+ }
+ },
+ },
+ ],
+ }),
+ afterMount(({ actions }) => {
+ actions.loadMetrics()
+ actions.loadSources()
+ }),
+])
diff --git a/products/business_intelligence/frontend/components/BIDataPane.tsx b/products/business_intelligence/frontend/components/BIDataPane.tsx
index e3e26fff9e1f..8af1cc86527a 100644
--- a/products/business_intelligence/frontend/components/BIDataPane.tsx
+++ b/products/business_intelligence/frontend/components/BIDataPane.tsx
@@ -8,6 +8,7 @@ import { BIDataPaneSection } from 'products/business_intelligence/frontend/BIDat
import { BIDataSourcePicker } from 'products/business_intelligence/frontend/BIDataSourcePicker'
import { biEditorLogic } from 'products/business_intelligence/frontend/biEditorLogic'
import { BIHierarchySection } from 'products/business_intelligence/frontend/BIHierarchySection'
+import { BISourceContext } from 'products/business_intelligence/frontend/BISourceContext'
import { BIMemberAliasesModal } from '../BIMemberAliasesModal'
import { biSceneLogic } from '../biSceneLogic'
@@ -19,6 +20,8 @@ import { BIConnectionSelector } from './BIConnectionSelector'
export function BIDataPane({ tabId }: { tabId: string }): JSX.Element {
const {
config,
+ allTables,
+ databaseConnectionId,
dataPaneFields,
dataPaneFieldsLoading,
dataPaneFieldsError,
@@ -31,6 +34,10 @@ export function BIDataPane({ tabId }: { tabId: string }): JSX.Element {
const hasFields = dataPaneFields.dimensions.length > 0 || dataPaneFields.measures.length > 0
const hasMatches = filteredDataPaneFields.dimensions.length > 0 || filteredDataPaneFields.measures.length > 0
+ const sourceTable =
+ !config.source?.connectionId && !databaseConnectionId
+ ? allTables.find((table) => table.name === config.source?.table)
+ : undefined
return (
<div className="flex min-h-0 flex-1 flex-col">
@@ -47,6 +54,7 @@ export function BIDataPane({ tabId }: { tabId: string }): JSX.Element {
>
View source data
</LemonButton>
+ {sourceTable && <BISourceContext table={sourceTable} />}
{config.source ? (
<LemonInput
type="search"