: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
chore(batch-exports): snowflake exports always use an integration (#100569)
Ross674bdcaffdc0
diff --git a/frontend/src/scenes/data-pipelines/batch-exports/BatchExportScene.stories.tsx b/frontend/src/scenes/data-pipelines/batch-exports/BatchExportScene.stories.tsxindex 1bcf1ba6f11a..748cae1e2ab5 100644--- a/frontend/src/scenes/data-pipelines/batch-exports/BatchExportScene.stories.tsx+++ b/frontend/src/scenes/data-pipelines/batch-exports/BatchExportScene.stories.tsx@@ -43,8 +43,8 @@ type Story = StoryObj<{}>// One new-export story per destination so visual regression covers each destination's// edit form (the per-destination `Fields` components in destinations/). The default-// configuration drives any conditional UI: Redshift defaults to COPY (shows the S3-// staging section), Snowflake to password auth.+// configuration drives any conditional UI: Redshift defaults to COPY, which shows the+// S3 staging section.export const NewAwsS3Export: Story = {parameters: {pageUrl: urls.batchExportNew('awss3'),diff --git a/frontend/src/scenes/data-pipelines/batch-exports/batchExportConfigFormLogic.test.ts b/frontend/src/scenes/data-pipelines/batch-exports/batchExportConfigFormLogic.test.tsindex 9d0b01ac14f5..f7c8c1fd1f34 100644--- a/frontend/src/scenes/data-pipelines/batch-exports/batchExportConfigFormLogic.test.ts+++ b/frontend/src/scenes/data-pipelines/batch-exports/batchExportConfigFormLogic.test.ts@@ -9,7 +9,7 @@ import { urls } from 'scenes/urls'import { useMocks } from '~/mocks/jest'import { MockResolverInfo } from '~/mocks/utils'import { initKeaTests } from '~/test/init'-import { BatchExportConfiguration } from '~/types'+import { BatchExportConfiguration, BatchExportServiceSnowflake } from '~/types'import {BatchExportConfigFormLogicProps,@@ -135,42 +135,43 @@ const POSTGRES_BATCH_EXPORT = fixture('fixture-postgres', 'Postgres Export', {},})-const SNOWFLAKE_PASSWORD_BATCH_EXPORT = fixture('fixture-snowflake-password', 'Snowflake Password Export', {+const SNOWFLAKE_BATCH_EXPORT = fixture('fixture-snowflake', 'Snowflake Export', {type: 'Snowflake',+ integration: 51,config: {- account: 'sf-account',database: 'sf-db',warehouse: 'sf-wh',- user: 'sf-user',- authentication_type: 'password',- password: 'sf-pass',- private_key: null,- private_key_passphrase: null,schema: 'public',table_name: 'events',- role: null,+ role: 'sf-role',exclude_events: [],include_events: [],},})-const SNOWFLAKE_KEYPAIR_BATCH_EXPORT = fixture('fixture-snowflake-keypair', 'Snowflake Keypair Export', {+// A migrated export: credentials moved to the integration, but the account and authentication+// values they came with are still in the stored config. The stale keys are deliberate.+const SNOWFLAKE_STALE_CONFIG = {+ database: 'sf-db',+ warehouse: 'sf-wh',+ schema: 'public',+ table_name: 'events',+ role: null,+ exclude_events: [],+ include_events: [],+ account: 'sf-account',+ user: 'sf-user',+ authentication_type: 'password',+ password: 'sf-pass',+ private_key: null,+ private_key_passphrase: null,+ // `satisfies` keeps the real fields checked; the index signature admits the stale keys.+} satisfies BatchExportServiceSnowflake['config'] & Record<string, unknown>++const SNOWFLAKE_STALE_BATCH_EXPORT = fixture('fixture-snowflake-stale', 'Snowflake Stale Export', {type: 'Snowflake',- config: {- account: 'sf-account',- database: 'sf-db',- warehouse: 'sf-wh',- user: 'sf-user',- authentication_type: 'keypair',- password: null,- private_key: 'priv-key',- private_key_passphrase: 'priv-pass',- schema: 'public',- table_name: 'events',- role: null,- exclude_events: [],- include_events: [],- },+ integration: 51,+ config: SNOWFLAKE_STALE_CONFIG,})// Note: `authorization_mode` is intentionally absent from these Redshift fixtures' config —@@ -380,8 +381,8 @@ const ALL_BATCH_EXPORTS: BatchExportConfiguration[] = [BIGQUERY_BATCH_EXPORT,BIGQUERY_STALE_BATCH_EXPORT,POSTGRES_BATCH_EXPORT,- SNOWFLAKE_PASSWORD_BATCH_EXPORT,- SNOWFLAKE_KEYPAIR_BATCH_EXPORT,+ SNOWFLAKE_BATCH_EXPORT,+ SNOWFLAKE_STALE_BATCH_EXPORT,REDSHIFT_INSERT_BATCH_EXPORT,REDSHIFT_NO_MODE_BATCH_EXPORT,REDSHIFT_COPY_IAM_BATCH_EXPORT,@@ -1294,8 +1295,7 @@ describe('batchExportConfigFormLogic', () => {{ name: 'S3Compatible', fixture: S3_COMPATIBLE_BATCH_EXPORT },{ name: 'BigQuery', fixture: BIGQUERY_BATCH_EXPORT },{ name: 'Postgres', fixture: POSTGRES_BATCH_EXPORT },- { name: 'Snowflake (password)', fixture: SNOWFLAKE_PASSWORD_BATCH_EXPORT },- { name: 'Snowflake (keypair)', fixture: SNOWFLAKE_KEYPAIR_BATCH_EXPORT },+ { name: 'Snowflake', fixture: SNOWFLAKE_BATCH_EXPORT },{ name: 'Redshift (INSERT)', fixture: REDSHIFT_INSERT_BATCH_EXPORT },{ name: 'Redshift (COPY + IAM)', fixture: REDSHIFT_COPY_IAM_BATCH_EXPORT },{ name: 'Redshift (COPY + Credentials)', fixture: REDSHIFT_COPY_CREDENTIALS_BATCH_EXPORT },@@ -1320,11 +1320,44 @@ describe('batchExportConfigFormLogic', () => {})describe('strips stale/legacy config fields not in the destination allowlist', () => {- // Pre-Integration BigQuery configs can still hold json_config_file + credential fields.+ // Pre-Integration configs can still hold credential fields that now live on the integration.// Editing such an export must not re-send them, or the backend rejects the PATCH with// "Configuration has unknown field/s".- it('drops pre-Integration BigQuery fields from the PATCH payload', async () => {- await initLogic({ service: null, id: BIGQUERY_STALE_BATCH_EXPORT.id })+ it.each([+ {+ name: 'BigQuery drops json_config_file and inline credentials',+ fixture: BIGQUERY_STALE_BATCH_EXPORT,+ expectedDestination: {+ type: 'BigQuery',+ integration: 7,+ config: {+ dataset_id: 'test_dataset',+ table_id: 'events',+ use_json_type: false,+ exclude_events: [],+ include_events: [],+ },+ },+ },+ {+ name: 'Snowflake drops the account and credentials left behind by the migration',+ fixture: SNOWFLAKE_STALE_BATCH_EXPORT,+ expectedDestination: {+ type: 'Snowflake',+ integration: 51,+ config: {+ database: 'sf-db',+ warehouse: 'sf-wh',+ schema: 'public',+ table_name: 'events',+ role: null,+ exclude_events: [],+ include_events: [],+ },+ },+ },+ ])('$name', async ({ fixture, expectedDestination }) => {+ await initLogic({ service: null, id: fixture.id })await expectLogic(logic, () => {logic.actions.submitConfiguration()@@ -1332,15 +1365,9 @@ describe('batchExportConfigFormLogic', () => {.toDispatchActions(['submitConfiguration', 'updateBatchExportConfigSuccess']).toFinishAllListeners()- const body = patchBodiesById[BIGQUERY_STALE_BATCH_EXPORT.id]+ const body = patchBodiesById[fixture.id]expect(body).not.toBeUndefined()- expect(body.destination.config).toEqual({- dataset_id: 'test_dataset',- table_id: 'events',- use_json_type: false,- exclude_events: [],- include_events: [],- })+ expect(body.destination).toEqual(expectedDestination)})})})diff --git a/frontend/src/scenes/data-pipelines/batch-exports/batchExportConfigFormLogic.tsx b/frontend/src/scenes/data-pipelines/batch-exports/batchExportConfigFormLogic.tsxindex e91255c35822..b13805a1f3f5 100644--- a/frontend/src/scenes/data-pipelines/batch-exports/batchExportConfigFormLogic.tsx+++ b/frontend/src/scenes/data-pipelines/batch-exports/batchExportConfigFormLogic.tsx@@ -113,7 +113,6 @@ function getConfigurationFromBatchExportConfig(batchExportConfig: BatchExportCon}if (definition?.usesIntegration) {- // Only the integration-backed destinations (Databricks, AzureBlob, BigQuery) carry this field.config.integration_id = (batchExportConfig.destination as { integration?: number }).integration}diff --git a/frontend/src/scenes/data-pipelines/batch-exports/destinations/snowflake.tsx b/frontend/src/scenes/data-pipelines/batch-exports/destinations/snowflake.tsxindex 898fb82aedc0..f4a29f33f648 100644--- a/frontend/src/scenes/data-pipelines/batch-exports/destinations/snowflake.tsx+++ b/frontend/src/scenes/data-pipelines/batch-exports/destinations/snowflake.tsx@@ -1,4 +1,4 @@-import { LemonBanner, LemonInput, LemonSelect, LemonTextArea } from '@posthog/lemon-ui'+import { LemonInput } from '@posthog/lemon-ui'import { IntegrationChoice } from 'lib/components/CyclotronJob/integrations/IntegrationChoice'import { LemonField } from 'lib/lemon-ui/LemonField'@@ -6,35 +6,13 @@ import { LemonField } from 'lib/lemon-ui/LemonField'import { PERSON_PROPERTIES_EVENT_FIELD } from './common'import type { DestinationDefinition } from './types'-// New Snowflake exports must store credentials in a linked Integration. Exports created before-// integrations existed keep their inline credentials (grandfathered), detected by integration_id.+// Credentials come from a linked `snowflake` Integration, never from this destination's config.export const snowflakeDefinition: DestinationDefinition = {type: 'Snowflake',usesIntegration: true,defaults: () => ({}),- requiredFields: ({ isNew, formValues }) => {- if (isNew || formValues.integration_id) {- // New exports must pick an integration; existing integration-backed exports keep theirs.- return [...(isNew ? ['integration_id'] : []), 'database', 'warehouse', 'schema', 'table_name']- }- // Grandfathered inline-credential exports keep their original fields when edited.- return ['account', 'database', 'warehouse', 'schema', 'table_name']- },- // The credential keys remain allowlisted for grandfathered inline exports.- // TODO: clean up once fully migrated to integration-based credentials- configKeys: [- 'database',- 'warehouse',- 'schema',- 'table_name',- 'role',- 'account',- 'user',- 'authentication_type',- 'password',- 'private_key',- 'private_key_passphrase',- ],+ requiredFields: () => ['integration_id', 'database', 'warehouse', 'schema', 'table_name'],+ configKeys: ['database', 'warehouse', 'schema', 'table_name', 'role'],eventTableOverrides: {setName: 'people_set',setOnceName: 'people_set_once',@@ -48,64 +26,14 @@ export const snowflakeDefinition: DestinationDefinition = {schema_valid: true,},},- Fields: function SnowflakeFields({ isNew, formValues }) {- const useIntegration = isNew || !!formValues.integration_id-+ Fields: function SnowflakeFields() {return (<>- {useIntegration ? (- <LemonField name="integration_id" label="Connection">- {({ value, onChange }) => (- <IntegrationChoice integration="snowflake" value={value} onChange={onChange} />- )}- </LemonField>- ) : (- <>- <LemonBanner type="warning">- Snowflake batch exports are moving to integration-based credentials. This export will be- migrated automatically — no action required.- </LemonBanner>-- <LemonField name="account" label="Account">- <LemonInput placeholder="my-account" />- </LemonField>-- <LemonField name="user" label="User">- <LemonInput placeholder={isNew ? 'my-user' : 'Leave unchanged'} />- </LemonField>-- <LemonField name="authentication_type" label="Authentication type" className="flex-1">- <LemonSelect- options={[- { value: 'password', label: 'Password' },- { value: 'keypair', label: 'Key pair' },- ]}- />- </LemonField>-- {formValues.authentication_type != 'keypair' && (- <LemonField name="password" label="Password">- <LemonInput placeholder={isNew ? 'my-password' : 'Leave unchanged'} type="password" />- </LemonField>- )}-- {formValues.authentication_type == 'keypair' && (- <>- <LemonField name="private_key" label="Private key">- <LemonTextArea- className="ph-ignore-input"- placeholder={isNew ? 'my-private-key' : 'Leave unchanged'}- minRows={4}- />- </LemonField>-- <LemonField name="private_key_passphrase" label="Private key passphrase">- <LemonInput placeholder={isNew ? 'my-passphrase' : 'Leave unchanged'} />- </LemonField>- </>- )}- </>- )}+ <LemonField name="integration_id" label="Connection">+ {({ value, onChange }) => (+ <IntegrationChoice integration="snowflake" value={value} onChange={onChange} />+ )}+ </LemonField><LemonField name="database" label="Database"><LemonInput placeholder="my-database" />diff --git a/frontend/src/types.ts b/frontend/src/types.tsindex 9576c897e39b..8fdc7a6bde80 100644--- a/frontend/src/types.ts+++ b/frontend/src/types.ts@@ -6835,18 +6835,13 @@ export type BatchExportServicePostgres = {}}+// Credentials live on the linked `snowflake` integration, not in the config.export type BatchExportServiceSnowflake = {type: 'Snowflake'- integration?: number+ integration: numberconfig: {- account: stringdatabase: stringwarehouse: string- user: string- authentication_type: 'password' | 'keypair'- password: string | null- private_key: string | null- private_key_passphrase: string | nullschema: stringtable_name: stringrole: string | null