: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
fix(data-warehouse): default keyless tables to full refresh in the source wizard (#110867)
Tom Owerseee5a31564d9
diff --git a/products/data_warehouse/frontend/scenes/NewSourceScene/sourceWizardLogic.tsx b/products/data_warehouse/frontend/scenes/NewSourceScene/sourceWizardLogic.tsxindex ecf4b84853b9..76522e475328 100644--- a/products/data_warehouse/frontend/scenes/NewSourceScene/sourceWizardLogic.tsx+++ b/products/data_warehouse/frontend/scenes/NewSourceScene/sourceWizardLogic.tsx@@ -366,6 +366,15 @@ export const resolveUpdateTrackedIncrementalField = (fields: IncrementalField[])fields.find((field) => /^(updated|modified|last_modified)/i.test(field.label) && isTimestampType(field)) ??fields.find((field) => /^created/i.test(field.label) && isTimestampType(field))+// An incremental sync merges rows on a primary key, and source creation rejects an incremental+// table whose introspected columns have no key and no `id` column to fall back to. A table with+// no introspected columns resolves its key at sync time, so it needs no key here.+const hasIncrementalMergeKey = (schema: ExternalDataSourceSyncSchema): boolean =>+ !schema.available_columns?.length ||+ !!schema.primary_key_columns?.length ||+ !!schema.detected_primary_keys?.length ||+ schema.available_columns.some((column) => column.field.toLowerCase() === 'id')+// Shared rule for bulk enablement (select-all, onboarding auto-configure): permission_error// rows stay off so bulk toggle never queues guaranteed-403 syncs, and default-off tables// (e.g. Supabase Vault tables, which hold decrypted secrets) keep their current state so@@ -2375,6 +2384,8 @@ export const sourceWizardLogic = kea<sourceWizardLogicType>([schema.sync_type = 'cdc'} else if (schema.supports_webhooks) {schema.sync_type = 'webhook'+ } else if (schema.incremental_available && !hasIncrementalMergeKey(schema)) {+ schema.sync_type = 'full_refresh'} else if (schema.incremental_available || schema.append_available) {const method = schema.incremental_available ? 'incremental' : 'append'const resolvedField =diff --git a/products/data_warehouse/frontend/scenes/NewSourceScene/tests/sourceWizardLogic.test.ts b/products/data_warehouse/frontend/scenes/NewSourceScene/tests/sourceWizardLogic.test.tsindex 2d7c2e613b83..4d8d57be0ed8 100644--- a/products/data_warehouse/frontend/scenes/NewSourceScene/tests/sourceWizardLogic.test.ts+++ b/products/data_warehouse/frontend/scenes/NewSourceScene/tests/sourceWizardLogic.test.ts@@ -10,7 +10,7 @@ import { captureMarketingCrossSellClick, getMarketingCrossSellAttribution } fromimport { ProductIntentContext, ProductKey, WebStatsBreakdown } from '~/queries/schema/schema-general'import { initKeaTests } from '~/test/init'-import type { ExternalDataSourceSyncSchema, IncrementalField } from '~/types'+import type { AvailableColumn, ExternalDataSourceSyncSchema, IncrementalField } from '~/types'import type { SourceConfigResponseApi } from 'products/warehouse_sources/frontend/generated/api.schemas'@@ -1198,6 +1198,40 @@ describe('sourceWizardLogic', () => {unmount()}})++ const column = (field: string): AvailableColumn => ({ field, label: field, type: 'string', nullable: true })++ it.each([+ ['no primary key and no id column', 'full_refresh', { available_columns: [column('updated_at')] }],+ [+ 'a detected primary key',+ 'incremental',+ { available_columns: [column('uuid'), column('updated_at')], detected_primary_keys: ['uuid'] },+ ],+ ['an id column', 'incremental', { available_columns: [column('ID'), column('updated_at')] }],+ ['no introspected columns', 'incremental', { available_columns: [] }],+ ])('defaults a table with %s to %s', async (_, expectedSyncType, overrides) => {+ jest.spyOn(api.externalDataSources, 'database_schema').mockResolvedValue([+ apiSchema({+ incremental_available: true,+ incremental_fields: [+ { field: 'updated_at', field_type: 'datetime', label: 'updated_at', type: 'datetime' },+ ],+ ...overrides,+ }),+ ] as ExternalDataSourceSyncSchema[])++ const logic = sourceWizardLogic({ availableSources: { Stripe: stripeSource } })+ const unmount = logic.mount()++ try {+ logic.actions.selectConnector(stripeSource)+ await expectLogic(logic, () => logic.actions.getDatabaseSchemas()).toFinishAllListeners()+ expect(logic.values.databaseSchema[0].sync_type).toBe(expectedSyncType)+ } finally {+ unmount()+ }+ })})// Signals setup passes requiredTables to skip the schema step and sync just those tables.