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.

fix(data-warehouse): use group count to decide collapsible vs flat schema picker (#59431)

Daniel RCc73316649454
diff --git a/products/data_warehouse/frontend/scenes/SchemaScene/ConfigurationTab.tsx b/products/data_warehouse/frontend/scenes/SchemaScene/ConfigurationTab.tsx
index 3266266cda16..398037fa59d9 100644
--- a/products/data_warehouse/frontend/scenes/SchemaScene/ConfigurationTab.tsx
+++ b/products/data_warehouse/frontend/scenes/SchemaScene/ConfigurationTab.tsx
@@ -421,8 +421,8 @@ function ColumnsSection({
updateSchema: (schema: ExternalDataSourceSchema) => void
resyncSchema: (schema: ExternalDataSourceSchema) => void
}): JSX.Element {
- const isPostgres = source?.source_type === 'Postgres'
const available = schema.available_columns ?? []
+ const hasAvailableColumns = available.length > 0
const synced = schema.enabled_columns
const alwaysRetained = new Set<string>([
@@ -497,10 +497,8 @@ function ColumnsSection({
description="Choose which columns from this table get synced. Primary keys and the active incremental field are always synced."
/>
<div className="border rounded p-4 bg-surface-primary flex flex-col gap-3">
- {!isPostgres ? (
- <span className="text-muted">
- Per-column selection is currently available for Postgres sources only.
- </span>
+ {!hasAvailableColumns ? (
+ <span className="text-muted">Per-column selection isn't available for this source yet.</span>
) : (
<>
<span className="text-sm text-secondary">{summaryLine}</span>
diff --git a/products/data_warehouse/frontend/scenes/SchemaScene/SchemaScene.tsx b/products/data_warehouse/frontend/scenes/SchemaScene/SchemaScene.tsx
index 2eca53859893..50797f8e02a6 100644
--- a/products/data_warehouse/frontend/scenes/SchemaScene/SchemaScene.tsx
+++ b/products/data_warehouse/frontend/scenes/SchemaScene/SchemaScene.tsx
@@ -67,6 +67,8 @@ function SchemaSceneContent({ sourceId, schemaId }: SchemaSceneProps): JSX.Eleme
const cleanedSourceId = cleanSourceId(sourceId)
const showMetrics = !!featureFlags[FEATURE_FLAGS.DWH_SOURCE_METRICS]
+ const showColumnsSection = (schema?.available_columns?.length ?? 0) > 0
+ const visibleSections = SCHEMA_CONFIGURATION_SECTIONS.filter((key) => key !== 'columns' || showColumnsSection)
useEffect(() => {
if (!showMetrics && currentTab === 'metrics') {
@@ -74,6 +76,12 @@ function SchemaSceneContent({ sourceId, schemaId }: SchemaSceneProps): JSX.Eleme
}
}, [showMetrics, currentTab, setCurrentTab])
+ useEffect(() => {
+ if (!showColumnsSection && currentSection === 'columns') {
+ setCurrentSection('details')
+ }
+ }, [showColumnsSection, currentSection, setCurrentSection])
+
if (sourceLoading && !source) {
return (
<SceneContent>
@@ -93,6 +101,7 @@ function SchemaSceneContent({ sourceId, schemaId }: SchemaSceneProps): JSX.Eleme
key: 'configuration',
content: (
<ConfigurationSectionLayout
+ sections={visibleSections}
section={currentSection}
onSectionChange={setCurrentSection}
body={
@@ -131,10 +140,12 @@ function SchemaSceneContent({ sourceId, schemaId }: SchemaSceneProps): JSX.Eleme
}
function ConfigurationSectionLayout({
+ sections,
section,
onSectionChange,
body,
}: {
+ sections: readonly SchemaConfigurationSection[]
section: SchemaConfigurationSection
onSectionChange: (section: SchemaConfigurationSection) => void
body: JSX.Element
@@ -143,7 +154,7 @@ function ConfigurationSectionLayout({
<div className="flex items-start gap-6">
<nav className="sticky top-[var(--scene-title-section-height,50px)] flex flex-col w-56 flex-shrink-0">
<ul className="flex flex-col gap-y-px">
- {SCHEMA_CONFIGURATION_SECTIONS.map((key) => (
+ {sections.map((key) => (
<li key={key}>
<LemonButton
fullWidth
diff --git a/products/data_warehouse/frontend/shared/components/forms/SchemaForm.tsx b/products/data_warehouse/frontend/shared/components/forms/SchemaForm.tsx
index 213971a43efe..38bbaee9eeba 100644
--- a/products/data_warehouse/frontend/shared/components/forms/SchemaForm.tsx
+++ b/products/data_warehouse/frontend/shared/components/forms/SchemaForm.tsx
@@ -67,13 +67,11 @@ export default function SchemaForm(): JSX.Element {
schemaNameFilter,
suggestedTablesMap,
isDirectQueryMode,
- selectedConnector,
tablesAllToggledOn,
source,
groupedDirectQueryDatabaseSchema,
expandedDirectQuerySchemaKeys,
} = useValues(sourceWizardLogic)
- const isPostgresWarehouseMode = !isDirectQueryMode && selectedConnector?.name === 'Postgres'
const onClickCheckbox = (schema: ExternalDataSourceSyncSchema, checked: boolean): void => {
if (!isDirectQueryMode && schema.sync_type === null) {
@@ -359,7 +357,9 @@ export default function SchemaForm(): JSX.Element {
embedded
activeKeys={
groupedDirectQueryDatabaseSchema.length === 1
- ? groupedDirectQueryDatabaseSchema.map((g) => g.schemaName)
+ ? groupedDirectQueryDatabaseSchema.map(
+ (g: { schemaName: string }) => g.schemaName
+ )
: expandedDirectQuerySchemaKeys
}
onChange={setExpandedDirectQuerySchemaKeys}
@@ -468,63 +468,53 @@ export default function SchemaForm(): JSX.Element {
) : (
<div className="border rounded px-4 py-8 text-center text-muted-alt">No tables found</div>
)
- ) : isPostgresWarehouseMode ? (
- groupedDirectQueryDatabaseSchema.length > 0 ? (
- <div className="border rounded bg-bg-light">
- <LemonCollapse
- multiple
- embedded
- activeKeys={
- groupedDirectQueryDatabaseSchema.length === 1
- ? groupedDirectQueryDatabaseSchema.map((g) => g.schemaName)
- : expandedDirectQuerySchemaKeys
- }
- onChange={setExpandedDirectQuerySchemaKeys}
- panels={groupedDirectQueryDatabaseSchema.map(
- ({
- schemaName,
- tables,
- }: {
- schemaName: string
- tables: ExternalDataSourceSyncSchema[]
- }) => ({
- key: schemaName,
- header: (
- <div className="flex items-center justify-between gap-3 w-full">
- <div className="flex items-center gap-2 min-w-0">
- <LemonCheckbox
- checked={getSchemaSelectionState(tables)}
- stopPropagation
- onChange={(checked) =>
- toggleDirectQuerySchemaGroup(schemaName, checked)
- }
- />
- <span className="font-semibold truncate">{schemaName}</span>
- </div>
- <span className="text-xs text-muted-alt whitespace-nowrap">
- {tables.filter((t) => t.should_sync).length} of {tables.length}{' '}
- tables
- </span>
+ ) : groupedDirectQueryDatabaseSchema.length > 1 ? (
+ <div className="border rounded bg-bg-light">
+ <LemonCollapse
+ multiple
+ embedded
+ activeKeys={expandedDirectQuerySchemaKeys}
+ onChange={setExpandedDirectQuerySchemaKeys}
+ panels={groupedDirectQueryDatabaseSchema.map(
+ ({
+ schemaName,
+ tables,
+ }: {
+ schemaName: string
+ tables: ExternalDataSourceSyncSchema[]
+ }) => ({
+ key: schemaName,
+ header: (
+ <div className="flex items-center justify-between gap-3 w-full">
+ <div className="flex items-center gap-2 min-w-0">
+ <LemonCheckbox
+ checked={getSchemaSelectionState(tables)}
+ stopPropagation
+ onChange={(checked) =>
+ toggleDirectQuerySchemaGroup(schemaName, checked)
+ }
+ />
+ <span className="font-semibold truncate">{schemaName}</span>
</div>
- ),
- content: (
- <LemonTable
- embedded
- showHeader={false}
- dataSource={tables}
- pagination={{ pageSize: 100, hideOnSinglePage: true }}
- columns={warehouseColumns}
- />
- ),
- })
- )}
- />
- </div>
- ) : (
- <div className="border rounded px-4 py-8 text-center text-muted-alt">
- {schemaNameFilter ? `No tables match "${schemaNameFilter}"` : 'No schemas found'}
- </div>
- )
+ <span className="text-xs text-muted-alt whitespace-nowrap">
+ {tables.filter((t) => t.should_sync).length} of {tables.length}{' '}
+ tables
+ </span>
+ </div>
+ ),
+ content: (
+ <LemonTable
+ embedded
+ showHeader={false}
+ dataSource={tables}
+ pagination={{ pageSize: 100, hideOnSinglePage: true }}
+ columns={warehouseColumns}
+ />
+ ),
+ })
+ )}
+ />
+ </div>
) : (
<LemonTable
emptyState={schemaNameFilter ? `No tables match "${schemaNameFilter}"` : 'No schemas found'}