: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.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(insights): make data warehouse series column pickers filterable (#63533)
Xander1cb91a2deef4
diff --git a/frontend/snapshots.yml b/frontend/snapshots.ymlindex daa0935dd5f5..fff62cd22ebd 100644--- a/frontend/snapshots.yml+++ b/frontend/snapshots.yml@@ -340,6 +340,10 @@ snapshots:hash: v1.k794b7964.bba20fd9be09dfbdf15cf5d0defee05e01ec7f592c7e4263bb9a862689f7f405.KEE_9obRfUkXM5lwekd8w5Ev_KqKBQfdUSftso_690scomponents-definition-popover--action--light:hash: v1.k794b7964.e04f3796a4f04cad8873ce1afdc158e4cc6a0540b8a920a8c5d918daf5199dbf.FAUSpdd2xVG1T6eZCXSQQBisUiX30_g-Q4BwRvRoE_g+ components-definition-popover--data-warehouse-column-mapping--dark:+ hash: v1.k794b7964.6f535af764881ae419ed9ac52aeca390ef92f802fbe4691778cf79fb92b5422e.VDUBeHyJ28_h-hJCnxhRXHG4SiryFPiCOOrOIMVLPMo+ components-definition-popover--data-warehouse-column-mapping--light:+ hash: v1.k794b7964.63a2124f9b72369793988678f8fc92999ae15d4812a53a3e17d2068bd3670b7d.gvgiL7tjCAmOdbH_2eMJsNb7nFdGojZs41KXBV2sbsMcomponents-definition-popover--event--dark:hash: v1.k794b7964.3da91158e1c88f8e9827213de348d341a3b3d1d8f64e1d53211b298d465133d4.oU3XnkSjwx3rnKksGGv2QOtnpMPTICcd62RII4xBReUcomponents-definition-popover--event--light:@@ -2165,9 +2169,9 @@ snapshots:filters-taxonomic-filter--three-groups-default-layout--light:hash: v1.k794b7964.7d03de4d736f21437d1009fc19719734175f0c0822cd2ccdbc380ffa8f5e627c.lGDn7Z4UhsMOqLuuLQ9_TO9FuIbd45s3RKUs7A69z7sfilters-taxonomic-filter-menu-rebuild--data-warehouse-config--dark:- hash: v1.k794b7964.61be2aec314f24a2a2c0a7a4faa1bd26e03544fbb57c33e5442a2f8abac5f4b2.YmOETQ3Yvu-wJftFxEn54OYXueKU6Ppo9pHnx2itpKk+ hash: v1.k794b7964.569842a2260c8d733d246dfe531215ef3a3d43693476adb54c851cbf8d17da7b.Ca6MIi6JxgqrWDq997ImIvtzWdbiYL0qzUS2-tXZC-Ifilters-taxonomic-filter-menu-rebuild--data-warehouse-config--light:- hash: v1.k794b7964.865f2c1d5b304c7267d14c1c0b36f283d8f1d004c5c577505bdd83874ddbbdc5.l3aN8SkWTC3GdoKxQ9tsSv-ozOv9ejOK-R-pEzvXahY+ hash: v1.k794b7964.7013ab5215c8ea2feebb430426dd7e01e528ccdee53ede68f596c50eca150998.wbsgCZgLFEkmJXYwEdUGz33ABZ1t20TDbI-HtrE35Qofilters-taxonomic-filter-menu-rebuild--events-and-actions--dark:hash: v1.k794b7964.658adcb2dd4233e9fbfe4a8c62759a6e8fe9619fe22141e691b8ab7e421ebce8.JXXooKz-3MXbjt8D2MNdWnb9xYSJD_ZglAdj1gZbZc4filters-taxonomic-filter-menu-rebuild--events-and-actions--light:diff --git a/frontend/src/lib/components/DefinitionPopover/DefinitionPopover.stories.tsx b/frontend/src/lib/components/DefinitionPopover/DefinitionPopover.stories.tsxindex 7922b847a766..25a5a1dccd65 100644--- a/frontend/src/lib/components/DefinitionPopover/DefinitionPopover.stories.tsx+++ b/frontend/src/lib/components/DefinitionPopover/DefinitionPopover.stories.tsx@@ -1,8 +1,11 @@import type { Meta, StoryObj } from '@storybook/react'+import { screen } from '@testing-library/dom'+import userEvent from '@testing-library/user-event'import { BindLogic } from 'kea'import { useRef } from 'react'import { TaxonomicFilterGroupType } from 'lib/components/TaxonomicFilter/types'+import { FEATURE_FLAGS } from 'lib/constants'import { mswDecorator } from '~/mocks/browser'import {@@ -15,6 +18,7 @@ import {} from '~/types'import {+ defaultDataWarehousePopoverFields,eventTaxonomicGroupProps,propertyTaxonomicGroupProps,taxonomicFilterLogic,@@ -240,3 +244,84 @@ export const WithoutTimestamps: Story = {groupType: TaxonomicFilterGroupType.Events,},}++// ---- Data warehouse column mapping (legacy / pill variant) --------------+// Covers the column-field pickers shown when a data warehouse table is+// selected as an insight series in the legacy TaxonomicFilter path+// (`DefinitionPopoverContents` → `DefinitionView` DWH branch). Pins the+// `pill` variant of the category-dropdown experiment. The rebuild variant+// of the same view is covered by `DataWarehouseConfig` in+// `TaxonomicFilterMenu.stories.tsx`.++const mockDataWarehouseTable = {+ id: 'dwh-table-1',+ name: 'stripe.charges',+ type: 'data_warehouse',+ fields: {+ id: { name: 'id', type: 'string' },+ amount: { name: 'amount', type: 'integer' },+ currency: { name: 'currency', type: 'string' },+ customer_email: { name: 'customer_email', type: 'string' },+ customer_id: { name: 'customer_id', type: 'string' },+ description: { name: 'description', type: 'string' },+ created_at: { name: 'created_at', type: 'datetime' },+ updated_at: { name: 'updated_at', type: 'datetime' },+ refunded: { name: 'refunded', type: 'boolean' },+ distinct_id: { name: 'distinct_id', type: 'string' },+ },+}++const dataWarehouseGroup = {+ name: 'Data warehouse tables',+ searchPlaceholder: 'data warehouse tables',+ type: TaxonomicFilterGroupType.DataWarehouse,+ getValue: (instance: any) => instance.name,+ getName: (instance: any) => instance.name,+ getPopoverHeader: () => 'Data warehouse table',+}++const DataWarehouseColumnMappingWrapper = (): JSX.Element => {+ const divRef = useRef<HTMLDivElement>(null)+ return (+ <BindLogic logic={definitionPopoverLogic} props={{ type: TaxonomicFilterGroupType.DataWarehouse }}>+ <BindLogic+ logic={taxonomicFilterLogic}+ props={{+ taxonomicFilterLogicKey: 'definition-popover-dwh-story',+ taxonomicGroupTypes: [TaxonomicFilterGroupType.DataWarehouse],+ dataWarehousePopoverFields: defaultDataWarehousePopoverFields,+ }}+ >+ <div className="p-4 bg-surface-primary" style={{ width: 500, height: 600 }}>+ <div ref={divRef} className="p-2 border border-border rounded">+ Hover target+ </div>+ <ControlledDefinitionPopover+ visible={true}+ item={mockDataWarehouseTable as any}+ group={dataWarehouseGroup as any}+ highlightedItemElement={divRef.current}+ />+ </div>+ </BindLogic>+ </BindLogic>+ )+}++export const DataWarehouseColumnMapping: Story = {+ render: () => <DataWarehouseColumnMappingWrapper />,+ parameters: {+ featureFlags: { [FEATURE_FLAGS.TAXONOMIC_FILTER_CATEGORY_DROPDOWN]: 'pill' },+ testOptions: { waitForSelector: '.definition-popover-data-warehouse-schema-form' },+ },+ // Open the first column picker so the snapshot captures the filterable+ // search-input dropdown, not just the closed control. The popover renders+ // into a portal (document.body), outside canvasElement, so query via+ // `screen` rather than `within(canvasElement)`.+ play: async () => {+ const [firstColumnSelect] = await screen.findAllByRole('textbox')+ await userEvent.click(firstColumnSelect)+ // Wait for an option row so the snapshot is taken with the dropdown open.+ await screen.findByRole('button', { name: /distinct_id \(string\)/ })+ },+}diff --git a/frontend/src/lib/components/DefinitionPopover/DefinitionPopoverContents.tsx b/frontend/src/lib/components/DefinitionPopover/DefinitionPopoverContents.tsxindex 8b0ceeea53ee..12bc6f17d07d 100644--- a/frontend/src/lib/components/DefinitionPopover/DefinitionPopoverContents.tsx+++ b/frontend/src/lib/components/DefinitionPopover/DefinitionPopoverContents.tsx@@ -3,7 +3,7 @@ import { useActions, useValues } from 'kea'import { Fragment, useEffect, useMemo } from 'react'import { IconBadge, IconEye, IconHide, IconInfo } from '@posthog/icons'-import { LemonButton, LemonDivider, LemonSegmentedButton, LemonSelect, LemonTag } from '@posthog/lemon-ui'+import { LemonButton, LemonDivider, LemonInputSelect, LemonSegmentedButton, LemonTag } from '@posthog/lemon-ui'import { ActionPopoverInfo } from 'lib/components/DefinitionPopover/ActionPopoverInfo'import { CohortPopoverInfo } from 'lib/components/DefinitionPopover/CohortPopoverInfo'@@ -520,16 +520,31 @@ function DefinitionView({ group }: { group: TaxonomicFilterGroup }): JSX.Element)}</label>{!hogQLOnly && (- <LemonSelect+ <LemonInputSelect+ mode="single"fullWidth- allowClear={!!optional}- value={isHogQL ? '' : fieldValue}+ placeholder="Select a column"+ value={isHogQL ? [''] : fieldValue != null ? [fieldValue] : null}options={[- ...columnOptions.filter((col) => !type || col.type === type),- ...(allowHogQL ? [hogqlOption] : []),+ ...columnOptions+ .filter((col) => !type || col.type === type)+ .map((col) => ({+ key: col.value,+ label: col.label,+ value: col.value,+ })),+ ...(allowHogQL+ ? [+ {+ key: hogqlOption.value,+ label: hogqlOption.label,+ value: hogqlOption.value,+ },+ ]+ : []),]}- onChange={(value: string | null) =>- setLocalDefinition({ [key]: value })+ onChange={(value) =>+ setLocalDefinition({ [key]: value.length > 0 ? value[0] : null })}/>)}diff --git a/frontend/src/lib/components/TaxonomicFilter/menu/DwhFlow.tsx b/frontend/src/lib/components/TaxonomicFilter/menu/DwhFlow.tsxindex 7d0027ebcbf8..8a0f00a43908 100644--- a/frontend/src/lib/components/TaxonomicFilter/menu/DwhFlow.tsx+++ b/frontend/src/lib/components/TaxonomicFilter/menu/DwhFlow.tsx@@ -28,11 +28,17 @@* that mirrors the legacy popover.*/import { useValues } from 'kea'-import { useMemo, useState } from 'react'+import { useMemo, useRef, useState } from 'react'import {Badge,Button,+ Combobox,+ ComboboxContent,+ ComboboxEmpty,+ ComboboxInput,+ ComboboxItem,+ ComboboxList,Dialog,DialogBody,DialogContent,@@ -46,12 +52,6 @@ import {ItemContent,ItemDescription,ItemTitle,- Select,- SelectContent,- SelectGroup,- SelectItem,- SelectTrigger,- SelectValue,Tabs,TabsList,TabsTrigger,@@ -512,7 +512,18 @@ interface ColumnSelectProps {const HOGQL_SENTINEL = '__hogql__'+/** Flat entry shape backing the combobox — `title`/`description` map to the+ * column name + type (or the SQL-expression sentinel row). */+interface ColumnSelectEntry {+ value: string+ title: string+ description?: string+}+function ColumnSelect({ options, value, onChange, allowHogQL }: ColumnSelectProps): JSX.Element {+ const [open, setOpen] = useState(false)+ const triggerRef = useRef<HTMLButtonElement>(null)+// HogQL mode whenever the value isn't a real column name AND the field// allows it. Drop the `!!value` guard so the empty string (set by// picking "SQL expression" from the dropdown before typing anything)@@ -520,57 +531,59 @@ function ColumnSelect({ options, value, onChange, allowHogQL }: ColumnSelectProp// rendering as blank.const isHogQL = allowHogQL && !options.some((o) => o.name === value)const displayValue = isHogQL ? HOGQL_SENTINEL : value++ const items: ColumnSelectEntry[] = useMemo(+ () => [+ ...options.map((o) => ({ value: o.name, title: o.name, description: o.type as string })),+ ...(allowHogQL+ ? [{ value: HOGQL_SENTINEL, title: 'SQL expression', description: 'Use a HogQL expression' }]+ : []),+ ],+ [options, allowHogQL]+ )++ const selectedItem = items.find((item) => item.value === displayValue) ?? null+return (- <Select<string>- value={displayValue || undefined}- onValueChange={(v) => onChange((v === HOGQL_SENTINEL ? '' : (v as string)) ?? '')}- itemToStringLabel={(o) => o ?? ''}- itemToStringValue={(o) => o ?? ''}+ <Combobox+ items={items}+ itemToStringLabel={(item: ColumnSelectEntry) => item.title}+ itemToStringValue={(item: ColumnSelectEntry) => item.value}+ open={open}+ onOpenChange={setOpen}+ value={selectedItem}+ onValueChange={(item: ColumnSelectEntry | null) =>+ onChange(item ? (item.value === HOGQL_SENTINEL ? '' : item.value) : '')+ }>- <SelectTrigger render={(props) => <Button variant="outline" {...props} className="h-min" />}>- <SelectValue placeholder="Select a value">- {(option: string | null) => {- if (!option) {- return null- }- if (option === HOGQL_SENTINEL) {- return (- <ItemContent variant="menuItem">- <ItemTitle>SQL expression</ItemTitle>- <ItemDescription className="leading-none">Use a HogQL expression</ItemDescription>- </ItemContent>- )- }- const opt = options.find((o) => o.name === option)- return (- <ItemContent variant="menuItem">- <ItemTitle>{option}</ItemTitle>- {opt?.type && <ItemDescription className="leading-none">{opt.type}</ItemDescription>}- </ItemContent>- )- }}- </SelectValue>- </SelectTrigger>- <SelectContent className="min-w-(--anchor-width)" align="start" sideOffset={8}>- <SelectGroup>- {options.map((o) => (- <SelectItem key={o.name} value={o.name} className="py-0">- <ItemContent variant="menuItem">- <ItemTitle>{o.name}</ItemTitle>- <ItemDescription className="leading-none">{o.type}</ItemDescription>- </ItemContent>- </SelectItem>- ))}- {allowHogQL && (- <SelectItem value={HOGQL_SENTINEL} className="py-0">+ <Button ref={triggerRef} variant="outline" className="h-min" onClick={() => setOpen((prev) => !prev)}>+ {selectedItem ? (+ <ItemContent variant="menuItem">+ <ItemTitle>{selectedItem.title}</ItemTitle>+ {selectedItem.description && (+ <ItemDescription className="leading-none">{selectedItem.description}</ItemDescription>+ )}+ </ItemContent>+ ) : (+ <span className="text-muted-foreground">Select a value</span>+ )}+ </Button>+ <ComboboxContent anchor={triggerRef} className="min-w-(--anchor-width)" align="start" sideOffset={8}>+ <ComboboxInput placeholder="Search columns" showTrigger={false} />+ <ComboboxEmpty>No columns found</ComboboxEmpty>+ <ComboboxList>+ {(item: ColumnSelectEntry) => (+ <ComboboxItem key={item.value} value={item} className="py-0"><ItemContent variant="menuItem">- <ItemTitle>SQL expression</ItemTitle>- <ItemDescription className="leading-none">Use a HogQL expression</ItemDescription>+ <ItemTitle>{item.title}</ItemTitle>+ {item.description && (+ <ItemDescription className="leading-none">{item.description}</ItemDescription>+ )}</ItemContent>- </SelectItem>+ </ComboboxItem>)}- </SelectGroup>- </SelectContent>- </Select>+ </ComboboxList>+ </ComboboxContent>+ </Combobox>)}diff --git a/frontend/src/lib/components/TaxonomicFilter/menu/TaxonomicFilterMenu.stories.tsx b/frontend/src/lib/components/TaxonomicFilter/menu/TaxonomicFilterMenu.stories.tsxindex 4b6cd70af645..de7678703272 100644--- a/frontend/src/lib/components/TaxonomicFilter/menu/TaxonomicFilterMenu.stories.tsx+++ b/frontend/src/lib/components/TaxonomicFilter/menu/TaxonomicFilterMenu.stories.tsx@@ -4,6 +4,7 @@ import { useState } from 'react'import { formatPropertyLabel } from 'lib/components/PropertyFilters/utils'import { taxonomicFilterMocksDecorator } from 'lib/components/TaxonomicFilter/__mocks__/taxonomicFilterMocksDecorator'+import { FEATURE_FLAGS } from 'lib/constants'import { actionsModel } from '~/models/actionsModel'import { getCoreFilterDefinition } from '~/taxonomy/helpers'@@ -296,6 +297,11 @@ function DwhConfigContainer(): JSX.Element {export const DataWarehouseConfig: Story = {render: () => <DwhConfigContainer />,parameters: {+ featureFlags: { [FEATURE_FLAGS.TAXONOMIC_FILTER_MENU_REBUILD]: true },+ testOptions: {+ waitForSelector: '[data-attr="dwh-config-back"]',+ snapshotTargetSelector: '[data-slot="dialog-content"]',+ },docs: {description: {story: 'DataWarehouse config form rendered standalone so it lands on the DWH interface immediately. Wide table with mixed types (string / integer / decimal / datetime / boolean / lazy_table / view) exercises every column-type filter in the dropdowns plus the linked-tables hint in the HogQL fallback. Tabs are configured to mirror the funnel popover (Aggregation target / Timestamp / Unique ID).',diff --git a/frontend/src/scenes/insights/EditorFilters/FunnelDataWarehouseStepDefinitionPopover.tsx b/frontend/src/scenes/insights/EditorFilters/FunnelDataWarehouseStepDefinitionPopover.tsxindex fc8871a78e3a..acd4bef06be2 100644--- a/frontend/src/scenes/insights/EditorFilters/FunnelDataWarehouseStepDefinitionPopover.tsx+++ b/frontend/src/scenes/insights/EditorFilters/FunnelDataWarehouseStepDefinitionPopover.tsx@@ -1,6 +1,6 @@import { useActions, useValues } from 'kea'-import { LemonButton, LemonSegmentedButton, LemonSelect, Link } from '@posthog/lemon-ui'+import { LemonButton, LemonInputSelect, LemonSegmentedButton, Link } from '@posthog/lemon-ui'import { HogQLDropdown } from 'lib/components/HogQLDropdown/HogQLDropdown'import { DatabaseTablePreview } from 'lib/components/TablePreview/DatabaseTablePreview'@@ -121,14 +121,20 @@ function FunnelDataWarehouseStepDefinitionPopoverContent({</div>)}- <LemonSelect+ <LemonInputSelectclassName="mt-2"+ mode="single"fullWidth- value={activeFieldValue}- options={activeFieldOptions}- onChange={(value: string | null) =>+ placeholder="Select a column"+ value={activeFieldIsHogQL ? [''] : activeFieldValue != null ? [activeFieldValue] : null}+ options={activeFieldOptions.map((option) => ({+ key: option.value,+ label: option.label,+ value: option.value,+ }))}+ onChange={(value) =>setLocalDefinition({- [activeFieldKey]: value ?? undefined,+ [activeFieldKey]: value.length > 0 ? value[0] : undefined,} as Partial<DataWarehouseTableForInsight>)}/>