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(data-warehouse): offer every destination type, on a per-type form (#104314)

Tom Owersfabf465d79ae
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index 7143c57eb367..d6439b85fb19 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -2512,6 +2512,30 @@ snapshots:
hash: v1.k794b7964.9b522de92c0ec0977626e3e694a64ceceda80fa691f50c490c906a06b012d0dd.ai1KpccNrHIv4qosfkQoeeTHQ1hkIw2rvoNF7Q3Yriw
data-warehouse-destinationlist--only-one-left--light:
hash: v1.k794b7964.e73d80636fa8aec2163ca81b6615ab5ae432296f391a74623cda19d1ab34f542.RCgSTjXC1oN6_ir0V3CST_szMCiJdf6beKhAr2rg4wA
+ data-warehouse-destinationmodal--azure-blob--dark:
+ hash: v1.k794b7964.59e2fab0e54439f87a02d90e578b6fc21984cfc817f576ad58ec2d941cdb224b.A4nwKDTtbyovK35VoGF_AGLHAF5LjiPQ6z4H8-22DVc
+ data-warehouse-destinationmodal--azure-blob--light:
+ hash: v1.k794b7964.4cd724ead6b52e96f103f01162624d8f31b31d884ac6a9e43c0b6d1825a46eff.ZBzac6NoxhO7gtMu2exFy6kAjIAiPH08ZNI7AKgvl_A
+ data-warehouse-destinationmodal--big-query--dark:
+ hash: v1.k794b7964.a185426152cd2eefc7f50d49912520d31c80bae794a3fa07325a79ed83ab2e32.EbAE045p1rUEWTAbBKaFubM7_Ssb0-9uowfBM7EY_cU
+ data-warehouse-destinationmodal--big-query--light:
+ hash: v1.k794b7964.a41935447297354c0fe7697c937ced69ee3073eb979dd167bf062743e0b10c5e.AuPDAoceAzaHLoPcX4VImFk7DfB0CevOa5HS-_7zk4o
+ data-warehouse-destinationmodal--databricks--dark:
+ hash: v1.k794b7964.91975ae27dd69fb9465cb84bbff2ba084313541d380541f8d8ee8c4aedf45de4.S3TVRhODbqvLS-OcpZsq3HvfqFFeYIpcfHtEBVO_ghE
+ data-warehouse-destinationmodal--databricks--light:
+ hash: v1.k794b7964.7f84c65a10aea7bce2c47cf5c4984a2750601b689da8ea04c29c1ab985719435.FF-pk8-lulV2IqhCtv8DH91m0WZOqPUFWMmRMxfE_iE
+ data-warehouse-destinationmodal--postgres--dark:
+ hash: v1.k794b7964.fe4729f4888a31a88d34234f5d0484ec38df2910cc050491fd2b11c6cf591333.xn76IebXOqhc9cHZNGglZUsZkecXZO4nnLhKSQWDXsg
+ data-warehouse-destinationmodal--postgres--light:
+ hash: v1.k794b7964.f5bbe7628ca1ad481ea49e6df6441ccec163983d873ff79f59a4ba253ca20997.qC6cZNKKCuBBla1I0nqaTw2LXpWZzUSEOuJ7m_-1WKY
+ data-warehouse-destinationmodal--s-3--dark:
+ hash: v1.k794b7964.047b5d2ff2ec1f036597c97986ca49a88703b6d0daa96a956adb2c9b184e5734.SF1vX1S2ZEHKCE4ghm96v1Hkz1AZJ3z6CTzm2Q8weFI
+ data-warehouse-destinationmodal--s-3--light:
+ hash: v1.k794b7964.69625aa4ffdcb98a994d8df27fd1ace236385fb64d38675b7d6d2b647e3d8e61.ZH5EQtJDOyH8avPcoTvnw-PTU6xSq4YQLJZp8JGm1VQ
+ data-warehouse-destinationmodal--snowflake--dark:
+ hash: v1.k794b7964.70a484a9907ad034381372cde9378f830f494ac5ded07894faf4c6ab9b8d705e.kiu1wO_66K6dUaEs1jKs-aXxp4drOBGsTFMAgZoS7Sg
+ data-warehouse-destinationmodal--snowflake--light:
+ hash: v1.k794b7964.03ecd38de36bb76f10b1dc4710300abeb3f4abffe583341dd0d213645642198a.gMVHyFvdNFswxvTt9985i73PKjiYblShjpfcxV-J8BI
data-warehouse-jobdestinations--destination-since-deleted--dark:
hash: v1.k794b7964.7850b437d0b757b20409473a16858b9ef875f35021e592521bdf94b2876e85c5.ix5aXJkl2sMIrSYeEmiT_OgH7Eb94qxUEEAt_DvutJk
data-warehouse-jobdestinations--destination-since-deleted--light:
diff --git a/frontend/src/lib/integrations/s3Regions.ts b/frontend/src/lib/integrations/s3Regions.ts
new file mode 100644
index 000000000000..0225fae9748f
--- /dev/null
+++ b/frontend/src/lib/integrations/s3Regions.ts
@@ -0,0 +1,131 @@
+// Shared by batch exports and warehouse destinations: a region in one list but not the other
+// fails only at connect time.
+
+// S3-family region list spanning AWS, Google Cloud Storage, Cloudflare R2, and OVHcloud. Non-AWS
+// entries are prefixed with their provider; AWS-style codes are left bare because S3-compatible
+// providers (MinIO, Wasabi, etc.) commonly reuse them (e.g. `us-east-1`) as a default region.
+export const S3_REGION_OPTIONS: { value: string; label: string }[] = [
+ // AWS
+ { value: 'us-east-1', label: 'US East (N. Virginia)' },
+ { value: 'us-east-2', label: 'US East (Ohio)' },
+ { value: 'us-west-1', label: 'US West (N. California)' },
+ { value: 'us-west-2', label: 'US West (Oregon)' },
+ { value: 'af-south-1', label: 'Africa (Cape Town)' },
+ { value: 'ap-east-1', label: 'Asia Pacific (Hong Kong)' },
+ { value: 'ap-south-1', label: 'Asia Pacific (Mumbai)' },
+ { value: 'ap-northeast-3', label: 'Asia Pacific (Osaka-Local)' },
+ { value: 'ap-northeast-2', label: 'Asia Pacific (Seoul)' },
+ { value: 'ap-southeast-1', label: 'Asia Pacific (Singapore)' },
+ { value: 'ap-southeast-2', label: 'Asia Pacific (Sydney)' },
+ { value: 'ap-northeast-1', label: 'Asia Pacific (Tokyo)' },
+ { value: 'ca-central-1', label: 'Canada (Central)' },
+ { value: 'cn-north-1', label: 'China (Beijing)' },
+ { value: 'cn-northwest-1', label: 'China (Ningxia)' },
+ { value: 'eu-central-1', label: 'Europe (Frankfurt)' },
+ { value: 'eu-west-1', label: 'Europe (Ireland)' },
+ { value: 'eu-west-2', label: 'Europe (London)' },
+ { value: 'eu-south-1', label: 'Europe (Milan)' },
+ { value: 'eu-west-3', label: 'Europe (Paris)' },
+ { value: 'eu-north-1', label: 'Europe (Stockholm)' },
+ { value: 'me-east-1', label: 'Middle East (Dubai)' },
+ { value: 'me-south-1', label: 'Middle East (Bahrain)' },
+ { value: 'me-central-1', label: 'Middle East (Riyadh)' },
+ { value: 'sa-east-1', label: 'South America (São Paulo)' },
+ // Google Cloud Storage (via the S3-compatible XML API). https://docs.cloud.google.com/storage/docs/locations
+ { value: 'northamerica-northeast1', label: 'GCP — Montréal (northamerica-northeast1)' },
+ { value: 'northamerica-northeast2', label: 'GCP — Toronto (northamerica-northeast2)' },
+ { value: 'northamerica-south1', label: 'GCP — Querétaro (northamerica-south1)' },
+ { value: 'us-central1', label: 'GCP — Iowa (us-central1)' },
+ { value: 'us-east1', label: 'GCP — South Carolina (us-east1)' },
+ { value: 'us-east4', label: 'GCP — Northern Virginia (us-east4)' },
+ { value: 'us-east5', label: 'GCP — Columbus (us-east5)' },
+ { value: 'us-south1', label: 'GCP — Dallas (us-south1)' },
+ { value: 'us-west1', label: 'GCP — Oregon (us-west1)' },
+ { value: 'us-west2', label: 'GCP — Los Angeles (us-west2)' },
+ { value: 'us-west3', label: 'GCP — Salt Lake City (us-west3)' },
+ { value: 'us-west4', label: 'GCP — Las Vegas (us-west4)' },
+ { value: 'southamerica-east1', label: 'GCP — São Paulo (southamerica-east1)' },
+ { value: 'southamerica-west1', label: 'GCP — Santiago (southamerica-west1)' },
+ { value: 'europe-central2', label: 'GCP — Warsaw (europe-central2)' },
+ { value: 'europe-north1', label: 'GCP — Finland (europe-north1)' },
+ { value: 'europe-north2', label: 'GCP — Stockholm (europe-north2)' },
+ { value: 'europe-southwest1', label: 'GCP — Madrid (europe-southwest1)' },
+ { value: 'europe-west1', label: 'GCP — Belgium (europe-west1)' },
+ { value: 'europe-west2', label: 'GCP — London (europe-west2)' },
+ { value: 'europe-west3', label: 'GCP — Frankfurt (europe-west3)' },
+ { value: 'europe-west4', label: 'GCP — Netherlands (europe-west4)' },
+ { value: 'europe-west6', label: 'GCP — Zürich (europe-west6)' },
+ { value: 'europe-west8', label: 'GCP — Milan (europe-west8)' },
+ { value: 'europe-west9', label: 'GCP — Paris (europe-west9)' },
+ { value: 'europe-west10', label: 'GCP — Berlin (europe-west10)' },
+ { value: 'europe-west12', label: 'GCP — Turin (europe-west12)' },
+ { value: 'asia-east1', label: 'GCP — Taiwan (asia-east1)' },
+ { value: 'asia-east2', label: 'GCP — Hong Kong (asia-east2)' },
+ { value: 'asia-northeast1', label: 'GCP — Tokyo (asia-northeast1)' },
+ { value: 'asia-northeast2', label: 'GCP — Osaka (asia-northeast2)' },
+ { value: 'asia-northeast3', label: 'GCP — Seoul (asia-northeast3)' },
+ { value: 'asia-south1', label: 'GCP — Mumbai (asia-south1)' },
+ { value: 'asia-south2', label: 'GCP — Delhi (asia-south2)' },
+ { value: 'asia-southeast1', label: 'GCP — Singapore (asia-southeast1)' },
+ { value: 'asia-southeast2', label: 'GCP — Jakarta (asia-southeast2)' },
+ { value: 'asia-southeast3', label: 'GCP — Bangkok (asia-southeast3)' },
+ { value: 'me-central1', label: 'GCP — Doha (me-central1)' },
+ { value: 'me-central2', label: 'GCP — Dammam (me-central2)' },
+ { value: 'me-west1', label: 'GCP — Tel Aviv (me-west1)' },
+ { value: 'australia-southeast1', label: 'GCP — Sydney (australia-southeast1)' },
+ { value: 'australia-southeast2', label: 'GCP — Melbourne (australia-southeast2)' },
+ { value: 'africa-south1', label: 'GCP — Johannesburg (africa-south1)' },
+ { value: 'US', label: 'GCP — US (multi-region)' },
+ { value: 'EU', label: 'GCP — EU (multi-region)' },
+ { value: 'ASIA', label: 'GCP — Asia (multi-region)' },
+ // Cloudflare R2 (location hints)
+ { value: 'auto', label: 'Cloudflare R2 — Automatic (AUTO)' },
+ { value: 'apac', label: 'Cloudflare R2 — Asia Pacific (APAC)' },
+ { value: 'eeur', label: 'Cloudflare R2 — Eastern Europe (EEUR)' },
+ { value: 'enam', label: 'Cloudflare R2 — Eastern North America (ENAM)' },
+ { value: 'oc', label: 'Cloudflare R2 — Oceania (OC)' },
+ { value: 'weur', label: 'Cloudflare R2 — Western Europe (WEUR)' },
+ { value: 'wnam', label: 'Cloudflare R2 — Western North America (WNAM)' },
+ // OVHcloud
+ { value: 'gra', label: 'OVH — Gravelines (GRA)' },
+ { value: 'rbx', label: 'OVH — Roubaix (RBX)' },
+ { value: 'sbg', label: 'OVH — Strasbourg (SBG)' },
+ { value: 'eu-west-par', label: 'OVH — Paris (PAR)' },
+ { value: 'eu-south-mil', label: 'OVH — Milan (MIL)' },
+ { value: 'de', label: 'OVH — Frankfurt (DE)' },
+ { value: 'uk', label: 'OVH — London (UK)' },
+ { value: 'waw', label: 'OVH — Warsaw (WAW)' },
+ { value: 'bhs', label: 'OVH — Beauharnois (BHS)' },
+ { value: 'ca-east-tor', label: 'OVH — Toronto (TOR)' },
+ { value: 'sgp', label: 'OVH — Singapore (SGP)' },
+ { value: 'ap-southeast-syd', label: 'OVH — Sydney (SYD)' },
+ { value: 'ap-south-mum', label: 'OVH — Mumbai (MUM)' },
+]
+
+// AWS-only region subset used for the Redshift COPY S3 staging bucket.
+export const AWS_ONLY_REGION_OPTIONS: { value: string; label: string }[] = [
+ { value: 'us-east-1', label: 'US East (N. Virginia)' },
+ { value: 'us-east-2', label: 'US East (Ohio)' },
+ { value: 'us-west-1', label: 'US West (N. California)' },
+ { value: 'us-west-2', label: 'US West (Oregon)' },
+ { value: 'af-south-1', label: 'Africa (Cape Town)' },
+ { value: 'ap-east-1', label: 'Asia Pacific (Hong Kong)' },
+ { value: 'ap-south-1', label: 'Asia Pacific (Mumbai)' },
+ { value: 'ap-northeast-3', label: 'Asia Pacific (Osaka-Local)' },
+ { value: 'ap-northeast-2', label: 'Asia Pacific (Seoul)' },
+ { value: 'ap-southeast-1', label: 'Asia Pacific (Singapore)' },
+ { value: 'ap-southeast-2', label: 'Asia Pacific (Sydney)' },
+ { value: 'ap-northeast-1', label: 'Asia Pacific (Tokyo)' },
+ { value: 'ca-central-1', label: 'Canada (Central)' },
+ { value: 'cn-north-1', label: 'China (Beijing)' },
+ { value: 'cn-northwest-1', label: 'China (Ningxia)' },
+ { value: 'eu-central-1', label: 'Europe (Frankfurt)' },
+ { value: 'eu-west-1', label: 'Europe (Ireland)' },
+ { value: 'eu-west-2', label: 'Europe (London)' },
+ { value: 'eu-south-1', label: 'Europe (Milan)' },
+ { value: 'eu-west-3', label: 'Europe (Paris)' },
+ { value: 'eu-north-1', label: 'Europe (Stockholm)' },
+ { value: 'me-south-1', label: 'Middle East (Bahrain)' },
+ { value: 'me-central-1', label: 'Middle East (Riyadh)' },
+ { value: 'sa-east-1', label: 'South America (São Paulo)' },
+]
diff --git a/frontend/src/scenes/data-pipelines/batch-exports/destinations/awss3.tsx b/frontend/src/scenes/data-pipelines/batch-exports/destinations/awss3.tsx
index ce00f90a0822..02ef747f74db 100644
--- a/frontend/src/scenes/data-pipelines/batch-exports/destinations/awss3.tsx
+++ b/frontend/src/scenes/data-pipelines/batch-exports/destinations/awss3.tsx
@@ -1,9 +1,6 @@
-import {
- AWS_ONLY_REGION_OPTIONS,
- S3FamilyFields,
- S3_FAMILY_EVENT_TABLE_EXTRA_FIELDS,
- validateBucketName,
-} from './common'
+import { AWS_ONLY_REGION_OPTIONS } from 'lib/integrations/s3Regions'
+
+import { S3FamilyFields, S3_FAMILY_EVENT_TABLE_EXTRA_FIELDS, validateBucketName } from './common'
import type { DestinationDefinition } from './types'
// AWS S3 — the first-class destination for buckets hosted on AWS. No endpoint or virtual-style
diff --git a/frontend/src/scenes/data-pipelines/batch-exports/destinations/common.tsx b/frontend/src/scenes/data-pipelines/batch-exports/destinations/common.tsx
index 43b7f4e306da..312f361d8130 100644
--- a/frontend/src/scenes/data-pipelines/batch-exports/destinations/common.tsx
+++ b/frontend/src/scenes/data-pipelines/batch-exports/destinations/common.tsx
@@ -54,135 +54,6 @@ export function validateAzureContainerName(name: string | undefined): string | u
return undefined
}
-// S3-family region list spanning AWS, Google Cloud Storage, Cloudflare R2, and OVHcloud. Non-AWS
-// entries are prefixed with their provider; AWS-style codes are left bare because S3-compatible
-// providers (MinIO, Wasabi, etc.) commonly reuse them (e.g. `us-east-1`) as a default region.
-export const S3_REGION_OPTIONS: { value: string; label: string }[] = [
- // AWS
- { value: 'us-east-1', label: 'US East (N. Virginia)' },
- { value: 'us-east-2', label: 'US East (Ohio)' },
- { value: 'us-west-1', label: 'US West (N. California)' },
- { value: 'us-west-2', label: 'US West (Oregon)' },
- { value: 'af-south-1', label: 'Africa (Cape Town)' },
- { value: 'ap-east-1', label: 'Asia Pacific (Hong Kong)' },
- { value: 'ap-south-1', label: 'Asia Pacific (Mumbai)' },
- { value: 'ap-northeast-3', label: 'Asia Pacific (Osaka-Local)' },
- { value: 'ap-northeast-2', label: 'Asia Pacific (Seoul)' },
- { value: 'ap-southeast-1', label: 'Asia Pacific (Singapore)' },
- { value: 'ap-southeast-2', label: 'Asia Pacific (Sydney)' },
- { value: 'ap-northeast-1', label: 'Asia Pacific (Tokyo)' },
- { value: 'ca-central-1', label: 'Canada (Central)' },
- { value: 'cn-north-1', label: 'China (Beijing)' },
- { value: 'cn-northwest-1', label: 'China (Ningxia)' },
- { value: 'eu-central-1', label: 'Europe (Frankfurt)' },
- { value: 'eu-west-1', label: 'Europe (Ireland)' },
- { value: 'eu-west-2', label: 'Europe (London)' },
- { value: 'eu-south-1', label: 'Europe (Milan)' },
- { value: 'eu-west-3', label: 'Europe (Paris)' },
- { value: 'eu-north-1', label: 'Europe (Stockholm)' },
- { value: 'me-east-1', label: 'Middle East (Dubai)' },
- { value: 'me-south-1', label: 'Middle East (Bahrain)' },
- { value: 'me-central-1', label: 'Middle East (Riyadh)' },
- { value: 'sa-east-1', label: 'South America (São Paulo)' },
- // Google Cloud Storage (via the S3-compatible XML API). https://docs.cloud.google.com/storage/docs/locations
- { value: 'northamerica-northeast1', label: 'GCP — Montréal (northamerica-northeast1)' },
- { value: 'northamerica-northeast2', label: 'GCP — Toronto (northamerica-northeast2)' },
- { value: 'northamerica-south1', label: 'GCP — Querétaro (northamerica-south1)' },
- { value: 'us-central1', label: 'GCP — Iowa (us-central1)' },
- { value: 'us-east1', label: 'GCP — South Carolina (us-east1)' },
- { value: 'us-east4', label: 'GCP — Northern Virginia (us-east4)' },
- { value: 'us-east5', label: 'GCP — Columbus (us-east5)' },
- { value: 'us-south1', label: 'GCP — Dallas (us-south1)' },
- { value: 'us-west1', label: 'GCP — Oregon (us-west1)' },
- { value: 'us-west2', label: 'GCP — Los Angeles (us-west2)' },
- { value: 'us-west3', label: 'GCP — Salt Lake City (us-west3)' },
- { value: 'us-west4', label: 'GCP — Las Vegas (us-west4)' },
- { value: 'southamerica-east1', label: 'GCP — São Paulo (southamerica-east1)' },
- { value: 'southamerica-west1', label: 'GCP — Santiago (southamerica-west1)' },
- { value: 'europe-central2', label: 'GCP — Warsaw (europe-central2)' },
- { value: 'europe-north1', label: 'GCP — Finland (europe-north1)' },
- { value: 'europe-north2', label: 'GCP — Stockholm (europe-north2)' },
- { value: 'europe-southwest1', label: 'GCP — Madrid (europe-southwest1)' },
- { value: 'europe-west1', label: 'GCP — Belgium (europe-west1)' },
- { value: 'europe-west2', label: 'GCP — London (europe-west2)' },
- { value: 'europe-west3', label: 'GCP — Frankfurt (europe-west3)' },
- { value: 'europe-west4', label: 'GCP — Netherlands (europe-west4)' },
- { value: 'europe-west6', label: 'GCP — Zürich (europe-west6)' },
- { value: 'europe-west8', label: 'GCP — Milan (europe-west8)' },
- { value: 'europe-west9', label: 'GCP — Paris (europe-west9)' },
- { value: 'europe-west10', label: 'GCP — Berlin (europe-west10)' },
- { value: 'europe-west12', label: 'GCP — Turin (europe-west12)' },
- { value: 'asia-east1', label: 'GCP — Taiwan (asia-east1)' },
- { value: 'asia-east2', label: 'GCP — Hong Kong (asia-east2)' },
- { value: 'asia-northeast1', label: 'GCP — Tokyo (asia-northeast1)' },
- { value: 'asia-northeast2', label: 'GCP — Osaka (asia-northeast2)' },
- { value: 'asia-northeast3', label: 'GCP — Seoul (asia-northeast3)' },
- { value: 'asia-south1', label: 'GCP — Mumbai (asia-south1)' },
- { value: 'asia-south2', label: 'GCP — Delhi (asia-south2)' },
- { value: 'asia-southeast1', label: 'GCP — Singapore (asia-southeast1)' },
- { value: 'asia-southeast2', label: 'GCP — Jakarta (asia-southeast2)' },
- { value: 'asia-southeast3', label: 'GCP — Bangkok (asia-southeast3)' },
- { value: 'me-central1', label: 'GCP — Doha (me-central1)' },
- { value: 'me-central2', label: 'GCP — Dammam (me-central2)' },
- { value: 'me-west1', label: 'GCP — Tel Aviv (me-west1)' },
- { value: 'australia-southeast1', label: 'GCP — Sydney (australia-southeast1)' },
- { value: 'australia-southeast2', label: 'GCP — Melbourne (australia-southeast2)' },
- { value: 'africa-south1', label: 'GCP — Johannesburg (africa-south1)' },
- { value: 'US', label: 'GCP — US (multi-region)' },
- { value: 'EU', label: 'GCP — EU (multi-region)' },
- { value: 'ASIA', label: 'GCP — Asia (multi-region)' },
- // Cloudflare R2 (location hints)
- { value: 'auto', label: 'Cloudflare R2 — Automatic (AUTO)' },
- { value: 'apac', label: 'Cloudflare R2 — Asia Pacific (APAC)' },
- { value: 'eeur', label: 'Cloudflare R2 — Eastern Europe (EEUR)' },
- { value: 'enam', label: 'Cloudflare R2 — Eastern North America (ENAM)' },
- { value: 'oc', label: 'Cloudflare R2 — Oceania (OC)' },
- { value: 'weur', label: 'Cloudflare R2 — Western Europe (WEUR)' },
- { value: 'wnam', label: 'Cloudflare R2 — Western North America (WNAM)' },
- // OVHcloud
- { value: 'gra', label: 'OVH — Gravelines (GRA)' },
- { value: 'rbx', label: 'OVH — Roubaix (RBX)' },
- { value: 'sbg', label: 'OVH — Strasbourg (SBG)' },
- { value: 'eu-west-par', label: 'OVH — Paris (PAR)' },
- { value: 'eu-south-mil', label: 'OVH — Milan (MIL)' },
- { value: 'de', label: 'OVH — Frankfurt (DE)' },
- { value: 'uk', label: 'OVH — London (UK)' },
- { value: 'waw', label: 'OVH — Warsaw (WAW)' },
- { value: 'bhs', label: 'OVH — Beauharnois (BHS)' },
- { value: 'ca-east-tor', label: 'OVH — Toronto (TOR)' },
- { value: 'sgp', label: 'OVH — Singapore (SGP)' },
- { value: 'ap-southeast-syd', label: 'OVH — Sydney (SYD)' },
- { value: 'ap-south-mum', label: 'OVH — Mumbai (MUM)' },
-]
-
-// AWS-only region subset used for the Redshift COPY S3 staging bucket.
-export const AWS_ONLY_REGION_OPTIONS: { value: string; label: string }[] = [
- { value: 'us-east-1', label: 'US East (N. Virginia)' },
- { value: 'us-east-2', label: 'US East (Ohio)' },
- { value: 'us-west-1', label: 'US West (N. California)' },
- { value: 'us-west-2', label: 'US West (Oregon)' },
- { value: 'af-south-1', label: 'Africa (Cape Town)' },
- { value: 'ap-east-1', label: 'Asia Pacific (Hong Kong)' },
- { value: 'ap-south-1', label: 'Asia Pacific (Mumbai)' },
- { value: 'ap-northeast-3', label: 'Asia Pacific (Osaka-Local)' },
- { value: 'ap-northeast-2', label: 'Asia Pacific (Seoul)' },
- { value: 'ap-southeast-1', label: 'Asia Pacific (Singapore)' },
- { value: 'ap-southeast-2', label: 'Asia Pacific (Sydney)' },
- { value: 'ap-northeast-1', label: 'Asia Pacific (Tokyo)' },
- { value: 'ca-central-1', label: 'Canada (Central)' },
- { value: 'cn-north-1', label: 'China (Beijing)' },
- { value: 'cn-northwest-1', label: 'China (Ningxia)' },
- { value: 'eu-central-1', label: 'Europe (Frankfurt)' },
- { value: 'eu-west-1', label: 'Europe (Ireland)' },
- { value: 'eu-west-2', label: 'Europe (London)' },
- { value: 'eu-south-1', label: 'Europe (Milan)' },
- { value: 'eu-west-3', label: 'Europe (Paris)' },
- { value: 'eu-north-1', label: 'Europe (Stockholm)' },
- { value: 'me-south-1', label: 'Middle East (Bahrain)' },
- { value: 'me-central-1', label: 'Middle East (Riyadh)' },
- { value: 'sa-east-1', label: 'South America (São Paulo)' },
-]
-
export const FILE_FORMAT_OPTIONS: { value: string; label: string }[] = [
{ value: 'Parquet', label: 'Apache Parquet' },
{ value: 'JSONLines', label: 'JSON lines' },
diff --git a/frontend/src/scenes/data-pipelines/batch-exports/destinations/redshift.tsx b/frontend/src/scenes/data-pipelines/batch-exports/destinations/redshift.tsx
index 23b833b1ce4d..420ce4a876d4 100644
--- a/frontend/src/scenes/data-pipelines/batch-exports/destinations/redshift.tsx
+++ b/frontend/src/scenes/data-pipelines/batch-exports/destinations/redshift.tsx
@@ -1,11 +1,12 @@
import { LemonBanner, LemonInput, LemonSelect } from '@posthog/lemon-ui'
import { IntegrationChoice } from 'lib/components/CyclotronJob/integrations/IntegrationChoice'
+import { AWS_ONLY_REGION_OPTIONS } from 'lib/integrations/s3Regions'
import { LemonField } from 'lib/lemon-ui/LemonField'
import type { IntegrationType } from '~/types'
-import { AWS_ONLY_REGION_OPTIONS, PERSON_PROPERTIES_EVENT_FIELD, validateBucketName } from './common'
+import { PERSON_PROPERTIES_EVENT_FIELD, validateBucketName } from './common'
import type { DestinationDefinition } from './types'
// Redshift is the only destination with a non-trivial form ↔ payload mapping.
diff --git a/frontend/src/scenes/data-pipelines/batch-exports/destinations/s3compatible.tsx b/frontend/src/scenes/data-pipelines/batch-exports/destinations/s3compatible.tsx
index df221405d823..1c9368780b36 100644
--- a/frontend/src/scenes/data-pipelines/batch-exports/destinations/s3compatible.tsx
+++ b/frontend/src/scenes/data-pipelines/batch-exports/destinations/s3compatible.tsx
@@ -1,4 +1,6 @@
-import { S3FamilyFields, S3_FAMILY_EVENT_TABLE_EXTRA_FIELDS, S3_REGION_OPTIONS, validateBucketName } from './common'
+import { S3_REGION_OPTIONS } from 'lib/integrations/s3Regions'
+
+import { S3FamilyFields, S3_FAMILY_EVENT_TABLE_EXTRA_FIELDS, validateBucketName } from './common'
import type { DestinationDefinition } from './types'
// Catch-all for any non-AWS S3-compatible object storage. Exposes virtual-style addressing; no
diff --git a/products/data_warehouse/frontend/shared/components/DestinationModal.stories.tsx b/products/data_warehouse/frontend/shared/components/DestinationModal.stories.tsx
new file mode 100644
index 000000000000..5aa1be8e4598
--- /dev/null
+++ b/products/data_warehouse/frontend/shared/components/DestinationModal.stories.tsx
@@ -0,0 +1,78 @@
+import { Meta, StoryFn } from '@storybook/react'
+import { useActions } from 'kea'
+import { useEffect } from 'react'
+
+import { mswDecorator } from '~/mocks/browser'
+
+import type { CreatableDestinationType } from 'products/data_warehouse/frontend/shared/destinations/types'
+import { destinationModalLogic } from 'products/data_warehouse/frontend/shared/logics/destinationModalLogic'
+
+import { DestinationModal } from './DestinationModal'
+
+// One connection per kind, so every type's picker has something to select.
+const INTEGRATIONS = [
+ 'postgresql',
+ 'aws-redshift',
+ 'snowflake',
+ 'databricks',
+ 'google-cloud-service-account',
+ 'aws-s3',
+ 's3-compatible',
+ 'azure-blob',
+].map((kind, index) => ({
+ id: index + 1,
+ kind,
+ display_name: `${kind} connection`,
+ created_at: '2026-09-01T10:00:00Z',
+ created_by: null,
+ config: {},
+}))
+
+const meta: Meta<typeof DestinationModal> = {
+ title: 'Data Warehouse/DestinationModal',
+ component: DestinationModal,
+ parameters: {
+ viewMode: 'story',
+ testOptions: { snapshotTargetSelector: '.LemonModal' },
+ },
+ decorators: [
+ mswDecorator({
+ get: {
+ '/api/projects/:team_id/integrations': { results: INTEGRATIONS },
+ },
+ }),
+ ],
+}
+export default meta
+
+function OpenModal({ type }: { type: CreatableDestinationType }): JSX.Element {
+ const props = { modalKey: `story-${type}`, onSaved: () => {} }
+ const { openForCreate, setDestinationType } = useActions(destinationModalLogic(props))
+
+ useEffect(() => {
+ openForCreate()
+ setDestinationType(type)
+ }, [openForCreate, setDestinationType, type])
+
+ return <DestinationModal {...props} />
+}
+
+const Template: StoryFn<{ type: CreatableDestinationType }> = ({ type }) => <OpenModal type={type} />
+
+export const Postgres = Template.bind({})
+Postgres.args = { type: 'Postgres' }
+
+export const Snowflake = Template.bind({})
+Snowflake.args = { type: 'Snowflake' }
+
+export const Databricks = Template.bind({})
+Databricks.args = { type: 'Databricks' }
+
+export const BigQuery = Template.bind({})
+BigQuery.args = { type: 'BigQuery' }
+
+export const S3 = Template.bind({})
+S3.args = { type: 'S3' }
+
+export const AzureBlob = Template.bind({})
+AzureBlob.args = { type: 'AzureBlob' }
diff --git a/products/data_warehouse/frontend/shared/components/DestinationModal.tsx b/products/data_warehouse/frontend/shared/components/DestinationModal.tsx
index cea9ca85e5d5..9b930511833a 100644
--- a/products/data_warehouse/frontend/shared/components/DestinationModal.tsx
+++ b/products/data_warehouse/frontend/shared/components/DestinationModal.tsx
@@ -1,116 +1,151 @@
import { useActions, useValues } from 'kea'
import { Form } from 'kea-forms'
-import { LemonButton, LemonInput, LemonModal } from '@posthog/lemon-ui'
+import { LemonButton, LemonInput, LemonModal, LemonSelect } from '@posthog/lemon-ui'
import { IntegrationChoice } from 'lib/components/CyclotronJob/integrations/IntegrationChoice'
import { IntegrationView } from 'lib/integrations/IntegrationView'
+import { getIntegrationNameFromKind } from 'lib/integrations/utils'
import { LemonBanner } from 'lib/lemon-ui/LemonBanner'
import { LemonField } from 'lib/lemon-ui/LemonField'
+import { CREATABLE_DESTINATION_TYPES } from 'products/data_warehouse/frontend/shared/destinations/destinationDefinitions'
import {
DestinationModalLogicProps,
destinationModalLogic,
} from 'products/data_warehouse/frontend/shared/logics/destinationModalLogic'
-import { DestinationIcon } from './DestinationIcon'
+import { DestinationIcon, destinationTypeLabel } from './DestinationIcon'
export function DestinationModal(props: DestinationModalLogicProps): JSX.Element {
const logic = destinationModalLogic(props)
- const { isOpen, editing, editingIntegration, isDestinationFormSubmitting } = useValues(logic)
- const { closeModal, submitDestinationForm, deleteDestination } = useActions(logic)
+ const { isOpen, editing, editingIntegration, isDestinationFormSubmitting, destinationForm, definition } =
+ useValues(logic)
+ const { closeModal, submitDestinationForm, deleteDestination, setDestinationType, setIntegrationKind } =
+ useActions(logic)
+
+ const Fields = definition.Fields
return (
- <>
- <LemonModal
- isOpen={isOpen}
- onClose={closeModal}
- title={
- <div className="flex gap-2 items-center">
- <DestinationIcon type="Postgres" />
- <span>{editing ? 'Edit destination' : 'New destination'}</span>
- </div>
- }
- footer={
- <>
- {editing && !editing.is_posthog_warehouse ? (
- <LemonButton
- type="secondary"
- status="danger"
- onClick={() => deleteDestination(editing)}
- data-attr="warehouse-destination-delete"
- // Sits apart from Cancel and Save so it is not reached by accident.
- className="mr-auto"
- >
- Delete
- </LemonButton>
- ) : null}
- <LemonButton type="secondary" onClick={closeModal}>
- Cancel
- </LemonButton>
+ <LemonModal
+ isOpen={isOpen}
+ onClose={closeModal}
+ title={
+ <div className="flex gap-2 items-center">
+ <DestinationIcon type={destinationForm.type} />
+ <span>{editing ? 'Edit destination' : 'New destination'}</span>
+ </div>
+ }
+ footer={
+ <>
+ {editing && !editing.is_posthog_warehouse ? (
<LemonButton
- type="primary"
- onClick={submitDestinationForm}
- loading={isDestinationFormSubmitting}
- data-attr="warehouse-destination-save"
+ type="secondary"
+ status="danger"
+ onClick={() => deleteDestination(editing)}
+ data-attr="warehouse-destination-delete"
+ // Sits apart from Cancel and Save so it is not reached by accident.
+ className="mr-auto"
>
- {editing ? 'Save' : 'Add destination'}
+ Delete
</LemonButton>
- </>
- }
+ ) : null}
+ <LemonButton type="secondary" onClick={closeModal}>
+ Cancel
+ </LemonButton>
+ <LemonButton
+ type="primary"
+ onClick={submitDestinationForm}
+ loading={isDestinationFormSubmitting}
+ data-attr="warehouse-destination-save"
+ >
+ {editing ? 'Save' : 'Add destination'}
+ </LemonButton>
+ </>
+ }
+ >
+ <Form
+ logic={destinationModalLogic}
+ props={props}
+ formKey="destinationForm"
+ className="deprecated-space-y-4"
>
- <Form
- logic={destinationModalLogic}
- props={props}
- formKey="destinationForm"
- className="deprecated-space-y-4"
- >
- <LemonField name="name" label="Name">
- <LemonInput placeholder="Customer Postgres" data-attr="warehouse-destination-name" />
+ {!editing && (
+ <LemonField name="type" label="Type">
+ {({ value }) => (
+ <LemonSelect
+ value={value}
+ onChange={setDestinationType}
+ data-attr="warehouse-destination-type"
+ options={CREATABLE_DESTINATION_TYPES.map((type) => ({
+ value: type,
+ label: destinationTypeLabel(type),
+ icon: <DestinationIcon type={type} />,
+ }))}
+ />
+ )}
</LemonField>
+ )}
- <LemonField
- name="integrationId"
- label="Connection"
- info="Credentials live on the connection, so one connection can back several destinations and batch exports."
- >
- {({ value, onChange }) =>
- editing ? (
- editingIntegration ? (
- <IntegrationView integration={editingIntegration} suffix={<></>} />
- ) : (
- <span className="text-muted">
- This destination's connection is no longer available.
- </span>
- )
+ <LemonField name="name" label="Name">
+ <LemonInput
+ placeholder={`My ${destinationTypeLabel(destinationForm.type)}`}
+ data-attr="warehouse-destination-name"
+ />
+ </LemonField>
+
+ {/* A type backed by more than one integration kind needs the provider picked
+ first, because the connection list is per kind. */}
+ {!editing && definition.integrationKinds.length > 1 && (
+ <LemonField name="integrationKind" label="Provider">
+ {({ value }) => (
+ <LemonSelect
+ value={value}
+ onChange={setIntegrationKind}
+ data-attr="warehouse-destination-provider"
+ options={definition.integrationKinds.map((kind) => ({
+ value: kind,
+ label: getIntegrationNameFromKind(kind),
+ }))}
+ />
+ )}
+ </LemonField>
+ )}
+
+ <LemonField
+ name="integrationId"
+ label="Connection"
+ info="Credentials live on the connection, so one connection can back several destinations and batch exports."
+ >
+ {({ value, onChange }) =>
+ editing ? (
+ editingIntegration ? (
+ <IntegrationView integration={editingIntegration} suffix={<></>} />
) : (
- <IntegrationChoice
- integration="postgresql"
- value={value ?? undefined}
- onChange={onChange}
- />
+ <span className="text-muted">
+ This destination's connection is no longer available.
+ </span>
)
- }
- </LemonField>
+ ) : (
+ <IntegrationChoice
+ integration={destinationForm.integrationKind}
+ value={value ?? undefined}
+ onChange={onChange}
+ />
+ )
+ }
+ </LemonField>
- <div className="flex gap-2">
- <LemonField name="database" label="Database" className="flex-1">
- <LemonInput data-attr="warehouse-destination-database" disabled={!!editing} />
- </LemonField>
- <LemonField name="schema" label="Schema" className="flex-1">
- <LemonInput data-attr="warehouse-destination-schema" disabled={!!editing} />
- </LemonField>
- </div>
+ <Fields isNew={!editing} formValues={destinationForm} selectedIntegration={editingIntegration} />
- {editing ? (
- <LemonBanner type="info">
- The connection, database and schema are fixed once a destination exists. Everything already
- synced sits where it is now, so pointing this somewhere else would leave that behind and
- need a full resync. Add a second destination instead.
- </LemonBanner>
- ) : null}
- </Form>
- </LemonModal>
- </>
+ {editing ? (
+ <LemonBanner type="info">
+ The connection and the place this writes to are fixed once a destination exists. Everything
+ already synced sits where it is now, so pointing this somewhere else would leave that behind and
+ need a full resync. Add a second destination instead.
+ </LemonBanner>
+ ) : null}
+ </Form>
+ </LemonModal>
)
}
diff --git a/products/data_warehouse/frontend/shared/destinations/azureBlob.tsx b/products/data_warehouse/frontend/shared/destinations/azureBlob.tsx
new file mode 100644
index 000000000000..73cd6d3ba97a
--- /dev/null
+++ b/products/data_warehouse/frontend/shared/destinations/azureBlob.tsx
@@ -0,0 +1,39 @@
+import { LemonInput, LemonSelect } from '@posthog/lemon-ui'
+
+import { LemonField } from 'lib/lemon-ui/LemonField'
+
+import { DEFAULT_PARQUET_COMPRESSION, PARQUET_COMPRESSION_OPTIONS } from './parquetCompression'
+import type { WarehouseDestinationDefinition } from './types'
+
+export const azureBlobDefinition: WarehouseDestinationDefinition = {
+ type: 'AzureBlob',
+ integrationKinds: ['azure-blob'],
+ defaults: () => ({ compression: DEFAULT_PARQUET_COMPRESSION }),
+ requiredFields: () => ['container_name'],
+ configKeys: ['container_name', 'prefix', 'compression'],
+ retargetingKeys: ['container_name', 'prefix'],
+ Fields: function AzureBlobFields({ isNew }) {
+ return (
+ <>
+ <LemonField name="container_name" label="Container" info="The container must already exist.">
+ <LemonInput
+ placeholder="my-container"
+ disabled={!isNew}
+ data-attr="warehouse-destination-container"
+ />
+ </LemonField>
+ <LemonField
+ name="prefix"
+ label="Prefix"
+ showOptional
+ info="Folder to write under. Each table gets its own folder below this."
+ >
+ <LemonInput placeholder="posthog/" disabled={!isNew} data-attr="warehouse-destination-prefix" />
+ </LemonField>
+ <LemonField name="compression" label="Compression">
+ <LemonSelect options={PARQUET_COMPRESSION_OPTIONS} data-attr="warehouse-destination-compression" />
+ </LemonField>
+ </>
+ )
+ },
+}
diff --git a/products/data_warehouse/frontend/shared/destinations/bigquery.tsx b/products/data_warehouse/frontend/shared/destinations/bigquery.tsx
new file mode 100644
index 000000000000..e1052ea58677
--- /dev/null
+++ b/products/data_warehouse/frontend/shared/destinations/bigquery.tsx
@@ -0,0 +1,37 @@
+import { LemonInput } from '@posthog/lemon-ui'
+
+import { LemonField } from 'lib/lemon-ui/LemonField'
+
+import type { WarehouseDestinationDefinition } from './types'
+
+export const bigqueryDefinition: WarehouseDestinationDefinition = {
+ type: 'BigQuery',
+ integrationKinds: ['google-cloud-service-account'],
+ defaults: () => ({}),
+ // Project is optional: the writer falls back to the service account's own project.
+ requiredFields: () => ['dataset'],
+ configKeys: ['dataset', 'project'],
+ retargetingKeys: ['dataset', 'project'],
+ Fields: function BigQueryFields({ isNew }) {
+ return (
+ <div className="flex gap-2">
+ <LemonField name="dataset" label="Dataset" className="flex-1">
+ <LemonInput placeholder="my_dataset" disabled={!isNew} data-attr="warehouse-destination-dataset" />
+ </LemonField>
+ <LemonField
+ name="project"
+ label="Project"
+ className="flex-1"
+ showOptional
+ info="Leave empty to use the project the service account belongs to."
+ >
+ <LemonInput
+ placeholder="The service account's project"
+ disabled={!isNew}
+ data-attr="warehouse-destination-project"
+ />
+ </LemonField>
+ </div>
+ )
+ },
+}
diff --git a/products/data_warehouse/frontend/shared/destinations/databricks.tsx b/products/data_warehouse/frontend/shared/destinations/databricks.tsx
new file mode 100644
index 000000000000..61af3d6618d4
--- /dev/null
+++ b/products/data_warehouse/frontend/shared/destinations/databricks.tsx
@@ -0,0 +1,48 @@
+import { LemonInput } from '@posthog/lemon-ui'
+
+import { LemonField } from 'lib/lemon-ui/LemonField'
+
+import type { WarehouseDestinationDefinition } from './types'
+
+export const databricksDefinition: WarehouseDestinationDefinition = {
+ type: 'Databricks',
+ integrationKinds: ['databricks'],
+ defaults: () => ({
+ catalog: 'main',
+ schema: 'default',
+ volume: 'posthog_warehouse_sync',
+ // Prefill the fixed part of the path so only the warehouse id has to be pasted.
+ http_path: '/sql/1.0/warehouses/',
+ }),
+ requiredFields: () => ['http_path', 'catalog', 'schema', 'volume'],
+ configKeys: ['http_path', 'catalog', 'schema', 'volume'],
+ retargetingKeys: ['catalog', 'schema'],
+ Fields: function DatabricksFields({ isNew }) {
+ return (
+ <>
+ <LemonField
+ name="http_path"
+ label="HTTP path"
+ info="The HTTP path of your SQL warehouse or all-purpose compute, from its connection details."
+ >
+ <LemonInput placeholder="/sql/1.0/warehouses/abc123" data-attr="warehouse-destination-http-path" />
+ </LemonField>
+ <div className="flex gap-2">
+ <LemonField name="catalog" label="Catalog" className="flex-1">
+ <LemonInput placeholder="main" disabled={!isNew} data-attr="warehouse-destination-catalog" />
+ </LemonField>
+ <LemonField name="schema" label="Schema" className="flex-1">
+ <LemonInput placeholder="default" disabled={!isNew} data-attr="warehouse-destination-schema" />
+ </LemonField>
+ </div>
+ <LemonField
+ name="volume"
+ label="Volume"
+ info="Unity Catalog volume used to stage files before they are loaded. It is created if it does not exist."
+ >
+ <LemonInput placeholder="posthog_warehouse_sync" data-attr="warehouse-destination-volume" />
+ </LemonField>
+ </>
+ )
+ },
+}
diff --git a/products/data_warehouse/frontend/shared/destinations/destinationDefinitions.test.ts b/products/data_warehouse/frontend/shared/destinations/destinationDefinitions.test.ts
new file mode 100644
index 000000000000..73d96f022f5f
--- /dev/null
+++ b/products/data_warehouse/frontend/shared/destinations/destinationDefinitions.test.ts
@@ -0,0 +1,118 @@
+import {
+ CREATABLE_DESTINATION_TYPES,
+ WAREHOUSE_DESTINATIONS,
+ buildDestinationConfig,
+ buildDestinationFormValues,
+ validateDestinationFields,
+} from './destinationDefinitions'
+import type { CreatableDestinationType } from './types'
+
+describe('warehouse destination definitions', () => {
+ it.each(CREATABLE_DESTINATION_TYPES)('%s keys its own definition', (type) => {
+ expect(WAREHOUSE_DESTINATIONS[type].type).toEqual(type)
+ })
+
+ it.each(CREATABLE_DESTINATION_TYPES)('%s names at least one integration kind', (type) => {
+ expect(WAREHOUSE_DESTINATIONS[type].integrationKinds.length).toBeGreaterThan(0)
+ })
+
+ it.each(CREATABLE_DESTINATION_TYPES)('%s only pins config keys it actually writes', (type) => {
+ // A retargeting key the type never sends is never compared, so the backend guard for it
+ // would never fire and the field would look protected while being editable.
+ const { configKeys, retargetingKeys } = WAREHOUSE_DESTINATIONS[type]
+ expect(configKeys).toEqual(expect.arrayContaining(retargetingKeys))
+ })
+
+ it.each(CREATABLE_DESTINATION_TYPES)('%s requires only fields it declares as config', (type) => {
+ // A required field outside `configKeys` is dropped from the payload, so it can never be satisfied.
+ const definition = WAREHOUSE_DESTINATIONS[type]
+ const required = definition.requiredFields({ isNew: true, formValues: {} })
+ expect(definition.configKeys).toEqual(expect.arrayContaining(required))
+ })
+
+ describe('buildDestinationConfig', () => {
+ it('drops fields belonging to another type', () => {
+ const config = buildDestinationConfig(WAREHOUSE_DESTINATIONS.BigQuery, {
+ dataset: 'analytics',
+ database: 'postgres',
+ schema: 'public',
+ bucket: 'my-bucket',
+ })
+
+ expect(config).toEqual({ dataset: 'analytics' })
+ })
+
+ it('leaves an untouched optional field out so the writer default applies', () => {
+ // Snowflake falls back to the user's default role when `role` is absent. An empty
+ // string is not absent, and would be asserted as an identifier.
+ const config = buildDestinationConfig(WAREHOUSE_DESTINATIONS.Snowflake, {
+ database: 'DB',
+ schema: 'PUBLIC',
+ warehouse: 'WH',
+ role: '',
+ })
+
+ expect(config).not.toHaveProperty('role')
+ })
+
+ it('keeps a false checkbox rather than treating it as unset', () => {
+ const config = buildDestinationConfig(WAREHOUSE_DESTINATIONS.S3, {
+ bucket: 'b',
+ region: 'us-east-1',
+ use_virtual_style_addressing: false,
+ })
+
+ expect(config.use_virtual_style_addressing).toBe(false)
+ })
+ })
+
+ describe('buildDestinationFormValues', () => {
+ it.each(CREATABLE_DESTINATION_TYPES)('%s round-trips a saved config back into the form', (type) => {
+ // A key missing from `configKeys` renders as the default, then overwrites the real value on save.
+ const definition = WAREHOUSE_DESTINATIONS[type]
+ const stored = Object.fromEntries(definition.configKeys.map((key) => [key, `stored-${key}`]))
+
+ const formValues = buildDestinationFormValues(definition, stored)
+
+ expect(buildDestinationConfig(definition, formValues)).toEqual(stored)
+ })
+
+ it('falls back to the type default when the key is absent', () => {
+ const formValues = buildDestinationFormValues(WAREHOUSE_DESTINATIONS.Databricks, {})
+
+ expect(formValues.catalog).toEqual('main')
+ expect(formValues.volume).toEqual('posthog_warehouse_sync')
+ })
+ })
+
+ describe('validateDestinationFields', () => {
+ it.each(CREATABLE_DESTINATION_TYPES)('%s reports every required field on an empty form', (type) => {
+ const definition = WAREHOUSE_DESTINATIONS[type]
+ const required = definition.requiredFields({ isNew: true, formValues: {} })
+
+ const errors = validateDestinationFields(definition, { isNew: true, formValues: {} })
+
+ expect(Object.keys(errors).sort()).toEqual([...required].sort())
+ })
+
+ it('accepts a form filled from the type defaults plus its required fields', () => {
+ const definition = WAREHOUSE_DESTINATIONS.Snowflake
+ const formValues = { ...definition.defaults(), database: 'DB', warehouse: 'WH' }
+
+ expect(validateDestinationFields(definition, { isNew: true, formValues })).toEqual({})
+ })
+
+ it('treats a whitespace-only value as missing', () => {
+ const errors = validateDestinationFields(WAREHOUSE_DESTINATIONS.BigQuery, {
+ isNew: true,
+ formValues: { dataset: ' ' },
+ })
+
+ expect(errors.dataset).toBeTruthy()
+ })
+ })
+
+ it('does not offer the managed PostHog warehouse as a type', () => {
+ expect(CREATABLE_DESTINATION_TYPES).not.toContain('PostHogWarehouse' as CreatableDestinationType)
+ })
+})
diff --git a/products/data_warehouse/frontend/shared/destinations/destinationDefinitions.ts b/products/data_warehouse/frontend/shared/destinations/destinationDefinitions.ts
new file mode 100644
index 000000000000..c4058531db3a
--- /dev/null
+++ b/products/data_warehouse/frontend/shared/destinations/destinationDefinitions.ts
@@ -0,0 +1,83 @@
+import { azureBlobDefinition } from './azureBlob'
+import { bigqueryDefinition } from './bigquery'
+import { databricksDefinition } from './databricks'
+import { postgresDefinition } from './postgres'
+import { redshiftDefinition } from './redshift'
+import { s3Definition } from './s3'
+import { snowflakeDefinition } from './snowflake'
+import type { CreatableDestinationType, DestinationContext, WarehouseDestinationDefinition } from './types'
+
+/**
+ * Adding a type here makes it selectable, but the backend decides whether it can be written:
+ * `USER_CREATABLE_TYPES` in the destination serializer, and a registered writer in
+ * `builtin_writers.py`. A type missing either fails on save rather than on sync.
+ */
+export const WAREHOUSE_DESTINATIONS: Record<CreatableDestinationType, WarehouseDestinationDefinition> = {
+ Postgres: postgresDefinition,
+ Redshift: redshiftDefinition,
+ Snowflake: snowflakeDefinition,
+ BigQuery: bigqueryDefinition,
+ Databricks: databricksDefinition,
+ S3: s3Definition,
+ AzureBlob: azureBlobDefinition,
+}
+
+export const CREATABLE_DESTINATION_TYPES = Object.keys(WAREHOUSE_DESTINATIONS) as CreatableDestinationType[]
+
+export function buildDestinationConfig(
+ definition: WarehouseDestinationDefinition,
+ formValues: Record<string, any>
+): Record<string, any> {
+ if (definition.serialize) {
+ return definition.serialize(formValues)
+ }
+
+ const config: Record<string, any> = {}
+ for (const key of definition.configKeys) {
+ const value = formValues[key]
+ // An untouched optional field stays out, so the writer's own default applies.
+ if (value !== undefined && value !== null && value !== '') {
+ config[key] = value
+ }
+ }
+ return config
+}
+
+export function buildDestinationFormValues(
+ definition: WarehouseDestinationDefinition,
+ config: Record<string, any>
+): Record<string, any> {
+ if (definition.deserialize) {
+ return { ...definition.defaults(), ...definition.deserialize(config) }
+ }
+
+ const values: Record<string, any> = { ...definition.defaults() }
+ for (const key of definition.configKeys) {
+ if (config[key] !== undefined) {
+ values[key] = config[key]
+ }
+ }
+ return values
+}
+
+export function validateDestinationFields(
+ definition: WarehouseDestinationDefinition,
+ ctx: DestinationContext
+): Record<string, string | undefined> {
+ const errors: Record<string, string | undefined> = {}
+
+ for (const field of definition.requiredFields(ctx)) {
+ const value = ctx.formValues[field]
+ if (value === undefined || value === null || String(value).trim() === '') {
+ errors[field] = 'This field is required'
+ }
+ }
+
+ for (const [field, error] of Object.entries(definition.validate?.(ctx.formValues) ?? {})) {
+ if (error && !errors[field]) {
+ errors[field] = error
+ }
+ }
+
+ return errors
+}
diff --git a/products/data_warehouse/frontend/shared/destinations/parquetCompression.ts b/products/data_warehouse/frontend/shared/destinations/parquetCompression.ts
new file mode 100644
index 000000000000..27bb55a83328
--- /dev/null
+++ b/products/data_warehouse/frontend/shared/destinations/parquetCompression.ts
@@ -0,0 +1,14 @@
+/**
+ * Mirrors `ParquetCompression` in the S3 and Azure Blob writers, which reject an unsupported
+ * value before reading a batch. An option added here alone fails the sync, not the form.
+ */
+export const PARQUET_COMPRESSION_OPTIONS: { value: string; label: string }[] = [
+ { value: 'zstd', label: 'zstd' },
+ { value: 'snappy', label: 'snappy' },
+ { value: 'gzip', label: 'gzip' },
+ { value: 'brotli', label: 'brotli' },
+ { value: 'lz4', label: 'lz4' },
+ { value: 'none', label: 'None' },
+]
+
+export const DEFAULT_PARQUET_COMPRESSION = 'zstd'
diff --git a/products/data_warehouse/frontend/shared/destinations/postgres.tsx b/products/data_warehouse/frontend/shared/destinations/postgres.tsx
new file mode 100644
index 000000000000..de387611177c
--- /dev/null
+++ b/products/data_warehouse/frontend/shared/destinations/postgres.tsx
@@ -0,0 +1,26 @@
+import { LemonInput } from '@posthog/lemon-ui'
+
+import { LemonField } from 'lib/lemon-ui/LemonField'
+
+import type { WarehouseDestinationDefinition } from './types'
+
+export const postgresDefinition: WarehouseDestinationDefinition = {
+ type: 'Postgres',
+ integrationKinds: ['postgresql'],
+ defaults: () => ({ database: 'postgres', schema: 'public' }),
+ requiredFields: () => ['database', 'schema'],
+ configKeys: ['database', 'schema'],
+ retargetingKeys: ['database', 'schema'],
+ Fields: function PostgresFields({ isNew }) {
+ return (
+ <div className="flex gap-2">
+ <LemonField name="database" label="Database" className="flex-1">
+ <LemonInput placeholder="postgres" disabled={!isNew} data-attr="warehouse-destination-database" />
+ </LemonField>
+ <LemonField name="schema" label="Schema" className="flex-1">
+ <LemonInput placeholder="public" disabled={!isNew} data-attr="warehouse-destination-schema" />
+ </LemonField>
+ </div>
+ )
+ },
+}
diff --git a/products/data_warehouse/frontend/shared/destinations/redshift.tsx b/products/data_warehouse/frontend/shared/destinations/redshift.tsx
new file mode 100644
index 000000000000..d50b99a574d4
--- /dev/null
+++ b/products/data_warehouse/frontend/shared/destinations/redshift.tsx
@@ -0,0 +1,29 @@
+import { LemonInput } from '@posthog/lemon-ui'
+
+import { LemonField } from 'lib/lemon-ui/LemonField'
+
+import type { WarehouseDestinationDefinition } from './types'
+
+// Redshift speaks the Postgres wire protocol and its writer subclasses the Postgres one, so it
+// takes the same two config fields. Kept as its own definition rather than sharing Postgres's,
+// because the two pick credentials from different integration kinds.
+export const redshiftDefinition: WarehouseDestinationDefinition = {
+ type: 'Redshift',
+ integrationKinds: ['aws-redshift'],
+ defaults: () => ({ database: 'dev', schema: 'public' }),
+ requiredFields: () => ['database', 'schema'],
+ configKeys: ['database', 'schema'],
+ retargetingKeys: ['database', 'schema'],
+ Fields: function RedshiftFields({ isNew }) {
+ return (
+ <div className="flex gap-2">
+ <LemonField name="database" label="Database" className="flex-1">
+ <LemonInput placeholder="dev" disabled={!isNew} data-attr="warehouse-destination-database" />
+ </LemonField>
+ <LemonField name="schema" label="Schema" className="flex-1">
+ <LemonInput placeholder="public" disabled={!isNew} data-attr="warehouse-destination-schema" />
+ </LemonField>
+ </div>
+ )
+ },
+}
diff --git a/products/data_warehouse/frontend/shared/destinations/s3.tsx b/products/data_warehouse/frontend/shared/destinations/s3.tsx
new file mode 100644
index 000000000000..1762d752bce5
--- /dev/null
+++ b/products/data_warehouse/frontend/shared/destinations/s3.tsx
@@ -0,0 +1,63 @@
+import { LemonCheckbox, LemonInput, LemonSelect } from '@posthog/lemon-ui'
+
+import { AWS_ONLY_REGION_OPTIONS, S3_REGION_OPTIONS } from 'lib/integrations/s3Regions'
+import { LemonField } from 'lib/lemon-ui/LemonField'
+
+import { DEFAULT_PARQUET_COMPRESSION, PARQUET_COMPRESSION_OPTIONS } from './parquetCompression'
+import type { WarehouseDestinationDefinition } from './types'
+
+// One type covers AWS and every S3-compatible provider. AWS only accepts its own region codes,
+// so aws-s3 gets the narrow catalog; s3-compatible providers (MinIO, Wasabi, GCS, R2, OVH, ...)
+// get the broad one. Virtual-style addressing stays visible either way: AWS ignores the setting,
+// but MinIO and Wasabi need it.
+export const s3Definition: WarehouseDestinationDefinition = {
+ type: 'S3',
+ integrationKinds: ['aws-s3', 's3-compatible'],
+ defaults: () => ({ compression: DEFAULT_PARQUET_COMPRESSION, use_virtual_style_addressing: false }),
+ requiredFields: () => ['bucket', 'region'],
+ configKeys: ['bucket', 'region', 'prefix', 'compression', 'use_virtual_style_addressing'],
+ retargetingKeys: ['bucket', 'prefix'],
+ Fields: function S3Fields({ isNew, formValues }) {
+ // AWS rejects region values that only exist for GCP, R2 or OVH, so aws-s3 gets the
+ // narrower catalog; s3-compatible providers reuse those values, so they get the broad one.
+ const regionOptions = formValues.integrationKind === 'aws-s3' ? AWS_ONLY_REGION_OPTIONS : S3_REGION_OPTIONS
+ return (
+ <>
+ <div className="flex gap-2">
+ <LemonField name="bucket" label="Bucket" className="flex-1">
+ <LemonInput
+ placeholder="my-bucket"
+ disabled={!isNew}
+ data-attr="warehouse-destination-bucket"
+ />
+ </LemonField>
+ <LemonField name="region" label="Region" className="flex-1">
+ <LemonSelect options={regionOptions} data-attr="warehouse-destination-region" />
+ </LemonField>
+ </div>
+ <LemonField
+ name="prefix"
+ label="Prefix"
+ showOptional
+ info="Folder to write under. Each table gets its own folder below this."
+ >
+ <LemonInput placeholder="posthog/" disabled={!isNew} data-attr="warehouse-destination-prefix" />
+ </LemonField>
+ <LemonField name="compression" label="Compression">
+ <LemonSelect options={PARQUET_COMPRESSION_OPTIONS} data-attr="warehouse-destination-compression" />
+ </LemonField>
+ <LemonField name="use_virtual_style_addressing">
+ {({ value, onChange }) => (
+ <LemonCheckbox
+ bordered
+ checked={!!value}
+ onChange={onChange}
+ label="Use virtual-hosted style addressing"
+ data-attr="warehouse-destination-virtual-style"
+ />
+ )}
+ </LemonField>
+ </>
+ )
+ },
+}
diff --git a/products/data_warehouse/frontend/shared/destinations/snowflake.tsx b/products/data_warehouse/frontend/shared/destinations/snowflake.tsx
new file mode 100644
index 000000000000..0694c0717929
--- /dev/null
+++ b/products/data_warehouse/frontend/shared/destinations/snowflake.tsx
@@ -0,0 +1,42 @@
+import { LemonInput } from '@posthog/lemon-ui'
+
+import { LemonField } from 'lib/lemon-ui/LemonField'
+
+import type { WarehouseDestinationDefinition } from './types'
+
+export const snowflakeDefinition: WarehouseDestinationDefinition = {
+ type: 'Snowflake',
+ integrationKinds: ['snowflake'],
+ defaults: () => ({ schema: 'PUBLIC' }),
+ // The writer asserts database, schema and warehouse are safe identifiers and fails the run
+ // without them. Role is optional: Snowflake falls back to the user's default role.
+ requiredFields: () => ['database', 'schema', 'warehouse'],
+ configKeys: ['database', 'schema', 'warehouse', 'role'],
+ retargetingKeys: ['database', 'schema'],
+ Fields: function SnowflakeFields({ isNew }) {
+ return (
+ <>
+ <div className="flex gap-2">
+ <LemonField name="database" label="Database" className="flex-1">
+ <LemonInput
+ placeholder="MY_DATABASE"
+ disabled={!isNew}
+ data-attr="warehouse-destination-database"
+ />
+ </LemonField>
+ <LemonField name="schema" label="Schema" className="flex-1">
+ <LemonInput placeholder="PUBLIC" disabled={!isNew} data-attr="warehouse-destination-schema" />
+ </LemonField>
+ </div>
+ <div className="flex gap-2">
+ <LemonField name="warehouse" label="Warehouse" className="flex-1">
+ <LemonInput placeholder="COMPUTE_WH" data-attr="warehouse-destination-warehouse" />
+ </LemonField>
+ <LemonField name="role" label="Role" className="flex-1" showOptional>
+ <LemonInput placeholder="Your default role" data-attr="warehouse-destination-role" />
+ </LemonField>
+ </div>
+ </>
+ )
+ },
+}
diff --git a/products/data_warehouse/frontend/shared/destinations/types.ts b/products/data_warehouse/frontend/shared/destinations/types.ts
new file mode 100644
index 000000000000..fbfaab0f61ee
--- /dev/null
+++ b/products/data_warehouse/frontend/shared/destinations/types.ts
@@ -0,0 +1,37 @@
+import type React from 'react'
+
+import type { IntegrationKind, IntegrationType } from '~/types'
+
+import type { ExternalDataDestinationTypeEnumApi } from 'products/warehouse_sources/frontend/generated/api.schemas'
+
+/** The PostHog warehouse is managed by the sync itself, so it is not creatable. */
+export type CreatableDestinationType = Exclude<ExternalDataDestinationTypeEnumApi, 'PostHogWarehouse'>
+
+export interface DestinationContext {
+ isNew: boolean
+ formValues: Record<string, any>
+ selectedIntegration?: IntegrationType | null
+}
+
+export interface WarehouseDestinationDefinition {
+ type: CreatableDestinationType
+ /** S3 names two, so the modal asks which provider before listing connections. */
+ integrationKinds: IntegrationKind[]
+ defaults: () => Record<string, any>
+ requiredFields: (ctx: DestinationContext) => string[]
+ validate?: (formValues: Record<string, any>) => Record<string, string | undefined>
+ /**
+ * Mirrors what this type's writer reads in `pipeline_v3/destinations_load/writers/`.
+ * `buildDestinationConfig` drops everything else, so switching type in the form cannot
+ * carry another type's fields into the payload.
+ */
+ configKeys: string[]
+ /**
+ * Config that pins where already-synced rows live. The backend refuses to change these
+ * after creation; mirrors `RETARGETING_FIELDS_BY_TYPE` in the destination serializer.
+ */
+ retargetingKeys: string[]
+ serialize?: (formValues: Record<string, any>) => Record<string, any>
+ deserialize?: (config: Record<string, any>) => Record<string, any>
+ Fields: React.FC<DestinationContext>
+}
diff --git a/products/data_warehouse/frontend/shared/logics/destinationModalLogic.test.ts b/products/data_warehouse/frontend/shared/logics/destinationModalLogic.test.ts
new file mode 100644
index 000000000000..35b318e8b559
--- /dev/null
+++ b/products/data_warehouse/frontend/shared/logics/destinationModalLogic.test.ts
@@ -0,0 +1,84 @@
+import { expectLogic } from 'kea-test-utils'
+
+import { initKeaTests } from '~/test/init'
+
+import { destinationModalLogic } from './destinationModalLogic'
+
+describe('destinationModalLogic', () => {
+ let logic: ReturnType<typeof destinationModalLogic.build>
+
+ beforeEach(() => {
+ initKeaTests()
+ logic = destinationModalLogic({ modalKey: 'test', onSaved: () => {} })
+ logic.mount()
+ })
+
+ afterEach(() => {
+ logic.unmount()
+ })
+
+ it('starts a new destination on Postgres with its defaults', async () => {
+ await expectLogic(logic, () => logic.actions.openForCreate()).toFinishAllListeners()
+
+ expect(logic.values.destinationForm).toMatchObject({
+ type: 'Postgres',
+ integrationKind: 'postgresql',
+ database: 'postgres',
+ schema: 'public',
+ })
+ })
+
+ it('drops the previous type fields when the type changes', async () => {
+ // Carrying them over leaves another type's values in the form. They would be dropped
+ // silently at save time, so the payload would not match what the form showed.
+ await expectLogic(logic, () => logic.actions.openForCreate()).toFinishAllListeners()
+ await expectLogic(logic, () => logic.actions.setDestinationType('BigQuery')).toFinishAllListeners()
+
+ expect(logic.values.destinationForm.database).toBeUndefined()
+ expect(logic.values.destinationForm.schema).toBeUndefined()
+ expect(logic.values.destinationForm.type).toEqual('BigQuery')
+ })
+
+ it('keeps the name already typed when the type changes', async () => {
+ await expectLogic(logic, () => logic.actions.openForCreate()).toFinishAllListeners()
+ logic.actions.setDestinationFormValue('name', 'Warehouse copy')
+
+ await expectLogic(logic, () => logic.actions.setDestinationType('Snowflake')).toFinishAllListeners()
+
+ expect(logic.values.destinationForm.name).toEqual('Warehouse copy')
+ })
+
+ it('follows the type to its own connection kind', async () => {
+ await expectLogic(logic, () => logic.actions.openForCreate()).toFinishAllListeners()
+ await expectLogic(logic, () => logic.actions.setDestinationType('Databricks')).toFinishAllListeners()
+
+ expect(logic.values.destinationForm.integrationKind).toEqual('databricks')
+ })
+
+ it('lets a multi-kind type switch provider without changing type', async () => {
+ // S3 covers AWS and every S3-compatible provider, and the connection list is per kind.
+ await expectLogic(logic, () => logic.actions.openForCreate()).toFinishAllListeners()
+ await expectLogic(logic, () => logic.actions.setDestinationType('S3')).toFinishAllListeners()
+ expect(logic.values.destinationForm.integrationKind).toEqual('aws-s3')
+
+ await expectLogic(logic, () => logic.actions.setIntegrationKind('s3-compatible')).toFinishAllListeners()
+
+ expect(logic.values.destinationForm.type).toEqual('S3')
+ expect(logic.values.destinationForm.integrationKind).toEqual('s3-compatible')
+ })
+
+ it('reports the picked type as invalid until its own required fields are filled', async () => {
+ await expectLogic(logic, () => logic.actions.openForCreate()).toFinishAllListeners()
+ await expectLogic(logic, () => logic.actions.setDestinationType('Snowflake')).toFinishAllListeners()
+
+ logic.actions.setDestinationFormValue('name', 'Snowflake copy')
+ logic.actions.setDestinationFormValue('integrationId', 1)
+ // `database` and `warehouse` are still empty.
+ expect(logic.values.isDestinationFormValid).toBe(false)
+
+ logic.actions.setDestinationFormValue('database', 'DB')
+ logic.actions.setDestinationFormValue('warehouse', 'WH')
+
+ expect(logic.values.isDestinationFormValid).toBe(true)
+ })
+})
diff --git a/products/data_warehouse/frontend/shared/logics/destinationModalLogic.ts b/products/data_warehouse/frontend/shared/logics/destinationModalLogic.ts
index e370a2de5e28..f4cec8e7d0c5 100644
--- a/products/data_warehouse/frontend/shared/logics/destinationModalLogic.ts
+++ b/products/data_warehouse/frontend/shared/logics/destinationModalLogic.ts
@@ -8,8 +8,18 @@ import { LemonDialog } from 'lib/lemon-ui/LemonDialog'
import { lemonToast } from 'lib/lemon-ui/LemonToast/LemonToast'
import { teamLogic } from 'scenes/teamLogic'
-import type { IntegrationType } from '~/types'
+import type { IntegrationKind, IntegrationType } from '~/types'
+import {
+ WAREHOUSE_DESTINATIONS,
+ buildDestinationConfig,
+ buildDestinationFormValues,
+ validateDestinationFields,
+} from 'products/data_warehouse/frontend/shared/destinations/destinationDefinitions'
+import type {
+ CreatableDestinationType,
+ WarehouseDestinationDefinition,
+} from 'products/data_warehouse/frontend/shared/destinations/types'
import {
externalDataDestinationsCreate,
externalDataDestinationsDestroy,
@@ -25,24 +35,33 @@ export interface DestinationModalLogicProps {
onDeleted?: (destinationId: string) => void
}
-export interface DestinationFormValues {
+/** The type's own config fields are flattened in, so each is a plain `LemonField` name. */
+export interface DestinationFormValues extends Record<string, any> {
name: string
+ type: CreatableDestinationType
integrationId: number | null
- database: string
- schema: string
+ integrationKind: IntegrationKind
}
-const NEW_DESTINATION_FORM: DestinationFormValues = {
- name: '',
- integrationId: null,
- database: 'postgres',
- schema: 'public',
+const DEFAULT_TYPE: CreatableDestinationType = 'Postgres'
+
+export function newDestinationForm(type: CreatableDestinationType = DEFAULT_TYPE): DestinationFormValues {
+ const definition = WAREHOUSE_DESTINATIONS[type]
+ return {
+ name: '',
+ type,
+ integrationId: null,
+ integrationKind: definition.integrationKinds[0],
+ ...definition.defaults(),
+ }
}
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface destinationModalLogicValues {
integrations: IntegrationType[] | null // integrationsLogic
currentTeamId: number | null // teamLogic
+ availableIntegrations: IntegrationType[]
+ definition: WarehouseDestinationDefinition
destinationForm: DestinationFormValues
destinationFormAllErrors: Record<string, any>
destinationFormChanged: boolean
@@ -57,7 +76,6 @@ export interface destinationModalLogicValues {
isDestinationFormSubmitting: boolean
isDestinationFormValid: boolean
isOpen: boolean
- postgresIntegrations: IntegrationType[]
showDestinationFormErrors: boolean
}
@@ -92,6 +110,56 @@ export interface destinationModalLogicActions {
setDestinationFormValues: (values: DeepPartial<DestinationFormValues>) => {
values: DeepPartial<DestinationFormValues>
}
+ setDestinationType: (type: CreatableDestinationType) => {
+ type: CreatableDestinationType
+ }
+ setIntegrationKind: (kind: IntegrationKind) => {
+ kind:
+ | 'apns'
+ | 'aws-redshift'
+ | 'aws-s3'
+ | 'azure-blob'
+ | 'bing-ads'
+ | 'clickup'
+ | 'customerio-app'
+ | 'customerio-track'
+ | 'customerio-webhook'
+ | 'databricks'
+ | 'email'
+ | 'firebase'
+ | 'github'
+ | 'gitlab'
+ | 'google-ads'
+ | 'google-analytics'
+ | 'google-calendar'
+ | 'google-cloud-service-account'
+ | 'google-cloud-storage'
+ | 'google-pubsub'
+ | 'google-search-console'
+ | 'google-sheets'
+ | 'helpscout'
+ | 'hubspot'
+ | 'instagram'
+ | 'intercom'
+ | 'jira'
+ | 'linear'
+ | 'linkedin-ads'
+ | 'meta-ads'
+ | 'pardot'
+ | 'pinterest-ads'
+ | 'postgresql'
+ | 'reddit-ads'
+ | 's3-compatible'
+ | 'salesforce'
+ | 'slack'
+ | 'snapchat'
+ | 'snowflake'
+ | 'stripe'
+ | 'tiktok-ads'
+ | 'twilio'
+ | 'vercel'
+ | 'youtube-analytics'
+ }
submitDestinationForm: () => {
value: boolean
}
@@ -117,7 +185,8 @@ export interface destinationModalLogicActions {
export interface destinationModalLogicMeta {
key: string
__keaTypeGenInternalSelectorTypes: {
- postgresIntegrations: (integrations: any) => IntegrationType[]
+ definition: (destinationForm: any) => WarehouseDestinationDefinition
+ availableIntegrations: (integrations: any, destinationForm: any) => IntegrationType[]
editingIntegration: (editing: any, integrations: any) => IntegrationType | null
}
}
@@ -142,6 +211,8 @@ export const destinationModalLogic = kea<destinationModalLogicType>([
openForEdit: (destination: ExternalDataDestinationApi) => ({ destination }),
closeModal: true,
deleteDestination: (destination: ExternalDataDestinationApi) => ({ destination }),
+ setDestinationType: (type: CreatableDestinationType) => ({ type }),
+ setIntegrationKind: (kind: IntegrationKind) => ({ kind }),
}),
reducers({
isOpen: [
@@ -161,36 +232,27 @@ export const destinationModalLogic = kea<destinationModalLogicType>([
},
],
}),
- selectors({
- postgresIntegrations: [
- (s: any) => [s.integrations],
- (integrations: IntegrationType[] | null): IntegrationType[] =>
- (integrations ?? []).filter((integration) => integration.kind === 'postgresql'),
- ],
- // The connection a destination already has, so editing can show it without offering to
- // change it. Null while integrations load, or if the integration was deleted.
- editingIntegration: [
- (s: any) => [s.editing, s.integrations],
- (
- editing: ExternalDataDestinationApi | null,
- integrations: IntegrationType[] | null
- ): IntegrationType | null =>
- (editing?.integration && integrations?.find((one) => one.id === editing.integration)) || null,
- ],
- }),
forms(({ values, props, actions }: any) => ({
destinationForm: {
- defaults: NEW_DESTINATION_FORM,
- errors: ({ name, integrationId }: DestinationFormValues) => ({
- name: !name?.trim() ? 'Give this destination a name' : undefined,
- integrationId: integrationId ? undefined : 'Pick a connection',
+ defaults: newDestinationForm(),
+ errors: (formValues: DestinationFormValues) => ({
+ name: !formValues.name?.trim() ? 'Give this destination a name' : undefined,
+ integrationId: formValues.integrationId ? undefined : 'Pick a connection',
+ ...validateDestinationFields(
+ WAREHOUSE_DESTINATIONS[formValues.type] ?? WAREHOUSE_DESTINATIONS[DEFAULT_TYPE],
+ {
+ isNew: !values.editing,
+ formValues,
+ }
+ ),
}),
submit: async (formValues: DestinationFormValues) => {
+ const definition = WAREHOUSE_DESTINATIONS[formValues.type] ?? WAREHOUSE_DESTINATIONS[DEFAULT_TYPE]
const payload = {
- type: 'Postgres' as const,
+ type: formValues.type,
name: formValues.name.trim(),
integration: formValues.integrationId,
- config: { database: formValues.database, schema: formValues.schema },
+ config: buildDestinationConfig(definition, formValues),
}
const teamId = String(values.currentTeamId)
const saved = values.editing
@@ -203,6 +265,29 @@ export const destinationModalLogic = kea<destinationModalLogicType>([
},
},
})),
+ // Declared after `forms`, because `definition` and `availableIntegrations` read
+ // `destinationForm`, and the forms plugin only adds that value when it is applied.
+ selectors({
+ definition: [
+ (s: any) => [s.destinationForm],
+ (destinationForm: DestinationFormValues): WarehouseDestinationDefinition =>
+ WAREHOUSE_DESTINATIONS[destinationForm.type] ?? WAREHOUSE_DESTINATIONS[DEFAULT_TYPE],
+ ],
+ availableIntegrations: [
+ (s: any) => [s.integrations, s.destinationForm],
+ (integrations: IntegrationType[] | null, destinationForm: DestinationFormValues): IntegrationType[] =>
+ (integrations ?? []).filter((integration) => integration.kind === destinationForm.integrationKind),
+ ],
+ // Null while integrations load, or if the integration was deleted.
+ editingIntegration: [
+ (s: any) => [s.editing, s.integrations],
+ (
+ editing: ExternalDataDestinationApi | null,
+ integrations: IntegrationType[] | null
+ ): IntegrationType | null =>
+ (editing?.integration && integrations?.find((one) => one.id === editing.integration)) || null,
+ ],
+ }),
listeners(({ actions, values, props }: any) => ({
deleteDestination: ({ destination }: { destination: ExternalDataDestinationApi }) => {
LemonDialog.open({
@@ -230,21 +315,49 @@ export const destinationModalLogic = kea<destinationModalLogicType>([
},
openForCreate: () => {
actions.loadIntegrations()
- actions.setDestinationFormValues({
- ...NEW_DESTINATION_FORM,
- // One connection usually means one obvious answer; preselect it.
- integrationId: values.postgresIntegrations.length === 1 ? values.postgresIntegrations[0].id : null,
- })
+ actions.resetDestinationForm(newDestinationForm())
+ actions.setDestinationType(DEFAULT_TYPE)
},
openForEdit: ({ destination }: { destination: ExternalDataDestinationApi }) => {
actions.loadIntegrations()
- const config = (destination.config ?? {}) as Record<string, unknown>
- actions.setDestinationFormValues({
+ const type = destination.type as CreatableDestinationType
+ const definition = WAREHOUSE_DESTINATIONS[type]
+ if (!definition) {
+ lemonToast.error(`${destination.name} has an unsupported type and cannot be edited here`)
+ actions.closeModal()
+ return
+ }
+ const config = (destination.config ?? {}) as Record<string, any>
+ actions.resetDestinationForm({
name: destination.name,
+ type,
integrationId: destination.integration ?? null,
- database: typeof config.database === 'string' ? config.database : 'postgres',
- schema: typeof config.schema === 'string' ? config.schema : 'public',
+ integrationKind: definition.integrationKinds[0],
+ ...buildDestinationFormValues(definition, config),
})
},
+ // Carrying the old type's fields over would leave values in the form that
+ // `buildDestinationConfig` then drops silently at save time.
+ setDestinationType: ({ type }: { type: CreatableDestinationType }) => {
+ const name = values.destinationForm.name
+ actions.resetDestinationForm({ ...newDestinationForm(type), name })
+ actions.setIntegrationKind(WAREHOUSE_DESTINATIONS[type].integrationKinds[0])
+ },
+ setIntegrationKind: ({ kind }: { kind: IntegrationKind }) => {
+ const matching = (values.integrations ?? []).filter((one: IntegrationType) => one.kind === kind)
+ actions.setDestinationFormValues({
+ integrationKind: kind,
+ integrationId: matching.length === 1 ? matching[0].id : null,
+ })
+ },
+ // Integrations arrive after the modal opens, so the preselect has to run again once they
+ // do. Keyed off `integrationsLogic`'s own action: a bare `loadIntegrationsSuccess` key
+ // would register a listener for an action this logic does not have, and never fire.
+ [integrationsLogic.actionTypes.loadIntegrationsSuccess]: () => {
+ if (values.editing || values.destinationForm.integrationId) {
+ return
+ }
+ actions.setIntegrationKind(values.destinationForm.integrationKind)
+ },
})),
])
diff --git a/products/warehouse_sources/backend/presentation/views/external_data_destination.py b/products/warehouse_sources/backend/presentation/views/external_data_destination.py
index e1a8dc825239..8b9254837e26 100644
--- a/products/warehouse_sources/backend/presentation/views/external_data_destination.py
+++ b/products/warehouse_sources/backend/presentation/views/external_data_destination.py
@@ -184,7 +184,23 @@ class ExternalDataDestinationSerializer(serializers.ModelSerializer):
# Where a destination points is fixed once it exists. Everything already synced sits at the
# current server and schema, so repointing one strands that data and needs a full resync of
# every table that syncs there. A second destination is the supported way to write elsewhere.
- RETARGETING_FIELDS = ("database", "schema")
+ # Config fields that pin where a destination's already-synced rows live, per type. Changing
+ # one points the destination somewhere else and strands everything written so far, so they
+ # are fixed after creation. Mirrors `retargetingKeys` on each definition in
+ # products/data_warehouse/frontend/shared/destinations/.
+ #
+ # Aliases are listed alongside the name the writer prefers: S3 reads `bucket` or
+ # `bucket_name` and Azure Blob reads `container_name` or `container`, so guarding only one
+ # spelling would let the other through.
+ RETARGETING_FIELDS_BY_TYPE: dict[str, tuple[str, ...]] = {
+ str(ExternalDataDestination.Type.POSTGRES): ("database", "schema"),
+ str(ExternalDataDestination.Type.REDSHIFT): ("database", "schema"),
+ str(ExternalDataDestination.Type.SNOWFLAKE): ("database", "schema"),
+ str(ExternalDataDestination.Type.DATABRICKS): ("catalog", "schema"),
+ str(ExternalDataDestination.Type.BIGQUERY): ("dataset", "dataset_id", "project", "project_id"),
+ str(ExternalDataDestination.Type.S3): ("bucket", "bucket_name", "prefix"),
+ str(ExternalDataDestination.Type.AZURE_BLOB): ("container_name", "container", "prefix"),
+ }
def _reject_retargeting(self, attrs: dict[str, Any]) -> None:
assert self.instance is not None
@@ -203,13 +219,15 @@ class ExternalDataDestinationSerializer(serializers.ModelSerializer):
current = self.instance.config or {}
incoming = attrs["config"] or {}
- for field in self.RETARGETING_FIELDS:
+ destination_type = attrs.get("type", getattr(self.instance, "type", None))
+ for field in self.RETARGETING_FIELDS_BY_TYPE.get(str(destination_type), ()):
if field in incoming and incoming[field] != current.get(field):
+ label = field.replace("_", " ")
raise ValidationError(
{
"config": (
- f"A destination keeps the {field} it was created with. Add a second "
- f"destination for the other {field}."
+ f"A destination keeps the {label} it was created with. Add a second "
+ f"destination for the other {label}."
)
}
)
@@ -222,6 +240,17 @@ class ExternalDataDestinationSerializer(serializers.ModelSerializer):
**validated_data,
)
+ def update(self, instance: ExternalDataDestination, validated_data: dict[str, Any]) -> ExternalDataDestination:
+ # `config` is a single JSON blob, so a PATCH that includes it replaces the whole thing.
+ # A caller that means to change one key (say `compression`) without repeating every other
+ # key would otherwise silently drop `database`/`schema` and strand already-synced rows,
+ # the exact outcome `_reject_retargeting` exists to prevent. Merging onto the current
+ # config keeps every field `_reject_retargeting` did not see change.
+ if "config" in validated_data:
+ current = instance.config or {}
+ validated_data["config"] = {**current, **validated_data["config"]}
+ return super().update(instance, validated_data)
+
class ExternalDataDestinationViewSet(TeamAndOrgViewSetMixin, viewsets.ModelViewSet):
"""Manage where warehouse sources write their synced rows.
diff --git a/products/warehouse_sources/backend/temporal/data_imports/pipelines/pipeline_v3/destinations_load/builtin_writers.py b/products/warehouse_sources/backend/temporal/data_imports/pipelines/pipeline_v3/destinations_load/builtin_writers.py
index 370d667bfee1..910f50c28522 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/pipelines/pipeline_v3/destinations_load/builtin_writers.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/pipelines/pipeline_v3/destinations_load/builtin_writers.py
@@ -1,9 +1,9 @@
"""Registering the writers that ship with warehouse sources.
-Postgres, Redshift, Snowflake, Databricks, S3, BigQuery and Azure Blob ship here. The other destination types have writers built on batch exports'
-clients, parked on `tom/dwh-destination-writers-parked`, and each one lands in its own change
-once it has been run against that warehouse. Registering a type whose writer has never
-executed is how a customer discovers it does not work.
+Every destination type `ExternalDataDestination.Type` offers ships here: Postgres, Redshift,
+Snowflake, Databricks, S3, BigQuery and Azure Blob. A type registered here is one a person can
+pick in the UI, so a writer that has never run against its warehouse must not be added:
+registering one is how a customer discovers it does not work.
Registration happens on first use rather than at a bootstrap step, so any entry point into
delivery resolves a writer. Each writer pulls in its vendor driver, so the imports stay inside
diff --git a/products/warehouse_sources/backend/tests/api/test_external_data_destination.py b/products/warehouse_sources/backend/tests/api/test_external_data_destination.py
index 5f415c3bde7f..6608c7464fa5 100644
--- a/products/warehouse_sources/backend/tests/api/test_external_data_destination.py
+++ b/products/warehouse_sources/backend/tests/api/test_external_data_destination.py
@@ -5,6 +5,7 @@ from unittest.mock import patch
from django.db import connection
from django.test.utils import CaptureQueriesContext
+from parameterized import parameterized
from rest_framework import status
from rest_framework.exceptions import PermissionDenied
@@ -105,14 +106,65 @@ class TestExternalDataDestinationAPI(DestinationAPITestBase):
assert response.status_code == status.HTTP_400_BAD_REQUEST
assert "integration" in response.json()["attr"]
- def test_the_target_database_and_schema_cannot_be_changed(self) -> None:
- destination = self._create_destination()
+ @parameterized.expand(
+ [
+ (ExternalDataDestination.Type.POSTGRES, Integration.IntegrationKind.POSTGRESQL, ("database", "schema")),
+ (ExternalDataDestination.Type.REDSHIFT, Integration.IntegrationKind.AWS_REDSHIFT, ("database", "schema")),
+ (ExternalDataDestination.Type.SNOWFLAKE, Integration.IntegrationKind.SNOWFLAKE, ("database", "schema")),
+ (ExternalDataDestination.Type.DATABRICKS, Integration.IntegrationKind.DATABRICKS, ("catalog", "schema")),
+ (
+ ExternalDataDestination.Type.BIGQUERY,
+ Integration.IntegrationKind.GOOGLE_CLOUD_SERVICE_ACCOUNT,
+ ("dataset", "project"),
+ ),
+ (ExternalDataDestination.Type.S3, Integration.IntegrationKind.AWS_S3, ("bucket", "prefix")),
+ (
+ ExternalDataDestination.Type.AZURE_BLOB,
+ Integration.IntegrationKind.AZURE_BLOB,
+ ("container_name", "prefix"),
+ ),
+ ]
+ )
+ def test_the_target_cannot_be_changed(self, destination_type: str, kind: str, fields: tuple[str, ...]) -> None:
+ # Every type pins where its rows land, on its own field names. A type missing from
+ # `RETARGETING_FIELDS_BY_TYPE` would accept a retarget silently and strand everything
+ # already written there.
+ destination = self._create_destination(
+ type=destination_type,
+ integration=self._integration(kind).pk,
+ config=dict.fromkeys(fields, "original"),
+ )
- for field in ("database", "schema"):
+ for field in fields:
response = self.client.patch(f"{self.base}/{destination.id}", {"config": {field: "somewhere_else"}})
- assert response.status_code == status.HTTP_400_BAD_REQUEST, field
- assert "config" in response.json()["attr"], field
+ assert response.status_code == status.HTTP_400_BAD_REQUEST, f"{destination_type}.{field}"
+ assert "config" in response.json()["attr"], f"{destination_type}.{field}"
+
+ @parameterized.expand(
+ [
+ (ExternalDataDestination.Type.S3, Integration.IntegrationKind.AWS_S3, "bucket", "bucket_name"),
+ (
+ ExternalDataDestination.Type.AZURE_BLOB,
+ Integration.IntegrationKind.AZURE_BLOB,
+ "container_name",
+ "container",
+ ),
+ ]
+ )
+ def test_the_target_cannot_be_changed_through_its_alias(
+ self, destination_type: str, kind: str, stored: str, alias: str
+ ) -> None:
+ # These writers read either spelling, so guarding only the preferred one would let a
+ # retarget through under the other name.
+ destination = self._create_destination(
+ type=destination_type, integration=self._integration(kind).pk, config={stored: "original"}
+ )
+
+ response = self.client.patch(f"{self.base}/{destination.id}", {"config": {alias: "somewhere_else"}})
+
+ assert response.status_code == status.HTTP_400_BAD_REQUEST
+ assert "config" in response.json()["attr"]
def test_the_name_can_still_be_changed(self) -> None:
destination = self._create_destination()
@@ -134,6 +186,17 @@ class TestExternalDataDestinationAPI(DestinationAPITestBase):
assert response.status_code == status.HTTP_200_OK, response.json()
+ def test_a_partial_config_update_keeps_the_fields_it_did_not_mention(self) -> None:
+ # `config` is one JSON blob. A PATCH naming only the key it means to change must not
+ # replace the whole blob and silently drop the target fields alongside it.
+ destination = self._create_destination(config={"database": "analytics", "schema": "public"})
+
+ response = self.client.patch(f"{self.base}/{destination.id}", {"config": {"ssl_mode": "require"}})
+
+ assert response.status_code == status.HTTP_200_OK, response.json()
+ destination.refresh_from_db()
+ assert destination.config == {"database": "analytics", "schema": "public", "ssl_mode": "require"}
+
def test_delete_detaches_everything_that_synced_to_it(self) -> None:
destination = self._create_destination()
ExternalDataSourceDestination.objects.for_team(self.team.pk).create(