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(sql-editor): split popular and posthog table categories (#101525)

Marius Andra29dbd3e5d563
diff --git a/docs/internal/sql-editor-schema-tree.md b/docs/internal/sql-editor-schema-tree.md
index 315cf42a2d69..1fd465de4a1c 100644
--- a/docs/internal/sql-editor-schema-tree.md
+++ b/docs/internal/sql-editor-schema-tree.md
@@ -1,5 +1,16 @@
# SQL editor schema tree
+The Sources tree starts with Popular, containing `events`, `groups`, `persons`, and `sessions`.
+PostHog follows with the full PostHog catalog, sorted by name and qualified with `posthog.`, including those four tables.
+Qualified entries use the same schema fields as their unqualified shortcuts.
+Search includes both categories, and table actions use the name shown in the tree.
+
+The PostHog catalog includes `posthog.ai_events` for AI observability, `posthog.session_replay_events` for recordings, and `posthog.trace_spans` for tracing.
+`posthog.metrics` contains metric data points; join `posthog.metric_series` for their labels.
+`posthog.flag_evaluations` appears when enabled for the organization.
+These tables come from the backend catalog without a separate sidebar allowlist.
+Namespace-only tables retain their `posthog.` prefix when requesting fields.
+
The SQL editor requests the database catalog with `DatabaseSchemaQuery.includeFields = false`.
The response contains table names and source metadata, with empty field dictionaries.
The sidebar does not mount source management or request the full external source list.
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index 05c7a143c77c..441678e36e06 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -7865,9 +7865,9 @@ snapshots:
scenes-app-data-warehouse-settings-schemas--multi-schema--light:
hash: v1.k794b7964.e5d678194a8e191fdf4f8a92cd7328f1e3cb162a81d3c4d05ef608f3c61537da.ZshlecoDn8CpsaVHaONi7UiXq8r-Xi4zJSWKeg7nAP0
scenes-app-data-warehouse-sql-editor--lazy-schema--dark:
- hash: v1.k794b7964.f7751fbc0f595aee24a590384d916693db3ee041ec4588a7206a92d370dc64be.yaZ0OmSVCnBWFsPxhe2sUdJNjDIppJg6M1kbVq_d6LE
+ hash: v1.k794b7964.6df7c8bdfde9cdca11881bfe77869c752f291d9bbcf4720265dc6c339fbab7ef.ljQafFei07bBzxV4_e2hW5afHG5UzdAk6uV-1xgVs8I
scenes-app-data-warehouse-sql-editor--lazy-schema--light:
- hash: v1.k794b7964.a2d4e8ccc169b6518ba08428d95eed3c0d6ad29aab451e71ac798e73d04b7ce5.qGJUulUBR1ncSPvultxYrIinGX-Pyq7mDPvkTeIfQ9E
+ hash: v1.k794b7964.a0be94b3b1bceba6156985d7a9a25d308e8a4dc9b88719efce572f7a0c7e19e1.c5o19bpW5K_DHKVIOiCvSyoVG6b9nv6096aYuIBYS6U
scenes-app-data-warehouse-sql-editor--managed-warehouse-connection--dark:
hash: v1.k794b7964.4d87a8398ed4a62e9e18ef60f2e907fc8f1585d178833c8eacc34eb5b49cd7cf.jIj6nVJk8Wp1LwkjVO3t4AsK_U0iWUqtUVC6HzXz12g
scenes-app-data-warehouse-sql-editor--managed-warehouse-connection--light:
diff --git a/frontend/src/scenes/data-warehouse/editor/SQLEditorScene.stories.tsx b/frontend/src/scenes/data-warehouse/editor/SQLEditorScene.stories.tsx
index e597b90b71cf..c73d115721de 100644
--- a/frontend/src/scenes/data-warehouse/editor/SQLEditorScene.stories.tsx
+++ b/frontend/src/scenes/data-warehouse/editor/SQLEditorScene.stories.tsx
@@ -227,6 +227,7 @@ export const MaterializationSettings: StoryObj = {
export const LazySchema: Story = {
parameters: {
+ pageUrl: urls.sqlEditor({ query: 'SELECT * FROM events LIMIT 100' }),
msw: {
mocks: {
get: {
@@ -254,6 +255,29 @@ export const LazySchema: Story = {
query: { kind: string; includeFields?: boolean; tables?: string[] }
}
const tables = {
+ ...Object.fromEntries(
+ [
+ 'groups',
+ 'sessions',
+ 'logs',
+ 'cohort_people',
+ 'session_replay_events',
+ 'posthog.flag_evaluations',
+ 'posthog.trace_spans',
+ 'posthog.metrics',
+ 'posthog.metric_series',
+ ].map((name) => [
+ name,
+ {
+ id: name,
+ name,
+ type: 'posthog',
+ fields: {
+ id: { name: 'id', hogql_value: 'id', type: 'string', schema_valid: true },
+ },
+ },
+ ])
+ ),
events: {
id: 'events',
name: 'events',
@@ -277,6 +301,27 @@ export const LazySchema: Story = {
},
},
},
+ 'posthog.ai_events': {
+ id: 'posthog.ai_events',
+ name: 'posthog.ai_events',
+ type: 'posthog',
+ fields: {
+ uuid: { name: 'uuid', hogql_value: 'uuid', type: 'string', schema_valid: true },
+ event: { name: 'event', hogql_value: 'event', type: 'string', schema_valid: true },
+ timestamp: {
+ name: 'timestamp',
+ hogql_value: 'timestamp',
+ type: 'datetime',
+ schema_valid: true,
+ },
+ properties: {
+ name: 'properties',
+ hogql_value: 'properties',
+ type: 'json',
+ schema_valid: true,
+ },
+ },
+ },
saved_events: {
id: 'saved-view',
name: 'saved_events',
@@ -306,6 +351,7 @@ export const LazySchema: Story = {
{
tables: Object.fromEntries(
Object.entries(tables)
+ .sort(([a], [b]) => a.localeCompare(b))
.filter(([name]) => !query.tables || query.tables.includes(name))
.map(([name, table]) => [
name,
diff --git a/frontend/src/scenes/data-warehouse/editor/sidebar/queryDatabaseLogic.test.ts b/frontend/src/scenes/data-warehouse/editor/sidebar/queryDatabaseLogic.test.ts
index 0fcaa5a203e7..034ddc089373 100644
--- a/frontend/src/scenes/data-warehouse/editor/sidebar/queryDatabaseLogic.test.ts
+++ b/frontend/src/scenes/data-warehouse/editor/sidebar/queryDatabaseLogic.test.ts
@@ -42,6 +42,8 @@ describe('queryDatabaseLogic', () => {
describe('property definition targets', () => {
test.each([
['event properties', 'events', 'properties', jsonField(), { type: 'event' }],
+ ['qualified event properties', 'posthog.events', 'properties', jsonField(), { type: 'event' }],
+ ['qualified person properties', 'posthog.persons', 'properties', jsonField(), { type: 'person' }],
['AI event properties', 'ai_events', 'properties', jsonField(), { type: 'event' }],
['person properties', 'persons', 'properties', jsonField(), { type: 'person' }],
['person properties joined to events', 'events', 'person.properties', jsonField(), { type: 'person' }],
@@ -116,7 +118,7 @@ describe('queryDatabaseLogic', () => {
const propertyNode = (): NonNullable<(typeof logic.values.treeData)[number]> | undefined =>
logic.values.treeData
.find((item) => item.record?.type === 'sources')
- ?.children?.find((item) => item.name === 'PostHog')
+ ?.children?.find((item) => item.name === 'Popular')
?.children?.find((item) => item.name === 'events')
?.children?.find((item) => item.record?.type === 'property-field')
@@ -443,7 +445,7 @@ describe('queryDatabaseLogic', () => {
logic.actions.locateTable('events')
expect(logic.values.expandedFolders).toEqual(
- expect.arrayContaining(['sources', 'source-posthog', 'table-events'])
+ expect.arrayContaining(['sources', 'source-Popular', 'table-events'])
)
expect(logic.values.tableToLocate).toEqual('events')
@@ -502,15 +504,63 @@ describe('queryDatabaseLogic', () => {
})
})
+ it('groups popular shortcuts and the qualified catalog in browsing and search', () => {
+ initKeaTests()
+ const logic = queryDatabaseLogic()
+ logic.mount()
+ const names = [
+ 'sessions',
+ 'events',
+ 'groups',
+ 'persons',
+ 'logs',
+ 'posthog.flag_evaluations',
+ 'posthog.ai_events',
+ ]
+ databaseTableListLogic.findMounted()?.actions.loadDatabaseSuccess({
+ tables: Object.fromEntries(names.map((name) => [name, { id: name, name, type: 'posthog', fields: {} }])),
+ joins: [],
+ })
+ const sources = logic.values.treeData.find((item) => item.id === 'sources')!.children!
+ expect(sources.map((item) => item.name)).toEqual(['Popular', 'PostHog'])
+ expect(sources[0].children?.map((item) => item.name)).toEqual(['events', 'groups', 'persons', 'sessions'])
+ expect(sources[1].children?.map((item) => item.name)).toEqual([
+ 'posthog.ai_events',
+ 'posthog.events',
+ 'posthog.flag_evaluations',
+ 'posthog.groups',
+ 'posthog.logs',
+ 'posthog.persons',
+ 'posthog.sessions',
+ ])
+ const tableIds = sources.flatMap((item) => item.children!.map((table) => table.id))
+ expect(new Set(tableIds).size).toBe(tableIds.length)
+ logic.actions.locateTable('posthog.logs')
+ expect(logic.values.expandedFolders).toEqual(
+ expect.arrayContaining(['sources', 'source-posthog', 'table-posthog.logs'])
+ )
+ logic.actions.setSearchTerm('events')
+ const searchSources = logic.values.searchTreeData.find((item) => item.record?.type === 'sources')!.children!
+ expect(searchSources.map((item) => item.name)).toEqual(['Popular', 'PostHog'])
+ expect(searchSources.flatMap((item) => item.children!.map((table) => table.name))).toEqual([
+ 'events',
+ 'posthog.ai_events',
+ 'posthog.events',
+ ])
+ logic.actions.setSearchTerm('posthog.flag_evaluations')
+ expect(logic.values.relevantPosthogTables.map(([table]) => table.name)).toContain('posthog.flag_evaluations')
+ logic.unmount()
+ })
+
describe('lazy schema hydration', () => {
let logic: ReturnType<typeof queryDatabaseLogic.build>
let dbLogic: ReturnType<typeof databaseTableListLogic.build>
- const findTableNode = (): any =>
+ const findTableNode = (name = 'events'): any =>
logic.values.treeData
.find((item) => item.record?.type === 'sources')
- ?.children?.find((child) => child.id === 'source-posthog')
- ?.children?.find((child) => child.id === 'table-events')
+ ?.children?.flatMap((child) => child.children ?? [])
+ .find((child) => child.id === `table-${name}`)
beforeEach(async () => {
initKeaTests()
@@ -526,6 +576,12 @@ describe('queryDatabaseLogic', () => {
tables: {
events: { id: 'events', name: 'events', type: 'posthog', fields: {} },
persons: { id: 'persons', name: 'persons', type: 'posthog', fields: {} },
+ 'posthog.ai_events': {
+ id: 'posthog.ai_events',
+ name: 'posthog.ai_events',
+ type: 'posthog',
+ fields: {},
+ },
},
joins: [],
})
@@ -620,7 +676,7 @@ describe('queryDatabaseLogic', () => {
joins: [],
})
if (restored) {
- logic.actions.setExpandedFolders(['sources', 'source-posthog', 'table-events', joinNode.id], null)
+ logic.actions.setExpandedFolders(['sources', 'source-Popular', 'table-events', joinNode.id], null)
} else {
logic.actions.toggleFolderOpen(joinNode.id, false)
}
@@ -640,6 +696,60 @@ describe('queryDatabaseLogic', () => {
expect(performQuery).toHaveBeenLastCalledWith(expect.objectContaining({ tables: ['persons'] }))
})
+ it.each(['events', 'posthog.events', 'posthog.ai_events'])(
+ 'hydrates %s and defers joined fields until expansion',
+ async (name) => {
+ const schemaName = name === 'posthog.ai_events' ? name : 'events'
+ const placeholder = findTableNode(name)?.children?.[0]
+ expect(placeholder?.type).toEqual('loading-indicator')
+ expect(placeholder?.record?.pendingTableName).toEqual(schemaName)
+
+ expect(performQuery).not.toHaveBeenCalled()
+ logic.actions.toggleFolderOpen(`table-${name}`, false)
+ await expectLogic(dbLogic).toFinishAllListeners()
+
+ expect(performQuery).toHaveBeenCalledWith(expect.objectContaining({ tables: [schemaName] }))
+
+ dbLogic.actions.hydrateTableFieldsSuccess([schemaName], {
+ [schemaName]: {
+ id: schemaName,
+ name: schemaName,
+ type: 'posthog',
+ fields: {
+ uuid: { name: 'uuid', hogql_value: 'uuid', type: 'string', schema_valid: true },
+ person: {
+ name: 'person',
+ hogql_value: 'person',
+ type: 'lazy_table',
+ table: 'persons',
+ schema_valid: true,
+ },
+ },
+ } as any,
+ })
+
+ const columnNames = findTableNode(name)?.children?.map((child: any) => child.name)
+ expect(columnNames).toEqual(['uuid', 'person'])
+ expect(performQuery).toHaveBeenCalledTimes(1)
+ if (schemaName === 'events') {
+ logic.actions.toggleFolderOpen(`table-${name === 'events' ? 'posthog.events' : 'events'}`, false)
+ }
+ logic.actions.selectSchema(findTableNode(name).record.table)
+ await expectLogic(dbLogic).toFinishAllListeners()
+ expect(performQuery).toHaveBeenCalledTimes(1)
+ expect(
+ logic.values.sidebarOverlayTreeItems.map((item) => ('name' in item ? item.name : undefined))
+ ).toEqual(['uuid', 'person'])
+ const joinNode = findTableNode(name)?.children?.find(
+ (child: any) => child.record?.type === 'lazy-table'
+ )
+ expect(joinNode).toBeTruthy()
+ logic.actions.toggleFolderOpen(joinNode.id, false)
+ await expectLogic(dbLogic).toFinishAllListeners()
+ expect(performQuery).toHaveBeenLastCalledWith(expect.objectContaining({ tables: ['persons'] }))
+ }
+ )
+
it.each(['view', 'materialized_view'] as const)(
'hydrates a saved %s on expansion and shares fields with the overlay and joins',
async (type) => {
diff --git a/frontend/src/scenes/data-warehouse/editor/sidebar/queryDatabaseLogic.tsx b/frontend/src/scenes/data-warehouse/editor/sidebar/queryDatabaseLogic.tsx
index 65b9169d6b3a..174fc816bf10 100644
--- a/frontend/src/scenes/data-warehouse/editor/sidebar/queryDatabaseLogic.tsx
+++ b/frontend/src/scenes/data-warehouse/editor/sidebar/queryDatabaseLogic.tsx
@@ -217,6 +217,7 @@ export const getSidebarPropertyDefinitionTarget = (
return null
}
+ tableName = tableName.replace(/^posthog\./, '')
const pathSegments = columnPath.split('.')
const fieldName = pathSegments.at(-1)
if (fieldName !== 'properties' && fieldName !== 'person_properties') {
@@ -313,7 +314,7 @@ const getHydrationTableNamesForNode = (node: TreeDataItem): string[] => {
return []
}
if ((record.type === 'table' || record.type === 'endpoint') && record.table?.name) {
- return [record.table.name]
+ return [record.table.type === 'posthog' ? record.table.id : record.table.name]
}
if (
(record.type === 'lazy-table' || record.type === 'view-table' || record.type === 'field-traverser') &&
@@ -1212,7 +1213,13 @@ const createTableLookup = ({
}): TableLookup => {
return Object.fromEntries(
[
- ...posthogTables.map((table) => [table.name, { name: table.name, fields: table.fields }]),
+ ...posthogTables.flatMap((table) => {
+ const entry = { name: table.name, fields: table.fields }
+ return [
+ [table.name, entry],
+ [table.name.startsWith('posthog.') ? table.name : `posthog.${table.name}`, entry],
+ ]
+ }),
...systemTables.map((table) => [table.name, { name: table.name, fields: table.fields }]),
...dataWarehouseTables.map((table) => [table.name, { name: table.name, fields: table.fields }]),
...dataWarehouseSavedQueries.map((view) => {
@@ -1238,11 +1245,12 @@ const createTableNode = (
): TreeDataItem => {
const tableId = `${isSearch ? 'search-' : ''}table-${table.name}`
const tableChildren: TreeDataItem[] = []
+ const schemaTableName = table.type === 'posthog' ? table.id : table.name
if ('fields' in table) {
- const fieldsState = getTableFieldsState(table.name, table.fields, options?.hydration)
+ const fieldsState = getTableFieldsState(schemaTableName, table.fields, options?.hydration)
if (fieldsState === 'pending') {
- tableChildren.push(createPendingFieldsNode(tableId, table.name))
+ tableChildren.push(createPendingFieldsNode(tableId, schemaTableName))
} else if (fieldsState === 'error') {
tableChildren.push(createFieldsErrorNode(tableId))
} else {
@@ -1530,7 +1538,9 @@ const createSourceFolderNode = (
? (tables[0] as DatabaseSchemaDataWarehouseTable).url_pattern
: (matches[0][0] as DatabaseSchemaDataWarehouseTable).url_pattern) ?? ''
)
- : sourceType
+ : sourceType === 'Popular'
+ ? 'PostHog'
+ : sourceType
}
size="xsmall"
disableTooltip
@@ -1890,7 +1900,6 @@ export interface queryDatabaseLogicValues {
latestEndpointTables: DatabaseSchemaEndpointTable[] // databaseTableListLogic
managedViews: DatabaseSchemaManagedViewTable[] // databaseTableListLogic
posthogTables: DatabaseSchemaTable[] // databaseTableListLogic
- posthogTablesMap: Record<string, DatabaseSchemaTable> // databaseTableListLogic
systemTables: DatabaseSchemaTable[] // databaseTableListLogic
systemTablesMap: Record<string, DatabaseSchemaTable> // databaseTableListLogic
tableFieldsStatus: TableFieldsStatus // databaseTableListLogic
@@ -1937,6 +1946,7 @@ export interface queryDatabaseLogicValues {
selectedDirectSource: ExternalDataSourceConnectionOptionApi | undefined
selectedSchema: DatabaseSchemaDataWarehouseTable | DatabaseSchemaTable | DataWarehouseSavedQuerySummary | null
sidebarOverlayTreeItems: TreeItem[]
+ sidebarPosthogTables: DatabaseSchemaTable[]
syncMoreNoticeDismissed: boolean
tableToLocate: string | null
treeData: TreeDataItem[]
@@ -2202,8 +2212,12 @@ export interface queryDatabaseLogicActions {
export interface queryDatabaseLogicMeta {
__keaTypeGenInternalSelectorTypes: {
hasNonPosthogSources: (dataWarehouseTables: DatabaseSchemaDataWarehouseTable[]) => boolean
- relevantPosthogTables: (
+ sidebarPosthogTables: (
posthogTables: DatabaseSchemaTable[],
+ allPosthogTables: DatabaseSchemaTable[]
+ ) => DatabaseSchemaTable[]
+ relevantPosthogTables: (
+ sidebarPosthogTables: DatabaseSchemaTable[],
searchTerm: string
) => [DatabaseSchemaTable, FuseSearchMatch[] | null][]
relevantSystemTables: (
@@ -2272,7 +2286,7 @@ export interface queryDatabaseLogicMeta {
) => TreeDataItem[]
treeDataContext: (
allPosthogTables: DatabaseSchemaTable[],
- posthogTables: DatabaseSchemaTable[],
+ sidebarPosthogTables: DatabaseSchemaTable[],
systemTables: DatabaseSchemaTable[],
dataWarehouseTables: DatabaseSchemaDataWarehouseTable[],
effectiveDataWarehouseSavedQueries: DataWarehouseSavedQuerySummary[],
@@ -2321,7 +2335,6 @@ export interface queryDatabaseLogicMeta {
joinsByFieldName: (joins: DataWarehouseViewLink[]) => Record<string, DataWarehouseViewLink>
sidebarOverlayTreeItems: (
selectedSchema: DatabaseSchemaTable | DataWarehouseSavedQuerySummary | null,
- posthogTablesMap: Record<string, DatabaseSchemaTable>,
systemTablesMap: Record<string, DatabaseSchemaTable>,
dataWarehouseTablesMap: Record<string, DatabaseSchemaDataWarehouseTable | DatabaseSchemaViewTable>,
dataWarehouseSavedQueryMapById: Record<string, DataWarehouseSavedQuerySummary>,
@@ -2411,7 +2424,6 @@ export const queryDatabaseLogic = kea<queryDatabaseLogicType>([
'allPosthogTables',
'posthogTables',
'dataWarehouseTables',
- 'posthogTablesMap',
'dataWarehouseTablesMap',
'viewsMapById',
'managedViews',
@@ -2498,6 +2510,7 @@ export const queryDatabaseLogic = kea<queryDatabaseLogicType>([
'sources',
'views',
'managed-views',
+ 'search-Popular',
'search-posthog',
'search-system',
'search-datawarehouse',
@@ -2823,8 +2836,20 @@ export const queryDatabaseLogic = kea<queryDatabaseLogicType>([
return dataWarehouseTables.length > 0
},
],
+ sidebarPosthogTables: [
+ (s) => [s.posthogTables, s.allPosthogTables],
+ (popularTables: DatabaseSchemaTable[], allPosthogTables: DatabaseSchemaTable[]): DatabaseSchemaTable[] => [
+ ...[...popularTables].sort((a, b) => a.name.localeCompare(b.name)),
+ ...allPosthogTables
+ .map((table) => ({
+ ...table,
+ name: table.name.startsWith('posthog.') ? table.name : `posthog.${table.name}`,
+ }))
+ .sort((a, b) => a.name.localeCompare(b.name)),
+ ],
+ ],
relevantPosthogTables: [
- (s) => [s.posthogTables, s.searchTerm],
+ (s) => [s.sidebarPosthogTables, s.searchTerm],
(
posthogTables: DatabaseSchemaTable[],
searchTerm: string
@@ -3078,19 +3103,22 @@ export const queryDatabaseLogic = kea<queryDatabaseLogicType>([
loadPropertyDefinitions: actions.loadPropertyDefinitions,
}
- // Add PostHog tables
- if (relevantPosthogTables.length > 0) {
- expandedIds.push('search-posthog')
- sourcesChildren.push(
- createSourceFolderNode(
- 'PostHog',
+ for (const category of ['Popular', 'PostHog']) {
+ const matches = relevantPosthogTables.filter(([table]) =>
+ category === 'PostHog' ? table.name.startsWith('posthog.') : !table.name.startsWith('posthog.')
+ )
+ if (matches.length > 0) {
+ const folder = createSourceFolderNode(
+ category,
[],
- relevantPosthogTables,
+ matches,
true,
tableLookup,
tableNodeOptions
)
- )
+ expandedIds.push(folder.id)
+ sourcesChildren.push(folder)
+ }
}
// Add System tables
@@ -3230,7 +3258,7 @@ export const queryDatabaseLogic = kea<queryDatabaseLogicType>([
treeDataContext: [
(s) => [
s.allPosthogTables,
- s.posthogTables,
+ s.sidebarPosthogTables,
s.systemTables,
s.dataWarehouseTables,
s.effectiveDataWarehouseSavedQueries,
@@ -3337,11 +3365,17 @@ export const queryDatabaseLogic = kea<queryDatabaseLogicType>([
type: 'loading-indicator',
})
} else {
- // Add PostHog tables
- if (posthogTables.length > 0) {
- sourcesChildren.push(
- createSourceFolderNode('PostHog', posthogTables, [], false, tableLookup, tableNodeOptions)
+ for (const category of ['Popular', 'PostHog']) {
+ const tables = posthogTables.filter((table) =>
+ category === 'PostHog'
+ ? table.name.startsWith('posthog.')
+ : !table.name.startsWith('posthog.')
)
+ if (tables.length > 0) {
+ sourcesChildren.push(
+ createSourceFolderNode(category, tables, [], false, tableLookup, tableNodeOptions)
+ )
+ }
}
// Add System tables
@@ -3670,7 +3704,6 @@ export const queryDatabaseLogic = kea<queryDatabaseLogicType>([
sidebarOverlayTreeItems: [
(s) => [
s.selectedSchema,
- s.posthogTablesMap,
s.systemTablesMap,
s.dataWarehouseTablesMap,
s.dataWarehouseSavedQueryMapById,
@@ -3684,7 +3717,6 @@ export const queryDatabaseLogic = kea<queryDatabaseLogicType>([
| DatabaseSchemaTable
| DataWarehouseSavedQuerySummary
| null,
- posthogTablesMap: Record<string, DatabaseSchemaTable>,
systemTablesMap: Record<string, DatabaseSchemaTable>,
dataWarehouseTablesMap: Record<
string,
@@ -3709,7 +3741,7 @@ export const queryDatabaseLogic = kea<queryDatabaseLogicType>([
| DataWarehouseSavedQuerySummary
| null = null
if (isPostHogTable(selectedSchema)) {
- table = posthogTablesMap[selectedSchema.name]
+ table = allTablesMap[selectedSchema.id]
} else if (isSystemTable(selectedSchema)) {
table = systemTablesMap[selectedSchema.name]
} else if (isDataWarehouseTable(selectedSchema)) {
@@ -3805,7 +3837,7 @@ export const queryDatabaseLogic = kea<queryDatabaseLogicType>([
selectSchema: ({ schema }) => {
// The sidebar overlay lists the selected table's columns, so make sure they're loaded.
if (schema && 'name' in schema && schema.name) {
- actions.hydrateTableFields([schema.name])
+ actions.hydrateTableFields([isPostHogTable(schema) ? schema.id : schema.name])
}
},
setSearchTerm: ({ searchTerm }) => {
@@ -3880,7 +3912,7 @@ export const queryDatabaseLogic = kea<queryDatabaseLogicType>([
values.connectionId
)
},
- posthogTables: (posthogTables: DatabaseSchemaTable[]) => {
+ sidebarPosthogTables: (posthogTables: DatabaseSchemaTable[]) => {
posthogTablesFuse.setCollection(posthogTables)
},
systemTables: (systemTables: DatabaseSchemaTable[]) => {