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): auto-sync new schemas on warehouse sources (#71853)

estefania23829f160323
diff --git a/frontend/src/lib/api.ts b/frontend/src/lib/api.ts
index 9f98c1560f45..139e48516910 100644
--- a/frontend/src/lib/api.ts
+++ b/frontend/src/lib/api.ts
@@ -5914,6 +5914,7 @@ const api = {
async refreshSchemas(sourceId: ExternalDataSource['id']): Promise<{
added: number
deleted: number
+ auto_enabled: number
total_tables_seen: number
}> {
return await new ApiRequest().externalDataSource(sourceId).withAction('refresh_schemas').create()
diff --git a/frontend/src/types.ts b/frontend/src/types.ts
index e94f2d561158..eac34e328d3e 100644
--- a/frontend/src/types.ts
+++ b/frontend/src/types.ts
@@ -6181,6 +6181,8 @@ export interface ExternalDataSource {
description: string | null
access_method?: 'warehouse' | 'direct'
direct_query_enabled?: boolean
+ auto_sync_new_schemas?: boolean
+ auto_sync_schema_patterns?: string[] | null
created_via: 'web' | 'api' | 'mcp' | 'wizard' | null
engine?: 'duckdb' | 'postgres' | 'mysql' | 'snowflake' | 'redshift' | null
latest_error: string | null
diff --git a/posthog/api/test/__snapshots__/test_element.ambr b/posthog/api/test/__snapshots__/test_element.ambr
index 0f5a9f7b1579..806996abe943 100644
--- a/posthog/api/test/__snapshots__/test_element.ambr
+++ b/posthog/api/test/__snapshots__/test_element.ambr
@@ -110,6 +110,8 @@
"posthog_externaldatasource"."created_via",
"posthog_externaldatasource"."access_method",
"posthog_externaldatasource"."direct_query_enabled",
+ "posthog_externaldatasource"."auto_sync_new_schemas",
+ "posthog_externaldatasource"."auto_sync_schema_patterns",
"posthog_externaldatasource"."revenue_analytics_enabled",
"posthog_externaldatasourcerevenueanalyticsconfig"."external_data_source_id",
"posthog_externaldatasourcerevenueanalyticsconfig"."enabled",
diff --git a/posthog/hogql/database/test/__snapshots__/test_database.ambr b/posthog/hogql/database/test/__snapshots__/test_database.ambr
index a645e4ccd460..cb717f98d0c0 100644
--- a/posthog/hogql/database/test/__snapshots__/test_database.ambr
+++ b/posthog/hogql/database/test/__snapshots__/test_database.ambr
@@ -315,6 +315,8 @@
"posthog_externaldatasource"."created_via",
"posthog_externaldatasource"."access_method",
"posthog_externaldatasource"."direct_query_enabled",
+ "posthog_externaldatasource"."auto_sync_new_schemas",
+ "posthog_externaldatasource"."auto_sync_schema_patterns",
"posthog_externaldatasource"."revenue_analytics_enabled",
"posthog_externaldatasourcerevenueanalyticsconfig"."external_data_source_id",
"posthog_externaldatasourcerevenueanalyticsconfig"."enabled",
@@ -655,6 +657,8 @@
"posthog_externaldatasource"."created_via",
"posthog_externaldatasource"."access_method",
"posthog_externaldatasource"."direct_query_enabled",
+ "posthog_externaldatasource"."auto_sync_new_schemas",
+ "posthog_externaldatasource"."auto_sync_schema_patterns",
"posthog_externaldatasource"."revenue_analytics_enabled",
"posthog_externaldatasourcerevenueanalyticsconfig"."external_data_source_id",
"posthog_externaldatasourcerevenueanalyticsconfig"."enabled",
diff --git a/posthog/session_recordings/test/__snapshots__/test_session_recording_playlist.ambr b/posthog/session_recordings/test/__snapshots__/test_session_recording_playlist.ambr
index 529466f31060..bc933fdee994 100644
--- a/posthog/session_recordings/test/__snapshots__/test_session_recording_playlist.ambr
+++ b/posthog/session_recordings/test/__snapshots__/test_session_recording_playlist.ambr
@@ -1246,6 +1246,8 @@
"posthog_externaldatasource"."created_via",
"posthog_externaldatasource"."access_method",
"posthog_externaldatasource"."direct_query_enabled",
+ "posthog_externaldatasource"."auto_sync_new_schemas",
+ "posthog_externaldatasource"."auto_sync_schema_patterns",
"posthog_externaldatasource"."revenue_analytics_enabled",
"posthog_externaldatasourcerevenueanalyticsconfig"."external_data_source_id",
"posthog_externaldatasourcerevenueanalyticsconfig"."enabled",
diff --git a/posthog/session_recordings/test/__snapshots__/test_session_recordings.ambr b/posthog/session_recordings/test/__snapshots__/test_session_recordings.ambr
index aa386a7a0b51..15621780bc75 100644
--- a/posthog/session_recordings/test/__snapshots__/test_session_recordings.ambr
+++ b/posthog/session_recordings/test/__snapshots__/test_session_recordings.ambr
@@ -764,6 +764,8 @@
"posthog_externaldatasource"."created_via",
"posthog_externaldatasource"."access_method",
"posthog_externaldatasource"."direct_query_enabled",
+ "posthog_externaldatasource"."auto_sync_new_schemas",
+ "posthog_externaldatasource"."auto_sync_schema_patterns",
"posthog_externaldatasource"."revenue_analytics_enabled",
"posthog_externaldatasourcerevenueanalyticsconfig"."external_data_source_id",
"posthog_externaldatasourcerevenueanalyticsconfig"."enabled",
@@ -1528,6 +1530,8 @@
"posthog_externaldatasource"."created_via",
"posthog_externaldatasource"."access_method",
"posthog_externaldatasource"."direct_query_enabled",
+ "posthog_externaldatasource"."auto_sync_new_schemas",
+ "posthog_externaldatasource"."auto_sync_schema_patterns",
"posthog_externaldatasource"."revenue_analytics_enabled",
"posthog_externaldatasourcerevenueanalyticsconfig"."external_data_source_id",
"posthog_externaldatasourcerevenueanalyticsconfig"."enabled",
@@ -2287,6 +2291,8 @@
"posthog_externaldatasource"."created_via",
"posthog_externaldatasource"."access_method",
"posthog_externaldatasource"."direct_query_enabled",
+ "posthog_externaldatasource"."auto_sync_new_schemas",
+ "posthog_externaldatasource"."auto_sync_schema_patterns",
"posthog_externaldatasource"."revenue_analytics_enabled",
"posthog_externaldatasourcerevenueanalyticsconfig"."external_data_source_id",
"posthog_externaldatasourcerevenueanalyticsconfig"."enabled",
@@ -3046,6 +3052,8 @@
"posthog_externaldatasource"."created_via",
"posthog_externaldatasource"."access_method",
"posthog_externaldatasource"."direct_query_enabled",
+ "posthog_externaldatasource"."auto_sync_new_schemas",
+ "posthog_externaldatasource"."auto_sync_schema_patterns",
"posthog_externaldatasource"."revenue_analytics_enabled",
"posthog_externaldatasourcerevenueanalyticsconfig"."external_data_source_id",
"posthog_externaldatasourcerevenueanalyticsconfig"."enabled",
@@ -3810,6 +3818,8 @@
"posthog_externaldatasource"."created_via",
"posthog_externaldatasource"."access_method",
"posthog_externaldatasource"."direct_query_enabled",
+ "posthog_externaldatasource"."auto_sync_new_schemas",
+ "posthog_externaldatasource"."auto_sync_schema_patterns",
"posthog_externaldatasource"."revenue_analytics_enabled",
"posthog_externaldatasourcerevenueanalyticsconfig"."external_data_source_id",
"posthog_externaldatasourcerevenueanalyticsconfig"."enabled",
@@ -4574,6 +4584,8 @@
"posthog_externaldatasource"."created_via",
"posthog_externaldatasource"."access_method",
"posthog_externaldatasource"."direct_query_enabled",
+ "posthog_externaldatasource"."auto_sync_new_schemas",
+ "posthog_externaldatasource"."auto_sync_schema_patterns",
"posthog_externaldatasource"."revenue_analytics_enabled",
"posthog_externaldatasourcerevenueanalyticsconfig"."external_data_source_id",
"posthog_externaldatasourcerevenueanalyticsconfig"."enabled",
@@ -5338,6 +5350,8 @@
"posthog_externaldatasource"."created_via",
"posthog_externaldatasource"."access_method",
"posthog_externaldatasource"."direct_query_enabled",
+ "posthog_externaldatasource"."auto_sync_new_schemas",
+ "posthog_externaldatasource"."auto_sync_schema_patterns",
"posthog_externaldatasource"."revenue_analytics_enabled",
"posthog_externaldatasourcerevenueanalyticsconfig"."external_data_source_id",
"posthog_externaldatasourcerevenueanalyticsconfig"."enabled",
@@ -6042,6 +6056,8 @@
"posthog_externaldatasource"."created_via",
"posthog_externaldatasource"."access_method",
"posthog_externaldatasource"."direct_query_enabled",
+ "posthog_externaldatasource"."auto_sync_new_schemas",
+ "posthog_externaldatasource"."auto_sync_schema_patterns",
"posthog_externaldatasource"."revenue_analytics_enabled",
"posthog_externaldatasourcerevenueanalyticsconfig"."external_data_source_id",
"posthog_externaldatasourcerevenueanalyticsconfig"."enabled",
@@ -6886,6 +6902,8 @@
"posthog_externaldatasource"."created_via",
"posthog_externaldatasource"."access_method",
"posthog_externaldatasource"."direct_query_enabled",
+ "posthog_externaldatasource"."auto_sync_new_schemas",
+ "posthog_externaldatasource"."auto_sync_schema_patterns",
"posthog_externaldatasource"."revenue_analytics_enabled",
"posthog_externaldatasourcerevenueanalyticsconfig"."external_data_source_id",
"posthog_externaldatasourcerevenueanalyticsconfig"."enabled",
@@ -7785,6 +7803,8 @@
"posthog_externaldatasource"."created_via",
"posthog_externaldatasource"."access_method",
"posthog_externaldatasource"."direct_query_enabled",
+ "posthog_externaldatasource"."auto_sync_new_schemas",
+ "posthog_externaldatasource"."auto_sync_schema_patterns",
"posthog_externaldatasource"."revenue_analytics_enabled",
"posthog_externaldatasourcerevenueanalyticsconfig"."external_data_source_id",
"posthog_externaldatasourcerevenueanalyticsconfig"."enabled",
@@ -8625,6 +8645,8 @@
"posthog_externaldatasource"."created_via",
"posthog_externaldatasource"."access_method",
"posthog_externaldatasource"."direct_query_enabled",
+ "posthog_externaldatasource"."auto_sync_new_schemas",
+ "posthog_externaldatasource"."auto_sync_schema_patterns",
"posthog_externaldatasource"."revenue_analytics_enabled",
"posthog_externaldatasourcerevenueanalyticsconfig"."external_data_source_id",
"posthog_externaldatasourcerevenueanalyticsconfig"."enabled",
@@ -9696,6 +9718,8 @@
"posthog_externaldatasource"."created_via",
"posthog_externaldatasource"."access_method",
"posthog_externaldatasource"."direct_query_enabled",
+ "posthog_externaldatasource"."auto_sync_new_schemas",
+ "posthog_externaldatasource"."auto_sync_schema_patterns",
"posthog_externaldatasource"."revenue_analytics_enabled",
"posthog_externaldatasourcerevenueanalyticsconfig"."external_data_source_id",
"posthog_externaldatasourcerevenueanalyticsconfig"."enabled",
@@ -10618,6 +10642,8 @@
"posthog_externaldatasource"."created_via",
"posthog_externaldatasource"."access_method",
"posthog_externaldatasource"."direct_query_enabled",
+ "posthog_externaldatasource"."auto_sync_new_schemas",
+ "posthog_externaldatasource"."auto_sync_schema_patterns",
"posthog_externaldatasource"."revenue_analytics_enabled",
"posthog_externaldatasourcerevenueanalyticsconfig"."external_data_source_id",
"posthog_externaldatasourcerevenueanalyticsconfig"."enabled",
@@ -11379,6 +11405,8 @@
"posthog_externaldatasource"."created_via",
"posthog_externaldatasource"."access_method",
"posthog_externaldatasource"."direct_query_enabled",
+ "posthog_externaldatasource"."auto_sync_new_schemas",
+ "posthog_externaldatasource"."auto_sync_schema_patterns",
"posthog_externaldatasource"."revenue_analytics_enabled",
"posthog_externaldatasourcerevenueanalyticsconfig"."external_data_source_id",
"posthog_externaldatasourcerevenueanalyticsconfig"."enabled",
@@ -12270,6 +12298,8 @@
"posthog_externaldatasource"."created_via",
"posthog_externaldatasource"."access_method",
"posthog_externaldatasource"."direct_query_enabled",
+ "posthog_externaldatasource"."auto_sync_new_schemas",
+ "posthog_externaldatasource"."auto_sync_schema_patterns",
"posthog_externaldatasource"."revenue_analytics_enabled",
"posthog_externaldatasourcerevenueanalyticsconfig"."external_data_source_id",
"posthog_externaldatasourcerevenueanalyticsconfig"."enabled",
@@ -13108,6 +13138,8 @@
"posthog_externaldatasource"."created_via",
"posthog_externaldatasource"."access_method",
"posthog_externaldatasource"."direct_query_enabled",
+ "posthog_externaldatasource"."auto_sync_new_schemas",
+ "posthog_externaldatasource"."auto_sync_schema_patterns",
"posthog_externaldatasource"."revenue_analytics_enabled",
"posthog_externaldatasourcerevenueanalyticsconfig"."external_data_source_id",
"posthog_externaldatasourcerevenueanalyticsconfig"."enabled",
@@ -13144,6 +13176,8 @@
"posthog_externaldatasource"."created_via",
"posthog_externaldatasource"."access_method",
"posthog_externaldatasource"."direct_query_enabled",
+ "posthog_externaldatasource"."auto_sync_new_schemas",
+ "posthog_externaldatasource"."auto_sync_schema_patterns",
"posthog_externaldatasource"."revenue_analytics_enabled",
"posthog_externaldatasourcerevenueanalyticsconfig"."external_data_source_id",
"posthog_externaldatasourcerevenueanalyticsconfig"."enabled",
@@ -13965,6 +13999,8 @@
"posthog_externaldatasource"."created_via",
"posthog_externaldatasource"."access_method",
"posthog_externaldatasource"."direct_query_enabled",
+ "posthog_externaldatasource"."auto_sync_new_schemas",
+ "posthog_externaldatasource"."auto_sync_schema_patterns",
"posthog_externaldatasource"."revenue_analytics_enabled",
"posthog_externaldatasourcerevenueanalyticsconfig"."external_data_source_id",
"posthog_externaldatasourcerevenueanalyticsconfig"."enabled",
diff --git a/products/data_warehouse/backend/presentation/views/external_data_source.py b/products/data_warehouse/backend/presentation/views/external_data_source.py
index cfa88aeb2c31..c437f281ab49 100644
--- a/products/data_warehouse/backend/presentation/views/external_data_source.py
+++ b/products/data_warehouse/backend/presentation/views/external_data_source.py
@@ -120,6 +120,7 @@ from products.warehouse_sources.backend.facade.models import (
ExternalDataSchema,
ExternalDataSource,
PendingSourceCredential,
+ auto_enable_new_schemas,
sync_old_schemas_with_new_schemas,
update_sync_type_config_keys,
)
@@ -771,6 +772,30 @@ class ExternalDataSourceSerializers(UserAccessControlSerializerMixin, serializer
"Defaults to false for new sources; ignored for pure direct-query sources."
),
)
+ auto_sync_new_schemas = serializers.BooleanField(
+ required=False,
+ help_text=(
+ "Automatically enable syncing for schemas discovered on this source after creation, "
+ "on both the scheduled discovery pass and manual schema refreshes. Defaults to false. "
+ "Not supported for direct-query sources."
+ ),
+ )
+ auto_sync_schema_patterns = serializers.ListField(
+ child=serializers.CharField(
+ max_length=250,
+ allow_blank=False,
+ help_text="An fnmatch-style glob pattern, e.g. `raw_*`.",
+ ),
+ required=False,
+ allow_null=True,
+ max_length=100,
+ help_text=(
+ "Optional fnmatch-style globs (`*` and `?` wildcards) restricting which newly discovered "
+ "schema names auto-sync, matched case-insensitively against both the qualified and bare "
+ "table name. Null or empty means every new schema qualifies. Only used when "
+ "`auto_sync_new_schemas` is true."
+ ),
+ )
api_version = serializers.CharField(
read_only=True,
allow_null=True,
@@ -803,6 +828,8 @@ class ExternalDataSourceSerializers(UserAccessControlSerializerMixin, serializer
"description",
"access_method",
"direct_query_enabled",
+ "auto_sync_new_schemas",
+ "auto_sync_schema_patterns",
"engine",
"last_run_at",
"schemas",
@@ -954,6 +981,13 @@ class ExternalDataSourceSerializers(UserAccessControlSerializerMixin, serializer
validated_data.pop("access_method", None)
# created_via is set at creation time and cannot be mutated afterwards
validated_data.pop("created_via", None)
+
+ if validated_data.get("auto_sync_new_schemas") and instance.is_direct_query:
+ raise ValidationError(
+ "Auto-syncing new schemas is not supported for direct query sources, "
+ "because their schemas resolve at query time."
+ )
+
incoming_prefix = validated_data.get("prefix", instance.prefix)
if instance.is_direct_query:
@@ -2797,6 +2831,7 @@ class ExternalDataSourceViewSet(TeamAndOrgViewSetMixin, AccessControlViewSetMixi
"properties": {
"added": {"type": "integer"},
"deleted": {"type": "integer"},
+ "auto_enabled": {"type": "integer"},
"total_tables_seen": {"type": "integer"},
},
}
@@ -2941,12 +2976,22 @@ class ExternalDataSourceViewSet(TeamAndOrgViewSetMixin, AccessControlViewSetMixi
# ClickHouse isn't a SQLSource but exposes the same column-selection
# capability and reconcile hook, so it reuses this path.
source.reconcile_schema_metadata(source=instance, source_schemas=schemas, team_id=self.team_id)
+
+ # Outside the atomic block: schedule creation talks to Temporal, which must not run under
+ # the source row lock or against rows that could still roll back. `schemas_created` holds
+ # post-substitution stored names, so remap the discovered names to match.
+ auto_enabled_names: list[str] = []
+ if schemas_created:
+ source_schemas_by_name = {name_substitutions.get(s.name, s.name): s for s in schemas}
+ auto_enabled_names = auto_enable_new_schemas(instance, schemas_created, source_schemas_by_name)
+
logger.debug(
"refresh_schemas completed",
source_id=str(instance.id),
team_id=self.team_id,
added=len(schemas_created),
deleted=len(schemas_deleted),
+ auto_enabled=len(auto_enabled_names),
total_tables_seen=len(schemas),
)
return Response(
@@ -2954,6 +2999,7 @@ class ExternalDataSourceViewSet(TeamAndOrgViewSetMixin, AccessControlViewSetMixi
data={
"added": len(schemas_created),
"deleted": len(schemas_deleted),
+ "auto_enabled": len(auto_enabled_names),
"total_tables_seen": len(schemas),
},
)
diff --git a/products/data_warehouse/backend/tests/api/test_external_data_source.py b/products/data_warehouse/backend/tests/api/test_external_data_source.py
index 5d1fd1dffef1..19ae33655227 100644
--- a/products/data_warehouse/backend/tests/api/test_external_data_source.py
+++ b/products/data_warehouse/backend/tests/api/test_external_data_source.py
@@ -2460,6 +2460,8 @@ class TestExternalDataSource(APIBaseTest):
"description",
"access_method",
"direct_query_enabled",
+ "auto_sync_new_schemas",
+ "auto_sync_schema_patterns",
"engine",
"last_run_at",
"schemas",
@@ -2658,6 +2660,7 @@ class TestExternalDataSource(APIBaseTest):
data = response.json()
self.assertEqual(data["added"], 2)
self.assertEqual(data["deleted"], 0)
+ self.assertEqual(data["auto_enabled"], 0)
self.assertEqual(data["total_tables_seen"], 2)
self.assertEqual(
ExternalDataSchema.objects.filter(team_id=self.team.pk, source_id=source.pk, deleted=False).count(), 2
@@ -2669,6 +2672,90 @@ class TestExternalDataSource(APIBaseTest):
)
self.assertCountEqual(names, ["table_a", "table_b"])
+ @patch("products.data_warehouse.backend.facade.api.sync_external_data_job_workflow")
+ @patch("products.data_warehouse.backend.presentation.views.external_data_source.SourceRegistry.get_source")
+ def test_refresh_schemas_auto_enables_matching_new_schemas(self, mock_get_source, mock_schedule):
+ mock_get_source.return_value.parse_config.return_value = None
+ mock_get_source.return_value.get_schemas.return_value = [
+ SourceSchema(
+ name="raw_events",
+ supports_incremental=True,
+ supports_append=False,
+ incremental_fields=[
+ {
+ "label": "updated_at",
+ "type": IncrementalFieldType.DateTime,
+ "field": "updated_at",
+ "field_type": IncrementalFieldType.DateTime,
+ }
+ ],
+ ),
+ SourceSchema(name="audit_log", supports_incremental=False, supports_append=False),
+ ]
+ source = self._create_external_data_source()
+ source.auto_sync_new_schemas = True
+ source.auto_sync_schema_patterns = ["raw_*"]
+ source.save()
+
+ response = self.client.post(
+ f"/api/environments/{self.team.pk}/external_data_sources/{source.pk}/refresh_schemas/"
+ )
+
+ self.assertEqual(response.status_code, 200)
+ data = response.json()
+ self.assertEqual(data["added"], 2)
+ self.assertEqual(data["auto_enabled"], 1)
+ enabled = ExternalDataSchema.objects.get(team_id=self.team.pk, source_id=source.pk, name="raw_events")
+ self.assertTrue(enabled.should_sync)
+ self.assertEqual(enabled.sync_type, ExternalDataSchema.SyncType.INCREMENTAL)
+ self.assertEqual(enabled.sync_type_config.get("incremental_field"), "updated_at")
+ disabled = ExternalDataSchema.objects.get(team_id=self.team.pk, source_id=source.pk, name="audit_log")
+ self.assertFalse(disabled.should_sync)
+ mock_schedule.assert_called_once()
+
+ def test_update_source_auto_sync_new_schemas_fields(self):
+ source = self._create_external_data_source()
+
+ response = self.client.patch(
+ f"/api/environments/{self.team.pk}/external_data_sources/{source.pk}/",
+ data={"auto_sync_new_schemas": True, "auto_sync_schema_patterns": ["raw_*", "billing_?"]},
+ )
+
+ self.assertEqual(response.status_code, 200, response.content)
+ source.refresh_from_db()
+ self.assertTrue(source.auto_sync_new_schemas)
+ self.assertEqual(source.auto_sync_schema_patterns, ["raw_*", "billing_?"])
+
+ def test_update_source_rejects_auto_sync_for_direct_query(self):
+ source = ExternalDataSource.objects.create(
+ team_id=self.team.pk,
+ source_id=str(uuid.uuid4()),
+ connection_id=str(uuid.uuid4()),
+ destination_id=str(uuid.uuid4()),
+ source_type="Postgres",
+ access_method=ExternalDataSource.AccessMethod.DIRECT,
+ created_by=self.user,
+ prefix="direct source",
+ job_inputs={
+ "host": "172.16.0.0",
+ "port": "123",
+ "database": "database",
+ "user": "user",
+ "password": "password",
+ "schema": "public",
+ },
+ )
+
+ response = self.client.patch(
+ f"/api/environments/{self.team.pk}/external_data_sources/{source.pk}/",
+ data={"auto_sync_new_schemas": True},
+ )
+
+ self.assertEqual(response.status_code, 400, response.content)
+ self.assertIn("direct query sources", response.json()["detail"])
+ source.refresh_from_db()
+ self.assertFalse(source.auto_sync_new_schemas)
+
@patch("products.data_warehouse.backend.presentation.views.external_data_source.SourceRegistry.get_source")
def test_refresh_schemas_creates_new_schemas_and_deletes_missing_schemas(self, mock_get_source):
mock_get_source.return_value.parse_config.return_value = None
diff --git a/products/data_warehouse/frontend/scenes/SourceScene/tabs/ConfigurationTab.tsx b/products/data_warehouse/frontend/scenes/SourceScene/tabs/ConfigurationTab.tsx
index 3c827a39e628..3e2e57f1287f 100644
--- a/products/data_warehouse/frontend/scenes/SourceScene/tabs/ConfigurationTab.tsx
+++ b/products/data_warehouse/frontend/scenes/SourceScene/tabs/ConfigurationTab.tsx
@@ -2,9 +2,10 @@ import { BindLogic, useActions, useValues } from 'kea'
import { Form } from 'kea-forms'
import { useEffect, useState } from 'react'
-import { LemonButton, LemonSkeleton } from '@posthog/lemon-ui'
+import { LemonButton, LemonDivider, LemonInputSelect, LemonSkeleton, LemonSwitch } from '@posthog/lemon-ui'
import { AccessControlAction } from 'lib/components/AccessControlAction'
+import { LemonField } from 'lib/lemon-ui/LemonField'
import { urls } from 'scenes/urls'
import { AccessControlLevel, AccessControlResourceType } from '~/types'
@@ -35,7 +36,7 @@ export const ConfigurationTab = ({ id }: ConfigurationTabProps): JSX.Element =>
}
function UpdateSourceConnectionFormContainer(): JSX.Element {
- const { sourceFieldConfig, source, sourceConfigLoading } = useValues(sourceSettingsLogic)
+ const { sourceFieldConfig, source, sourceConfig, sourceConfigLoading } = useValues(sourceSettingsLogic)
const { setSourceConfigValue } = useActions(sourceSettingsLogic)
const [jobInputs, setJobInputs] = useState<Record<string, any>>({})
@@ -49,6 +50,8 @@ function UpdateSourceConnectionFormContainer(): JSX.Element {
setSourceConfigValue(['direct_query_enabled'], source.direct_query_enabled ?? false)
setSourceConfigValue(['prefix'], source.prefix ?? '')
setSourceConfigValue(['description'], source.description ?? '')
+ setSourceConfigValue(['auto_sync_new_schemas'], source.auto_sync_new_schemas ?? false)
+ setSourceConfigValue(['auto_sync_schema_patterns'], source.auto_sync_schema_patterns ?? [])
setJobInputs({
...buildKeaFormDefaultFromSourceDetails({ [source.source_type]: sourceFieldConfig })['payload'],
...source.job_inputs,
@@ -60,8 +63,11 @@ function UpdateSourceConnectionFormContainer(): JSX.Element {
source?.direct_query_enabled,
source?.prefix,
source?.description,
+ source?.auto_sync_new_schemas,
setSourceConfigValue,
// oxlint-disable-next-line exhaustive-deps
+ JSON.stringify(source?.auto_sync_schema_patterns ?? []),
+ // oxlint-disable-next-line exhaustive-deps
JSON.stringify(source?.job_inputs ?? {}),
// oxlint-disable-next-line exhaustive-deps
JSON.stringify(sourceFieldConfig),
@@ -87,6 +93,46 @@ function UpdateSourceConnectionFormContainer(): JSX.Element {
initialAccessMethod={source.access_method ?? 'warehouse'}
setSourceConfigValue={setSourceConfigValue}
/>
+ {source.access_method !== 'direct' && (
+ <>
+ <LemonDivider className="my-4" />
+ <div className="flex flex-col gap-2">
+ <LemonField
+ name="auto_sync_new_schemas"
+ help="New tables found on this source will start syncing automatically, using recommended sync settings."
+ >
+ {({ value, onChange }) => (
+ <LemonSwitch
+ bordered
+ checked={value ?? false}
+ onChange={onChange}
+ label="Automatically sync new tables"
+ data-attr="source-auto-sync-new-schemas"
+ />
+ )}
+ </LemonField>
+ {sourceConfig?.auto_sync_new_schemas ? (
+ <LemonField
+ name="auto_sync_schema_patterns"
+ label="Only auto-sync tables matching"
+ help="Use * and ? as wildcards, e.g. raw_*. Leave empty to auto-sync all new tables."
+ >
+ {({ value, onChange }) => (
+ <LemonInputSelect
+ mode="multiple"
+ allowCustomValues
+ disableFiltering
+ value={value ?? []}
+ onChange={onChange}
+ placeholder="raw_*"
+ data-attr="source-auto-sync-schema-patterns"
+ />
+ )}
+ </LemonField>
+ ) : null}
+ </div>
+ </>
+ )}
<div className="my-4 flex flex-row justify-end gap-2">
<AccessControlAction
resourceType={AccessControlResourceType.ExternalDataSource}
diff --git a/products/data_warehouse/frontend/scenes/SourceScene/tabs/sourceSettingsLogic.ts b/products/data_warehouse/frontend/scenes/SourceScene/tabs/sourceSettingsLogic.ts
index 98c9695e6198..48ba09d2108e 100644
--- a/products/data_warehouse/frontend/scenes/SourceScene/tabs/sourceSettingsLogic.ts
+++ b/products/data_warehouse/frontend/scenes/SourceScene/tabs/sourceSettingsLogic.ts
@@ -1035,13 +1035,27 @@ export const sourceSettingsLogic = kea<sourceSettingsLogicType>([
// `buildKeaFormDefaultFromSourceDetails` + `setJobInputs`/`setSourceConfigValue`.
// The cast widens the inferred form value type so reads of `access_method`, payload
// sub-fields, etc. type-check.
- defaults: { prefix: '', description: '', payload: {} } as Record<string, any>,
+ defaults: {
+ prefix: '',
+ description: '',
+ payload: {},
+ auto_sync_new_schemas: false,
+ auto_sync_schema_patterns: [],
+ } as Record<string, any>,
errors: (sourceValues) => {
return getErrorsForFields(values.sourceFieldConfig?.fields ?? [], sourceValues as any, {
allowBlankSensitiveFields: true,
})
},
- submit: async ({ payload = {}, description, prefix, access_method, direct_query_enabled }) => {
+ submit: async ({
+ payload = {},
+ description,
+ prefix,
+ access_method,
+ direct_query_enabled,
+ auto_sync_new_schemas,
+ auto_sync_schema_patterns,
+ }) => {
const sanitizedPayload = clonePayloadPreservingFiles(payload) as Record<string, any>
if (values.sourceFieldConfig?.fields) {
removeEmptySensitiveValues(values.sourceFieldConfig.fields, sanitizedPayload)
@@ -1087,6 +1101,14 @@ export const sourceSettingsLogic = kea<sourceSettingsLogicType>([
direct_query_enabled !== undefined
? direct_query_enabled
: values.source?.direct_query_enabled,
+ auto_sync_new_schemas:
+ auto_sync_new_schemas !== undefined
+ ? auto_sync_new_schemas
+ : values.source?.auto_sync_new_schemas,
+ auto_sync_schema_patterns:
+ auto_sync_schema_patterns !== undefined
+ ? auto_sync_schema_patterns
+ : values.source?.auto_sync_schema_patterns,
description: description !== '' ? description : (values.source?.description ?? null),
})
actions.loadSource()
@@ -1285,6 +1307,7 @@ export const sourceSettingsLogic = kea<sourceSettingsLogicType>([
const {
added = 0,
deleted = 0,
+ auto_enabled = 0,
total_tables_seen = 0,
} = await api.externalDataSources.refreshSchemas(values.sourceId)
actions.loadSource()
@@ -1292,6 +1315,7 @@ export const sourceSettingsLogic = kea<sourceSettingsLogicType>([
sourceType: values.source?.source_type,
added,
deleted,
+ auto_enabled,
total_tables_seen,
})
// Connected and got an empty table list — almost always a permissions
@@ -1312,7 +1336,11 @@ export const sourceSettingsLogic = kea<sourceSettingsLogicType>([
lemonToast.success(`No schema changes — all ${total_tables_seen} table(s) already tracked.`)
return
}
- const counts = [added > 0 ? `${added} added` : null, deleted > 0 ? `${deleted} deleted` : null]
+ const counts = [
+ added > 0 ? `${added} added` : null,
+ deleted > 0 ? `${deleted} deleted` : null,
+ auto_enabled > 0 ? `${auto_enabled} auto-enabled` : null,
+ ]
.filter(Boolean)
.join(' / ')
lemonToast.success(`Schemas refreshed: ${counts}`)
diff --git a/products/warehouse_sources/backend/facade/models.py b/products/warehouse_sources/backend/facade/models.py
index b1e1c20466a4..a48eda57607b 100644
--- a/products/warehouse_sources/backend/facade/models.py
+++ b/products/warehouse_sources/backend/facade/models.py
@@ -25,6 +25,7 @@ from products.warehouse_sources.backend.models.custom_oauth2_integration import
from products.warehouse_sources.backend.models.external_data_job import ExternalDataJob, get_latest_run_if_exists
from products.warehouse_sources.backend.models.external_data_schema import (
ExternalDataSchema,
+ auto_enable_new_schemas,
get_all_schemas_for_source_id,
sync_frequency_interval_to_sync_frequency,
sync_frequency_to_sync_frequency_interval,
@@ -72,6 +73,7 @@ __all__ = [
"WarehouseColumnStatistics",
"acreate_datawarehousetable",
"asave_datawarehousetable",
+ "auto_enable_new_schemas",
"get_custom_oauth2_integration",
"get_all_schemas_for_source_id",
"get_direct_external_data_source_for_connection",
diff --git a/products/warehouse_sources/backend/migrations/0080_externaldatasource_auto_sync_new_schemas_and_more.py b/products/warehouse_sources/backend/migrations/0080_externaldatasource_auto_sync_new_schemas_and_more.py
new file mode 100644
index 000000000000..f23cfc19b0f3
--- /dev/null
+++ b/products/warehouse_sources/backend/migrations/0080_externaldatasource_auto_sync_new_schemas_and_more.py
@@ -0,0 +1,22 @@
+# Generated by Django 5.2.14 on 2026-07-17 08:28
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+ dependencies = [
+ ("warehouse_sources", "0079_alter_externaldatasource_source_type_and_more"),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name="externaldatasource",
+ name="auto_sync_new_schemas",
+ field=models.BooleanField(default=False),
+ ),
+ migrations.AddField(
+ model_name="externaldatasource",
+ name="auto_sync_schema_patterns",
+ field=models.JSONField(blank=True, null=True),
+ ),
+ ]
diff --git a/products/warehouse_sources/backend/migrations/max_migration.txt b/products/warehouse_sources/backend/migrations/max_migration.txt
index f31c6179250a..987ebf16dee4 100644
--- a/products/warehouse_sources/backend/migrations/max_migration.txt
+++ b/products/warehouse_sources/backend/migrations/max_migration.txt
@@ -1 +1 @@
-0079_alter_externaldatasource_source_type_and_more
+0080_externaldatasource_auto_sync_new_schemas_and_more
diff --git a/products/warehouse_sources/backend/models/external_data_schema.py b/products/warehouse_sources/backend/models/external_data_schema.py
index f6114f849be3..60521fb0657f 100644
--- a/products/warehouse_sources/backend/models/external_data_schema.py
+++ b/products/warehouse_sources/backend/models/external_data_schema.py
@@ -1,8 +1,9 @@
import sys
import uuid
+import fnmatch
from collections.abc import Callable, Iterable
from datetime import date, datetime, timedelta
-from typing import Any, Literal, Optional
+from typing import TYPE_CHECKING, Any, Literal, Optional
from django.conf import settings
from django.db import models, transaction
@@ -23,6 +24,10 @@ from products.warehouse_sources.backend.temporal.data_imports.pipelines.pipeline
)
from products.warehouse_sources.backend.types import IncrementalFieldType
+if TYPE_CHECKING:
+ from products.warehouse_sources.backend.models.external_data_source import ExternalDataSource
+ from products.warehouse_sources.backend.temporal.data_imports.sources.common.schema import SourceSchema
+
type IncrementalFieldValue = str | int | float | None
@@ -969,6 +974,121 @@ def sync_old_schemas_with_new_schemas(
return actually_created, deleted_schemas
+def schema_name_matches_auto_sync_patterns(name: str, patterns: list[str] | None) -> bool:
+ """Whether a discovered schema name qualifies for auto-sync under a source's glob patterns.
+
+ Patterns are fnmatch globs matched case-insensitively against both the stored name and its
+ unqualified tail — mirroring `_same_table`'s bare↔qualified equivalence, so `raw_*` matches
+ `public.raw_events`. No patterns means every name qualifies.
+ """
+ cleaned = [pattern.strip().lower() for pattern in patterns or [] if isinstance(pattern, str) and pattern.strip()]
+ if not cleaned:
+ return True
+
+ candidates = {name.lower(), name.rpartition(".")[2].lower()}
+ return any(fnmatch.fnmatchcase(candidate, pattern) for pattern in cleaned for candidate in candidates)
+
+
+def auto_enable_new_schemas(
+ source: "ExternalDataSource",
+ created_schema_names: list[str],
+ source_schemas_by_name: dict[str, "SourceSchema"],
+) -> list[str]:
+ """Enable syncing for newly discovered schemas on sources that opted into auto-sync.
+
+ Only rows still in the untouched discovery state (disabled, no sync type) are considered, so
+ revived rows keep whatever a user configured before and retries are idempotent. Sync config
+ comes from the same defaults as one-shot setup; each enabled schema gets a Temporal schedule
+ and an immediate first sync, like flipping the toggle in the UI.
+ """
+ if not created_schema_names or not source.auto_sync_new_schemas or not source.supports_scheduled_sync:
+ return []
+
+ # Call-time imports: the sources package's import chain pulls the source registry back into
+ # these models, and data_load.service puts temporalio on the django.setup() path (see
+ # update_should_sync above).
+ from products.data_warehouse.backend.facade.api import sync_external_data_job_workflow # noqa: PLC0415
+ from products.warehouse_sources.backend.temporal.data_imports.sources.common.schema import ( # noqa: PLC0415
+ build_default_schemas,
+ )
+
+ enabled: list[str] = []
+ candidates = ExternalDataSchema.objects.filter(
+ team_id=source.team_id,
+ source_id=source.id,
+ name__in=created_schema_names,
+ deleted=False,
+ should_sync=False,
+ sync_type__isnull=True,
+ )
+ for schema in candidates:
+ if not schema_name_matches_auto_sync_patterns(schema.name, source.auto_sync_schema_patterns):
+ continue
+
+ source_schema = source_schemas_by_name.get(schema.name)
+ if source_schema is None:
+ continue
+
+ defaults = build_default_schemas([source_schema])[0]
+ if not defaults.get("should_sync"):
+ # Webhook-only tables and tables the source marks default-off need explicit opt-in.
+ continue
+
+ sync_type = defaults["sync_type"]
+ original_sync_type_config = schema.sync_type_config
+ sync_type_config = {**(original_sync_type_config or {})}
+ if defaults.get("incremental_field") is not None:
+ sync_type_config["incremental_field"] = defaults["incremental_field"]
+ sync_type_config["incremental_field_type"] = defaults["incremental_field_type"]
+ if defaults.get("primary_key_columns"):
+ sync_type_config["primary_key_columns"] = defaults["primary_key_columns"]
+ if (
+ sync_type == ExternalDataSchema.SyncType.INCREMENTAL
+ and source_schema.default_incremental_lookback_seconds is not None
+ ):
+ sync_type_config["incremental_field_lookback_seconds"] = source_schema.default_incremental_lookback_seconds
+
+ # Claim the row under a lock before enabling it, so a discovery pass running concurrently
+ # (a second "Pull new schemas" click, or the 6h schedule firing alongside a manual refresh)
+ # can't also enable the same row and fire a duplicate first sync. Re-read inside the lock
+ # and bail if it is no longer the untouched discovery row.
+ try:
+ with transaction.atomic():
+ locked = ExternalDataSchema.objects.select_for_update().get(id=schema.id, team_id=source.team_id)
+ if locked.should_sync or locked.sync_type is not None:
+ continue
+ locked.sync_type = sync_type
+ locked.sync_type_config = sync_type_config
+ locked.should_sync = True
+ locked.save()
+ except Exception as e:
+ # A bad schema must not block the rest; nothing was persisted, so the next discovery
+ # pass reconsiders this row unchanged.
+ capture_exception(e)
+ continue
+
+ try:
+ sync_external_data_job_workflow(locked, create=True)
+ enabled.append(locked.name)
+ except Exception as e:
+ # Scheduling talks to Temporal and can fail after we persisted the enabled state. Roll
+ # the row back to the untouched discovery state so the next discovery pass retries it —
+ # this helper only reconsiders disabled, untyped rows, so leaving it enabled would strand
+ # it without a schedule or first sync until someone reloaded the source by hand.
+ capture_exception(e)
+ try:
+ with transaction.atomic():
+ revert = ExternalDataSchema.objects.select_for_update().get(id=locked.id, team_id=source.team_id)
+ revert.should_sync = False
+ revert.sync_type = None
+ revert.sync_type_config = original_sync_type_config
+ revert.save()
+ except Exception as rollback_error:
+ capture_exception(rollback_error)
+
+ return enabled
+
+
def sync_frequency_to_sync_frequency_interval(frequency: str) -> timedelta | None:
if frequency == "never":
return None
diff --git a/products/warehouse_sources/backend/models/external_data_source.py b/products/warehouse_sources/backend/models/external_data_source.py
index 066fe66ae688..4a1a09964d2c 100644
--- a/products/warehouse_sources/backend/models/external_data_source.py
+++ b/products/warehouse_sources/backend/models/external_data_source.py
@@ -74,6 +74,13 @@ class ExternalDataSource(ModelActivityMixin, CreatedMetaFields, UpdatedMetaField
# Lets a synced (warehouse) source also be live-queryable via direct connection; ignored for pure direct sources.
# Off by default — a user opts a synced source in explicitly before it becomes live-queryable.
direct_query_enabled = models.BooleanField(default=False)
+ # Auto-enable syncing for schemas discovered after source creation (both the scheduled
+ # discovery pass and manual "Pull new schemas"). Off by default — per-source opt-in.
+ auto_sync_new_schemas = models.BooleanField(default=False)
+ # Optional list of fnmatch-style globs (e.g. ["raw_*"]) restricting which newly discovered
+ # schema names auto-sync; matched case-insensitively against both the qualified and bare
+ # table name. Null/empty means every new schema qualifies.
+ auto_sync_schema_patterns = models.JSONField(null=True, blank=True)
# DEPRECATED: Check inside `revenue_analytics_config` instead
revenue_analytics_enabled = models.BooleanField(default=False, blank=True, null=True)
diff --git a/products/warehouse_sources/backend/temporal/data_imports/workflow_activities/sync_new_schemas.py b/products/warehouse_sources/backend/temporal/data_imports/workflow_activities/sync_new_schemas.py
index ba364dae3827..2944b6133ae6 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/workflow_activities/sync_new_schemas.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/workflow_activities/sync_new_schemas.py
@@ -9,7 +9,10 @@ from temporalio import activity
from posthog.temporal.common.logger import get_logger
from products.data_warehouse.backend.facade.api import delete_discover_schemas_schedule
-from products.warehouse_sources.backend.models.external_data_schema import sync_old_schemas_with_new_schemas
+from products.warehouse_sources.backend.models.external_data_schema import (
+ auto_enable_new_schemas,
+ sync_old_schemas_with_new_schemas,
+)
from products.warehouse_sources.backend.models.external_data_source import ExternalDataSource
from products.warehouse_sources.backend.temporal.data_imports.sources import SourceRegistry
from products.warehouse_sources.backend.types import ExternalDataSourceType
@@ -106,6 +109,10 @@ def sync_new_schemas_activity(inputs: SyncNewSchemasActivityInputs) -> None:
if len(schemas_created) > 0:
logger.info(f"Added new schemas: {', '.join(schemas_created)}")
+
+ auto_enabled = auto_enable_new_schemas(source, schemas_created, {s.name: s for s in schemas})
+ if auto_enabled:
+ logger.info(f"Auto-enabled sync for new schemas: {', '.join(auto_enabled)}")
else:
logger.info("No new schemas to create")
diff --git a/products/warehouse_sources/backend/temporal/data_imports/workflow_activities/tests/test_sync_new_schemas.py b/products/warehouse_sources/backend/temporal/data_imports/workflow_activities/tests/test_sync_new_schemas.py
index 015833b7c2d1..d792c9057d14 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/workflow_activities/tests/test_sync_new_schemas.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/workflow_activities/tests/test_sync_new_schemas.py
@@ -1,3 +1,5 @@
+import contextlib
+
import pytest
from unittest import mock
@@ -8,27 +10,32 @@ from products.warehouse_sources.backend.temporal.data_imports.workflow_activitie
)
-def _patch_common(source_mock):
+def _patch_common(source_mock, schemas_created=None):
"""Patch DB + registry so the activity runs without a database or real source."""
existing_source = mock.MagicMock(source_type="GoogleAds", job_inputs={"k": "v"}, deleted=False)
objects = mock.MagicMock()
objects.filter.return_value.exclude.return_value.exists.return_value = True
objects.get.return_value = existing_source
- return (
- mock.patch.object(module, "close_old_connections"),
- mock.patch.object(module.ExternalDataSource, "objects", objects),
- mock.patch.object(module, "ExternalDataSourceType", return_value="GoogleAds"),
- mock.patch.object(module.SourceRegistry, "is_registered", return_value=True),
- mock.patch.object(module.SourceRegistry, "get_source", return_value=source_mock),
- mock.patch.object(module, "sync_old_schemas_with_new_schemas", return_value=([], [])),
- )
+ return {
+ "close_old_connections": mock.patch.object(module, "close_old_connections"),
+ "objects": mock.patch.object(module.ExternalDataSource, "objects", objects),
+ "source_type": mock.patch.object(module, "ExternalDataSourceType", return_value="GoogleAds"),
+ "is_registered": mock.patch.object(module.SourceRegistry, "is_registered", return_value=True),
+ "get_source": mock.patch.object(module.SourceRegistry, "get_source", return_value=source_mock),
+ "sync_old_schemas_with_new_schemas": mock.patch.object(
+ module, "sync_old_schemas_with_new_schemas", return_value=(schemas_created or [], [])
+ ),
+ "auto_enable_new_schemas": mock.patch.object(module, "auto_enable_new_schemas", return_value=[]),
+ }
-def _run_activity(source_mock):
- patches = _patch_common(source_mock)
- with patches[0], patches[1], patches[2], patches[3], patches[4], patches[5]:
+def _run_activity(source_mock, schemas_created=None):
+ patches = _patch_common(source_mock, schemas_created)
+ with contextlib.ExitStack() as stack:
+ entered = {name: stack.enter_context(patcher) for name, patcher in patches.items()}
sync_new_schemas_activity(SyncNewSchemasActivityInputs(source_id="src", team_id=1))
+ return entered
@pytest.mark.parametrize(
@@ -67,3 +74,30 @@ def test_unparseable_config_is_skipped():
_run_activity(source_mock)
source_mock.get_schemas.assert_not_called()
+
+
+def test_created_schemas_are_passed_to_auto_enable():
+ source_mock = mock.MagicMock()
+ source_mock.parse_config.return_value = {}
+ discovered = mock.MagicMock()
+ discovered.name = "raw_events"
+ source_mock.get_schemas.return_value = [discovered]
+
+ mocks = _run_activity(source_mock, schemas_created=["raw_events"])
+
+ auto_enable = mocks["auto_enable_new_schemas"]
+ auto_enable.assert_called_once()
+ source_arg, created_arg, source_schemas_arg = auto_enable.call_args.args
+ assert source_arg is mocks["objects"].get.return_value
+ assert created_arg == ["raw_events"]
+ assert source_schemas_arg == {"raw_events": discovered}
+
+
+def test_auto_enable_not_called_when_nothing_created():
+ source_mock = mock.MagicMock()
+ source_mock.parse_config.return_value = {}
+ source_mock.get_schemas.return_value = []
+
+ mocks = _run_activity(source_mock)
+
+ mocks["auto_enable_new_schemas"].assert_not_called()
diff --git a/products/warehouse_sources/backend/tests/test_schema_discovery_reconcile.py b/products/warehouse_sources/backend/tests/test_schema_discovery_reconcile.py
index fa947bb3d92e..d862b213c751 100644
--- a/products/warehouse_sources/backend/tests/test_schema_discovery_reconcile.py
+++ b/products/warehouse_sources/backend/tests/test_schema_discovery_reconcile.py
@@ -1,15 +1,22 @@
import uuid
from posthog.test.base import BaseTest
+from unittest.mock import patch
+
+from django.test import SimpleTestCase
from parameterized import parameterized
from products.warehouse_sources.backend.models.external_data_schema import (
ExternalDataSchema,
+ auto_enable_new_schemas,
+ schema_name_matches_auto_sync_patterns,
sync_old_schemas_with_new_schemas,
)
from products.warehouse_sources.backend.models.external_data_source import ExternalDataSource
from products.warehouse_sources.backend.models.table import DataWarehouseTable
+from products.warehouse_sources.backend.temporal.data_imports.sources.common.schema import SourceSchema
+from products.warehouse_sources.backend.types import IncrementalField, IncrementalFieldType
# Managed/scheduled discovery calls sync_old_schemas_with_new_schemas with no rename step, so a
@@ -138,3 +145,194 @@ class TestSchemaDiscoveryReconcile(BaseTest):
assert synced_removed.should_sync is False
assert synced_removed.deleted is False
assert unsynced_removed.deleted is True
+
+
+class TestSchemaNameMatchesAutoSyncPatterns(SimpleTestCase):
+ @parameterized.expand(
+ [
+ ("no_patterns", "raw_events", None, True),
+ ("empty_list", "raw_events", [], True),
+ ("blank_patterns_only", "raw_events", [" ", ""], True),
+ ("exact_match", "raw_events", ["raw_events"], True),
+ ("prefix_glob", "raw_events", ["raw_*"], True),
+ ("prefix_glob_matches_bare_tail_of_qualified_name", "public.raw_events", ["raw_*"], True),
+ ("qualified_pattern_matches_full_name", "analytics.users", ["analytics.*"], True),
+ ("case_insensitive", "RAW_Events", ["raw_*"], True),
+ ("pattern_whitespace_is_stripped", "raw_events", [" raw_* "], True),
+ ("question_mark_single_char", "raw_1", ["raw_?"], True),
+ ("question_mark_rejects_longer_name", "raw_12", ["raw_?"], False),
+ ("any_pattern_may_match", "billing_invoices", ["raw_*", "billing_*"], True),
+ ("no_match", "public.users", ["raw_*"], False),
+ ]
+ )
+ def test_matching(self, _name: str, schema_name: str, patterns: list[str] | None, expected: bool) -> None:
+ assert schema_name_matches_auto_sync_patterns(schema_name, patterns) is expected
+
+
+_SCHEDULE_FN = "products.data_warehouse.backend.facade.api.sync_external_data_job_workflow"
+
+
+class TestAutoEnableNewSchemas(BaseTest):
+ def _make_source(self, **kwargs) -> ExternalDataSource:
+ return ExternalDataSource.objects.create(
+ team_id=self.team.pk,
+ source_id=str(uuid.uuid4()),
+ connection_id=str(uuid.uuid4()),
+ destination_id=str(uuid.uuid4()),
+ source_type="Postgres",
+ created_by=self.user,
+ job_inputs={"host": "localhost", "port": 5432, "schema": "public"},
+ **{"auto_sync_new_schemas": True, **kwargs},
+ )
+
+ def _make_discovered_row(self, source: ExternalDataSource, name: str, **kwargs) -> ExternalDataSchema:
+ return ExternalDataSchema.objects.create(
+ team_id=self.team.pk, source_id=source.pk, name=name, should_sync=False, **kwargs
+ )
+
+ def _source_schema(self, name: str, **kwargs) -> SourceSchema:
+ updated_at: IncrementalField = {
+ "label": "updated_at",
+ "type": IncrementalFieldType.DateTime,
+ "field": "updated_at",
+ "field_type": IncrementalFieldType.DateTime,
+ }
+ defaults: dict = {
+ "supports_incremental": True,
+ "supports_append": False,
+ "incremental_fields": [updated_at],
+ "detected_primary_keys": ["id"],
+ }
+ return SourceSchema(name=name, **{**defaults, **kwargs})
+
+ def test_enables_matching_schema_with_smart_defaults_and_schedule(self) -> None:
+ source = self._make_source(auto_sync_schema_patterns=["raw_*"])
+ matching = self._make_discovered_row(
+ source, "raw_events", sync_type_config={"schema_metadata": {"source_table_name": "raw_events"}}
+ )
+ non_matching = self._make_discovered_row(source, "audit_log")
+ source_schemas = {name: self._source_schema(name) for name in ["raw_events", "audit_log"]}
+
+ with patch(_SCHEDULE_FN) as mock_schedule:
+ enabled = auto_enable_new_schemas(source, ["raw_events", "audit_log"], source_schemas)
+
+ assert enabled == ["raw_events"]
+ matching.refresh_from_db()
+ assert matching.should_sync is True
+ assert matching.sync_type == ExternalDataSchema.SyncType.INCREMENTAL
+ assert matching.sync_type_config["incremental_field"] == "updated_at"
+ assert matching.sync_type_config["incremental_field_type"] == "datetime"
+ assert matching.sync_type_config["primary_key_columns"] == ["id"]
+ # Pre-seeded discovery metadata must survive the config merge
+ assert matching.sync_type_config["schema_metadata"] == {"source_table_name": "raw_events"}
+ non_matching.refresh_from_db()
+ assert non_matching.should_sync is False
+ assert non_matching.sync_type is None
+ mock_schedule.assert_called_once()
+ assert mock_schedule.call_args.args[0].id == matching.id
+ assert mock_schedule.call_args.kwargs.get("create") is True
+
+ def test_empty_patterns_enable_every_new_schema(self) -> None:
+ source = self._make_source(auto_sync_schema_patterns=None)
+ self._make_discovered_row(source, "raw_events")
+ self._make_discovered_row(source, "audit_log")
+ source_schemas = {name: self._source_schema(name) for name in ["raw_events", "audit_log"]}
+
+ with patch(_SCHEDULE_FN):
+ enabled = auto_enable_new_schemas(source, ["raw_events", "audit_log"], source_schemas)
+
+ assert sorted(enabled) == ["audit_log", "raw_events"]
+ assert ExternalDataSchema.objects.filter(source_id=source.pk, should_sync=True, deleted=False).count() == 2
+
+ @parameterized.expand(
+ [
+ ("auto_sync_disabled", {"auto_sync_new_schemas": False}),
+ ("direct_query_source", {"access_method": ExternalDataSource.AccessMethod.DIRECT}),
+ ]
+ )
+ def test_no_op_when_opted_out_or_direct_query(self, _name: str, source_kwargs: dict) -> None:
+ source = self._make_source(**source_kwargs)
+ row = self._make_discovered_row(source, "raw_events")
+
+ with patch(_SCHEDULE_FN) as mock_schedule:
+ enabled = auto_enable_new_schemas(source, ["raw_events"], {"raw_events": self._source_schema("raw_events")})
+
+ assert enabled == []
+ row.refresh_from_db()
+ assert row.should_sync is False
+ mock_schedule.assert_not_called()
+
+ def test_skips_rows_that_already_have_sync_config(self) -> None:
+ # A revived soft-deleted row keeps its previous user config; auto-sync must not overwrite it.
+ source = self._make_source()
+ row = self._make_discovered_row(source, "raw_events", sync_type=ExternalDataSchema.SyncType.FULL_REFRESH)
+
+ with patch(_SCHEDULE_FN) as mock_schedule:
+ enabled = auto_enable_new_schemas(source, ["raw_events"], {"raw_events": self._source_schema("raw_events")})
+
+ assert enabled == []
+ row.refresh_from_db()
+ assert row.should_sync is False
+ assert row.sync_type == ExternalDataSchema.SyncType.FULL_REFRESH
+ mock_schedule.assert_not_called()
+
+ @parameterized.expand(
+ [
+ ("webhook_only", {"webhook_only": True}),
+ ("default_off", {"should_sync_default": False}),
+ ]
+ )
+ def test_skips_tables_the_source_marks_as_opt_in(self, _name: str, schema_kwargs: dict) -> None:
+ source = self._make_source()
+ row = self._make_discovered_row(source, "raw_events")
+
+ with patch(_SCHEDULE_FN) as mock_schedule:
+ enabled = auto_enable_new_schemas(
+ source, ["raw_events"], {"raw_events": self._source_schema("raw_events", **schema_kwargs)}
+ )
+
+ assert enabled == []
+ row.refresh_from_db()
+ assert row.should_sync is False
+ mock_schedule.assert_not_called()
+
+ def test_schedule_failure_does_not_block_remaining_schemas(self) -> None:
+ source = self._make_source()
+ row_a = self._make_discovered_row(source, "raw_a")
+ row_b = self._make_discovered_row(source, "raw_b")
+ source_schemas = {name: self._source_schema(name) for name in ["raw_a", "raw_b"]}
+
+ def _fail_for_raw_a(schema, **kwargs):
+ if schema.name == "raw_a":
+ raise Exception("temporal unavailable")
+
+ with patch(_SCHEDULE_FN, side_effect=_fail_for_raw_a):
+ enabled = auto_enable_new_schemas(source, ["raw_a", "raw_b"], source_schemas)
+
+ assert enabled == ["raw_b"]
+ row_a.refresh_from_db()
+ row_b.refresh_from_db()
+ # raw_a's schedule failed, so it rolls back to the untouched discovery state and a later
+ # pass can retry it; raw_b is unaffected and stays fully enabled.
+ assert row_a.should_sync is False
+ assert row_a.sync_type is None
+ assert row_b.should_sync is True
+
+ def test_schedule_failure_rollback_lets_next_pass_retry(self) -> None:
+ source = self._make_source()
+ row = self._make_discovered_row(source, "raw_events")
+ source_schemas = {"raw_events": self._source_schema("raw_events")}
+
+ with patch(_SCHEDULE_FN, side_effect=Exception("temporal unavailable")):
+ assert auto_enable_new_schemas(source, ["raw_events"], source_schemas) == []
+ after_failure = ExternalDataSchema.objects.get(id=row.id)
+ assert after_failure.should_sync is False
+ assert after_failure.sync_type is None
+
+ # Temporal recovered: the rolled-back row is still an eligible candidate, so it enables now.
+ with patch(_SCHEDULE_FN) as mock_schedule:
+ assert auto_enable_new_schemas(source, ["raw_events"], source_schemas) == ["raw_events"]
+ after_retry = ExternalDataSchema.objects.get(id=row.id)
+ assert after_retry.should_sync is True
+ assert after_retry.sync_type == ExternalDataSchema.SyncType.INCREMENTAL
+ mock_schedule.assert_called_once()
diff --git a/products/warehouse_sources/frontend/generated/api.schemas.ts b/products/warehouse_sources/frontend/generated/api.schemas.ts
index 0c7426913d5c..7fcb6e21a2a4 100644
--- a/products/warehouse_sources/frontend/generated/api.schemas.ts
+++ b/products/warehouse_sources/frontend/generated/api.schemas.ts
@@ -2208,6 +2208,15 @@ export interface ExternalDataSourceSerializersApi {
readonly access_method: AccessMethodEnumApi
/** Whether this synced source is also live-queryable via direct connection. Defaults to false for new sources; ignored for pure direct-query sources. */
direct_query_enabled?: boolean
+ /** Automatically enable syncing for schemas discovered on this source after creation, on both the scheduled discovery pass and manual schema refreshes. Defaults to false. Not supported for direct-query sources. */
+ auto_sync_new_schemas?: boolean
+ /**
+ * Optional fnmatch-style globs (`*` and `?` wildcards) restricting which newly discovered schema names auto-sync, matched case-insensitively against both the qualified and bare table name. Null or empty means every new schema qualifies. Only used when `auto_sync_new_schemas` is true.
+ * @maxItems 100
+ * @nullable
+ * @items.maxLength 250
+ */
+ auto_sync_schema_patterns?: string[] | null
/** Backend engine detected for the direct connection.
*
* * `duckdb` - duckdb
@@ -3199,6 +3208,15 @@ export interface PatchedExternalDataSourceSerializersApi {
readonly access_method?: AccessMethodEnumApi
/** Whether this synced source is also live-queryable via direct connection. Defaults to false for new sources; ignored for pure direct-query sources. */
direct_query_enabled?: boolean
+ /** Automatically enable syncing for schemas discovered on this source after creation, on both the scheduled discovery pass and manual schema refreshes. Defaults to false. Not supported for direct-query sources. */
+ auto_sync_new_schemas?: boolean
+ /**
+ * Optional fnmatch-style globs (`*` and `?` wildcards) restricting which newly discovered schema names auto-sync, matched case-insensitively against both the qualified and bare table name. Null or empty means every new schema qualifies. Only used when `auto_sync_new_schemas` is true.
+ * @maxItems 100
+ * @nullable
+ * @items.maxLength 250
+ */
+ auto_sync_schema_patterns?: string[] | null
/** Backend engine detected for the direct connection.
*
* * `duckdb` - duckdb
diff --git a/products/warehouse_sources/frontend/generated/api.zod.ts b/products/warehouse_sources/frontend/generated/api.zod.ts
index b152709aba52..f436a51e1a39 100644
--- a/products/warehouse_sources/frontend/generated/api.zod.ts
+++ b/products/warehouse_sources/frontend/generated/api.zod.ts
@@ -1481,6 +1481,10 @@ export const externalDataSourcesUpdateBodyPrefixMax = 100
export const externalDataSourcesUpdateBodyDescriptionMax = 400
+export const externalDataSourcesUpdateBodyAutoSyncSchemaPatternsItemMax = 250
+
+export const externalDataSourcesUpdateBodyAutoSyncSchemaPatternsMax = 100
+
export const ExternalDataSourcesUpdateBody = /* @__PURE__ */ zod
.object({
created_via: zod
@@ -1506,6 +1510,24 @@ export const ExternalDataSourcesUpdateBody = /* @__PURE__ */ zod
.describe(
'Whether this synced source is also live-queryable via direct connection. Defaults to false for new sources; ignored for pure direct-query sources.'
),
+ auto_sync_new_schemas: zod
+ .boolean()
+ .optional()
+ .describe(
+ 'Automatically enable syncing for schemas discovered on this source after creation, on both the scheduled discovery pass and manual schema refreshes. Defaults to false. Not supported for direct-query sources.'
+ ),
+ auto_sync_schema_patterns: zod
+ .array(
+ zod
+ .string()
+ .max(externalDataSourcesUpdateBodyAutoSyncSchemaPatternsItemMax)
+ .describe('An fnmatch-style glob pattern, e.g. `raw_\*`.')
+ )
+ .max(externalDataSourcesUpdateBodyAutoSyncSchemaPatternsMax)
+ .nullish()
+ .describe(
+ 'Optional fnmatch-style globs (`\*` and `?` wildcards) restricting which newly discovered schema names auto-sync, matched case-insensitively against both the qualified and bare table name. Null or empty means every new schema qualifies. Only used when `auto_sync_new_schemas` is true.'
+ ),
job_inputs: zod.unknown().optional(),
})
.describe('Mixin for serializers to add user access control fields')
@@ -1517,6 +1539,10 @@ export const externalDataSourcesPartialUpdateBodyPrefixMax = 100
export const externalDataSourcesPartialUpdateBodyDescriptionMax = 400
+export const externalDataSourcesPartialUpdateBodyAutoSyncSchemaPatternsItemMax = 250
+
+export const externalDataSourcesPartialUpdateBodyAutoSyncSchemaPatternsMax = 100
+
export const ExternalDataSourcesPartialUpdateBody = /* @__PURE__ */ zod
.object({
created_via: zod
@@ -1542,6 +1568,24 @@ export const ExternalDataSourcesPartialUpdateBody = /* @__PURE__ */ zod
.describe(
'Whether this synced source is also live-queryable via direct connection. Defaults to false for new sources; ignored for pure direct-query sources.'
),
+ auto_sync_new_schemas: zod
+ .boolean()
+ .optional()
+ .describe(
+ 'Automatically enable syncing for schemas discovered on this source after creation, on both the scheduled discovery pass and manual schema refreshes. Defaults to false. Not supported for direct-query sources.'
+ ),
+ auto_sync_schema_patterns: zod
+ .array(
+ zod
+ .string()
+ .max(externalDataSourcesPartialUpdateBodyAutoSyncSchemaPatternsItemMax)
+ .describe('An fnmatch-style glob pattern, e.g. `raw_\*`.')
+ )
+ .max(externalDataSourcesPartialUpdateBodyAutoSyncSchemaPatternsMax)
+ .nullish()
+ .describe(
+ 'Optional fnmatch-style globs (`\*` and `?` wildcards) restricting which newly discovered schema names auto-sync, matched case-insensitively against both the qualified and bare table name. Null or empty means every new schema qualifies. Only used when `auto_sync_new_schemas` is true.'
+ ),
job_inputs: zod.unknown().optional(),
})
.describe('Mixin for serializers to add user access control fields')
@@ -1632,6 +1676,10 @@ export const externalDataSourcesCheckCdcPrerequisitesForSourceCreateBodyPrefixMa
export const externalDataSourcesCheckCdcPrerequisitesForSourceCreateBodyDescriptionMax = 400
+export const externalDataSourcesCheckCdcPrerequisitesForSourceCreateBodyAutoSyncSchemaPatternsItemMax = 250
+
+export const externalDataSourcesCheckCdcPrerequisitesForSourceCreateBodyAutoSyncSchemaPatternsMax = 100
+
export const ExternalDataSourcesCheckCdcPrerequisitesForSourceCreateBody = /* @__PURE__ */ zod
.object({
created_via: zod
@@ -1660,6 +1708,24 @@ export const ExternalDataSourcesCheckCdcPrerequisitesForSourceCreateBody = /* @_
.describe(
'Whether this synced source is also live-queryable via direct connection. Defaults to false for new sources; ignored for pure direct-query sources.'
),
+ auto_sync_new_schemas: zod
+ .boolean()
+ .optional()
+ .describe(
+ 'Automatically enable syncing for schemas discovered on this source after creation, on both the scheduled discovery pass and manual schema refreshes. Defaults to false. Not supported for direct-query sources.'
+ ),
+ auto_sync_schema_patterns: zod
+ .array(
+ zod
+ .string()
+ .max(externalDataSourcesCheckCdcPrerequisitesForSourceCreateBodyAutoSyncSchemaPatternsItemMax)
+ .describe('An fnmatch-style glob pattern, e.g. `raw_\*`.')
+ )
+ .max(externalDataSourcesCheckCdcPrerequisitesForSourceCreateBodyAutoSyncSchemaPatternsMax)
+ .nullish()
+ .describe(
+ 'Optional fnmatch-style globs (`\*` and `?` wildcards) restricting which newly discovered schema names auto-sync, matched case-insensitively against both the qualified and bare table name. Null or empty means every new schema qualifies. Only used when `auto_sync_new_schemas` is true.'
+ ),
job_inputs: zod.unknown().optional(),
})
.describe('Mixin for serializers to add user access control fields')
@@ -1671,6 +1737,10 @@ export const externalDataSourcesCreateWebhookCreateBodyPrefixMax = 100
export const externalDataSourcesCreateWebhookCreateBodyDescriptionMax = 400
+export const externalDataSourcesCreateWebhookCreateBodyAutoSyncSchemaPatternsItemMax = 250
+
+export const externalDataSourcesCreateWebhookCreateBodyAutoSyncSchemaPatternsMax = 100
+
export const ExternalDataSourcesCreateWebhookCreateBody = /* @__PURE__ */ zod
.object({
created_via: zod
@@ -1696,6 +1766,24 @@ export const ExternalDataSourcesCreateWebhookCreateBody = /* @__PURE__ */ zod
.describe(
'Whether this synced source is also live-queryable via direct connection. Defaults to false for new sources; ignored for pure direct-query sources.'
),
+ auto_sync_new_schemas: zod
+ .boolean()
+ .optional()
+ .describe(
+ 'Automatically enable syncing for schemas discovered on this source after creation, on both the scheduled discovery pass and manual schema refreshes. Defaults to false. Not supported for direct-query sources.'
+ ),
+ auto_sync_schema_patterns: zod
+ .array(
+ zod
+ .string()
+ .max(externalDataSourcesCreateWebhookCreateBodyAutoSyncSchemaPatternsItemMax)
+ .describe('An fnmatch-style glob pattern, e.g. `raw_\*`.')
+ )
+ .max(externalDataSourcesCreateWebhookCreateBodyAutoSyncSchemaPatternsMax)
+ .nullish()
+ .describe(
+ 'Optional fnmatch-style globs (`\*` and `?` wildcards) restricting which newly discovered schema names auto-sync, matched case-insensitively against both the qualified and bare table name. Null or empty means every new schema qualifies. Only used when `auto_sync_new_schemas` is true.'
+ ),
job_inputs: zod.unknown().optional(),
})
.describe('Mixin for serializers to add user access control fields')
@@ -1707,6 +1795,10 @@ export const externalDataSourcesDeleteWebhookCreateBodyPrefixMax = 100
export const externalDataSourcesDeleteWebhookCreateBodyDescriptionMax = 400
+export const externalDataSourcesDeleteWebhookCreateBodyAutoSyncSchemaPatternsItemMax = 250
+
+export const externalDataSourcesDeleteWebhookCreateBodyAutoSyncSchemaPatternsMax = 100
+
export const ExternalDataSourcesDeleteWebhookCreateBody = /* @__PURE__ */ zod
.object({
created_via: zod
@@ -1732,6 +1824,24 @@ export const ExternalDataSourcesDeleteWebhookCreateBody = /* @__PURE__ */ zod
.describe(
'Whether this synced source is also live-queryable via direct connection. Defaults to false for new sources; ignored for pure direct-query sources.'
),
+ auto_sync_new_schemas: zod
+ .boolean()
+ .optional()
+ .describe(
+ 'Automatically enable syncing for schemas discovered on this source after creation, on both the scheduled discovery pass and manual schema refreshes. Defaults to false. Not supported for direct-query sources.'
+ ),
+ auto_sync_schema_patterns: zod
+ .array(
+ zod
+ .string()
+ .max(externalDataSourcesDeleteWebhookCreateBodyAutoSyncSchemaPatternsItemMax)
+ .describe('An fnmatch-style glob pattern, e.g. `raw_\*`.')
+ )
+ .max(externalDataSourcesDeleteWebhookCreateBodyAutoSyncSchemaPatternsMax)
+ .nullish()
+ .describe(
+ 'Optional fnmatch-style globs (`\*` and `?` wildcards) restricting which newly discovered schema names auto-sync, matched case-insensitively against both the qualified and bare table name. Null or empty means every new schema qualifies. Only used when `auto_sync_new_schemas` is true.'
+ ),
job_inputs: zod.unknown().optional(),
})
.describe('Mixin for serializers to add user access control fields')
@@ -1750,6 +1860,10 @@ export const externalDataSourcesDisableCdcCreateBodyPrefixMax = 100
export const externalDataSourcesDisableCdcCreateBodyDescriptionMax = 400
+export const externalDataSourcesDisableCdcCreateBodyAutoSyncSchemaPatternsItemMax = 250
+
+export const externalDataSourcesDisableCdcCreateBodyAutoSyncSchemaPatternsMax = 100
+
export const ExternalDataSourcesDisableCdcCreateBody = /* @__PURE__ */ zod
.object({
created_via: zod
@@ -1775,6 +1889,24 @@ export const ExternalDataSourcesDisableCdcCreateBody = /* @__PURE__ */ zod
.describe(
'Whether this synced source is also live-queryable via direct connection. Defaults to false for new sources; ignored for pure direct-query sources.'
),
+ auto_sync_new_schemas: zod
+ .boolean()
+ .optional()
+ .describe(
+ 'Automatically enable syncing for schemas discovered on this source after creation, on both the scheduled discovery pass and manual schema refreshes. Defaults to false. Not supported for direct-query sources.'
+ ),
+ auto_sync_schema_patterns: zod
+ .array(
+ zod
+ .string()
+ .max(externalDataSourcesDisableCdcCreateBodyAutoSyncSchemaPatternsItemMax)
+ .describe('An fnmatch-style glob pattern, e.g. `raw_\*`.')
+ )
+ .max(externalDataSourcesDisableCdcCreateBodyAutoSyncSchemaPatternsMax)
+ .nullish()
+ .describe(
+ 'Optional fnmatch-style globs (`\*` and `?` wildcards) restricting which newly discovered schema names auto-sync, matched case-insensitively against both the qualified and bare table name. Null or empty means every new schema qualifies. Only used when `auto_sync_new_schemas` is true.'
+ ),
job_inputs: zod.unknown().optional(),
})
.describe('Mixin for serializers to add user access control fields')
@@ -1797,6 +1929,10 @@ export const externalDataSourcesEnableCdcCreateBodyPrefixMax = 100
export const externalDataSourcesEnableCdcCreateBodyDescriptionMax = 400
+export const externalDataSourcesEnableCdcCreateBodyAutoSyncSchemaPatternsItemMax = 250
+
+export const externalDataSourcesEnableCdcCreateBodyAutoSyncSchemaPatternsMax = 100
+
export const ExternalDataSourcesEnableCdcCreateBody = /* @__PURE__ */ zod
.object({
created_via: zod
@@ -1822,6 +1958,24 @@ export const ExternalDataSourcesEnableCdcCreateBody = /* @__PURE__ */ zod
.describe(
'Whether this synced source is also live-queryable via direct connection. Defaults to false for new sources; ignored for pure direct-query sources.'
),
+ auto_sync_new_schemas: zod
+ .boolean()
+ .optional()
+ .describe(
+ 'Automatically enable syncing for schemas discovered on this source after creation, on both the scheduled discovery pass and manual schema refreshes. Defaults to false. Not supported for direct-query sources.'
+ ),
+ auto_sync_schema_patterns: zod
+ .array(
+ zod
+ .string()
+ .max(externalDataSourcesEnableCdcCreateBodyAutoSyncSchemaPatternsItemMax)
+ .describe('An fnmatch-style glob pattern, e.g. `raw_\*`.')
+ )
+ .max(externalDataSourcesEnableCdcCreateBodyAutoSyncSchemaPatternsMax)
+ .nullish()
+ .describe(
+ 'Optional fnmatch-style globs (`\*` and `?` wildcards) restricting which newly discovered schema names auto-sync, matched case-insensitively against both the qualified and bare table name. Null or empty means every new schema qualifies. Only used when `auto_sync_new_schemas` is true.'
+ ),
job_inputs: zod.unknown().optional(),
})
.describe('Mixin for serializers to add user access control fields')
@@ -1833,6 +1987,10 @@ export const externalDataSourcesRefreshSchemasCreateBodyPrefixMax = 100
export const externalDataSourcesRefreshSchemasCreateBodyDescriptionMax = 400
+export const externalDataSourcesRefreshSchemasCreateBodyAutoSyncSchemaPatternsItemMax = 250
+
+export const externalDataSourcesRefreshSchemasCreateBodyAutoSyncSchemaPatternsMax = 100
+
export const ExternalDataSourcesRefreshSchemasCreateBody = /* @__PURE__ */ zod
.object({
created_via: zod
@@ -1858,6 +2016,24 @@ export const ExternalDataSourcesRefreshSchemasCreateBody = /* @__PURE__ */ zod
.describe(
'Whether this synced source is also live-queryable via direct connection. Defaults to false for new sources; ignored for pure direct-query sources.'
),
+ auto_sync_new_schemas: zod
+ .boolean()
+ .optional()
+ .describe(
+ 'Automatically enable syncing for schemas discovered on this source after creation, on both the scheduled discovery pass and manual schema refreshes. Defaults to false. Not supported for direct-query sources.'
+ ),
+ auto_sync_schema_patterns: zod
+ .array(
+ zod
+ .string()
+ .max(externalDataSourcesRefreshSchemasCreateBodyAutoSyncSchemaPatternsItemMax)
+ .describe('An fnmatch-style glob pattern, e.g. `raw_\*`.')
+ )
+ .max(externalDataSourcesRefreshSchemasCreateBodyAutoSyncSchemaPatternsMax)
+ .nullish()
+ .describe(
+ 'Optional fnmatch-style globs (`\*` and `?` wildcards) restricting which newly discovered schema names auto-sync, matched case-insensitively against both the qualified and bare table name. Null or empty means every new schema qualifies. Only used when `auto_sync_new_schemas` is true.'
+ ),
job_inputs: zod.unknown().optional(),
})
.describe('Mixin for serializers to add user access control fields')
@@ -1869,6 +2045,10 @@ export const externalDataSourcesReloadCreateBodyPrefixMax = 100
export const externalDataSourcesReloadCreateBodyDescriptionMax = 400
+export const externalDataSourcesReloadCreateBodyAutoSyncSchemaPatternsItemMax = 250
+
+export const externalDataSourcesReloadCreateBodyAutoSyncSchemaPatternsMax = 100
+
export const ExternalDataSourcesReloadCreateBody = /* @__PURE__ */ zod
.object({
created_via: zod
@@ -1894,6 +2074,24 @@ export const ExternalDataSourcesReloadCreateBody = /* @__PURE__ */ zod
.describe(
'Whether this synced source is also live-queryable via direct connection. Defaults to false for new sources; ignored for pure direct-query sources.'
),
+ auto_sync_new_schemas: zod
+ .boolean()
+ .optional()
+ .describe(
+ 'Automatically enable syncing for schemas discovered on this source after creation, on both the scheduled discovery pass and manual schema refreshes. Defaults to false. Not supported for direct-query sources.'
+ ),
+ auto_sync_schema_patterns: zod
+ .array(
+ zod
+ .string()
+ .max(externalDataSourcesReloadCreateBodyAutoSyncSchemaPatternsItemMax)
+ .describe('An fnmatch-style glob pattern, e.g. `raw_\*`.')
+ )
+ .max(externalDataSourcesReloadCreateBodyAutoSyncSchemaPatternsMax)
+ .nullish()
+ .describe(
+ 'Optional fnmatch-style globs (`\*` and `?` wildcards) restricting which newly discovered schema names auto-sync, matched case-insensitively against both the qualified and bare table name. Null or empty means every new schema qualifies. Only used when `auto_sync_new_schemas` is true.'
+ ),
job_inputs: zod.unknown().optional(),
})
.describe('Mixin for serializers to add user access control fields')
@@ -1905,6 +2103,10 @@ export const externalDataSourcesRevenueAnalyticsConfigPartialUpdateBodyPrefixMax
export const externalDataSourcesRevenueAnalyticsConfigPartialUpdateBodyDescriptionMax = 400
+export const externalDataSourcesRevenueAnalyticsConfigPartialUpdateBodyAutoSyncSchemaPatternsItemMax = 250
+
+export const externalDataSourcesRevenueAnalyticsConfigPartialUpdateBodyAutoSyncSchemaPatternsMax = 100
+
export const ExternalDataSourcesRevenueAnalyticsConfigPartialUpdateBody = /* @__PURE__ */ zod
.object({
created_via: zod
@@ -1933,6 +2135,24 @@ export const ExternalDataSourcesRevenueAnalyticsConfigPartialUpdateBody = /* @__
.describe(
'Whether this synced source is also live-queryable via direct connection. Defaults to false for new sources; ignored for pure direct-query sources.'
),
+ auto_sync_new_schemas: zod
+ .boolean()
+ .optional()
+ .describe(
+ 'Automatically enable syncing for schemas discovered on this source after creation, on both the scheduled discovery pass and manual schema refreshes. Defaults to false. Not supported for direct-query sources.'
+ ),
+ auto_sync_schema_patterns: zod
+ .array(
+ zod
+ .string()
+ .max(externalDataSourcesRevenueAnalyticsConfigPartialUpdateBodyAutoSyncSchemaPatternsItemMax)
+ .describe('An fnmatch-style glob pattern, e.g. `raw_\*`.')
+ )
+ .max(externalDataSourcesRevenueAnalyticsConfigPartialUpdateBodyAutoSyncSchemaPatternsMax)
+ .nullish()
+ .describe(
+ 'Optional fnmatch-style globs (`\*` and `?` wildcards) restricting which newly discovered schema names auto-sync, matched case-insensitively against both the qualified and bare table name. Null or empty means every new schema qualifies. Only used when `auto_sync_new_schemas` is true.'
+ ),
job_inputs: zod.unknown().optional(),
})
.describe('Mixin for serializers to add user access control fields')
@@ -1949,6 +2169,10 @@ export const externalDataSourcesUpdateCdcSettingsCreateBodyPrefixMax = 100
export const externalDataSourcesUpdateCdcSettingsCreateBodyDescriptionMax = 400
+export const externalDataSourcesUpdateCdcSettingsCreateBodyAutoSyncSchemaPatternsItemMax = 250
+
+export const externalDataSourcesUpdateCdcSettingsCreateBodyAutoSyncSchemaPatternsMax = 100
+
export const ExternalDataSourcesUpdateCdcSettingsCreateBody = /* @__PURE__ */ zod
.object({
created_via: zod
@@ -1974,6 +2198,24 @@ export const ExternalDataSourcesUpdateCdcSettingsCreateBody = /* @__PURE__ */ zo
.describe(
'Whether this synced source is also live-queryable via direct connection. Defaults to false for new sources; ignored for pure direct-query sources.'
),
+ auto_sync_new_schemas: zod
+ .boolean()
+ .optional()
+ .describe(
+ 'Automatically enable syncing for schemas discovered on this source after creation, on both the scheduled discovery pass and manual schema refreshes. Defaults to false. Not supported for direct-query sources.'
+ ),
+ auto_sync_schema_patterns: zod
+ .array(
+ zod
+ .string()
+ .max(externalDataSourcesUpdateCdcSettingsCreateBodyAutoSyncSchemaPatternsItemMax)
+ .describe('An fnmatch-style glob pattern, e.g. `raw_\*`.')
+ )
+ .max(externalDataSourcesUpdateCdcSettingsCreateBodyAutoSyncSchemaPatternsMax)
+ .nullish()
+ .describe(
+ 'Optional fnmatch-style globs (`\*` and `?` wildcards) restricting which newly discovered schema names auto-sync, matched case-insensitively against both the qualified and bare table name. Null or empty means every new schema qualifies. Only used when `auto_sync_new_schemas` is true.'
+ ),
job_inputs: zod.unknown().optional(),
})
.describe('Mixin for serializers to add user access control fields')
@@ -1985,6 +2227,10 @@ export const externalDataSourcesUpdateWebhookInputsCreateBodyPrefixMax = 100
export const externalDataSourcesUpdateWebhookInputsCreateBodyDescriptionMax = 400
+export const externalDataSourcesUpdateWebhookInputsCreateBodyAutoSyncSchemaPatternsItemMax = 250
+
+export const externalDataSourcesUpdateWebhookInputsCreateBodyAutoSyncSchemaPatternsMax = 100
+
export const ExternalDataSourcesUpdateWebhookInputsCreateBody = /* @__PURE__ */ zod
.object({
created_via: zod
@@ -2010,6 +2256,24 @@ export const ExternalDataSourcesUpdateWebhookInputsCreateBody = /* @__PURE__ */
.describe(
'Whether this synced source is also live-queryable via direct connection. Defaults to false for new sources; ignored for pure direct-query sources.'
),
+ auto_sync_new_schemas: zod
+ .boolean()
+ .optional()
+ .describe(
+ 'Automatically enable syncing for schemas discovered on this source after creation, on both the scheduled discovery pass and manual schema refreshes. Defaults to false. Not supported for direct-query sources.'
+ ),
+ auto_sync_schema_patterns: zod
+ .array(
+ zod
+ .string()
+ .max(externalDataSourcesUpdateWebhookInputsCreateBodyAutoSyncSchemaPatternsItemMax)
+ .describe('An fnmatch-style glob pattern, e.g. `raw_\*`.')
+ )
+ .max(externalDataSourcesUpdateWebhookInputsCreateBodyAutoSyncSchemaPatternsMax)
+ .nullish()
+ .describe(
+ 'Optional fnmatch-style globs (`\*` and `?` wildcards) restricting which newly discovered schema names auto-sync, matched case-insensitively against both the qualified and bare table name. Null or empty means every new schema qualifies. Only used when `auto_sync_new_schemas` is true.'
+ ),
job_inputs: zod.unknown().optional(),
})
.describe('Mixin for serializers to add user access control fields')
@@ -4735,6 +4999,10 @@ export const externalDataSourcesSourcePrefixCreateBodyPrefixMax = 100
export const externalDataSourcesSourcePrefixCreateBodyDescriptionMax = 400
+export const externalDataSourcesSourcePrefixCreateBodyAutoSyncSchemaPatternsItemMax = 250
+
+export const externalDataSourcesSourcePrefixCreateBodyAutoSyncSchemaPatternsMax = 100
+
export const ExternalDataSourcesSourcePrefixCreateBody = /* @__PURE__ */ zod
.object({
created_via: zod
@@ -4760,6 +5028,24 @@ export const ExternalDataSourcesSourcePrefixCreateBody = /* @__PURE__ */ zod
.describe(
'Whether this synced source is also live-queryable via direct connection. Defaults to false for new sources; ignored for pure direct-query sources.'
),
+ auto_sync_new_schemas: zod
+ .boolean()
+ .optional()
+ .describe(
+ 'Automatically enable syncing for schemas discovered on this source after creation, on both the scheduled discovery pass and manual schema refreshes. Defaults to false. Not supported for direct-query sources.'
+ ),
+ auto_sync_schema_patterns: zod
+ .array(
+ zod
+ .string()
+ .max(externalDataSourcesSourcePrefixCreateBodyAutoSyncSchemaPatternsItemMax)
+ .describe('An fnmatch-style glob pattern, e.g. `raw_\*`.')
+ )
+ .max(externalDataSourcesSourcePrefixCreateBodyAutoSyncSchemaPatternsMax)
+ .nullish()
+ .describe(
+ 'Optional fnmatch-style globs (`\*` and `?` wildcards) restricting which newly discovered schema names auto-sync, matched case-insensitively against both the qualified and bare table name. Null or empty means every new schema qualifies. Only used when `auto_sync_new_schemas` is true.'
+ ),
job_inputs: zod.unknown().optional(),
})
.describe('Mixin for serializers to add user access control fields')
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index 2592fc8b16ef..926a1006b79c 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -27765,6 +27765,15 @@ export namespace Schemas {
readonly access_method: AccessMethodEnum;
/** Whether this synced source is also live-queryable via direct connection. Defaults to false for new sources; ignored for pure direct-query sources. */
direct_query_enabled?: boolean;
+ /** Automatically enable syncing for schemas discovered on this source after creation, on both the scheduled discovery pass and manual schema refreshes. Defaults to false. Not supported for direct-query sources. */
+ auto_sync_new_schemas?: boolean;
+ /**
+ * Optional fnmatch-style globs (`*` and `?` wildcards) restricting which newly discovered schema names auto-sync, matched case-insensitively against both the qualified and bare table name. Null or empty means every new schema qualifies. Only used when `auto_sync_new_schemas` is true.
+ * @maxItems 100
+ * @nullable
+ * @items.maxLength 250
+ */
+ auto_sync_schema_patterns?: string[] | null;
/** Backend engine detected for the direct connection.
*
* * `duckdb` - duckdb
@@ -44329,6 +44338,15 @@ export namespace Schemas {
readonly access_method?: AccessMethodEnum;
/** Whether this synced source is also live-queryable via direct connection. Defaults to false for new sources; ignored for pure direct-query sources. */
direct_query_enabled?: boolean;
+ /** Automatically enable syncing for schemas discovered on this source after creation, on both the scheduled discovery pass and manual schema refreshes. Defaults to false. Not supported for direct-query sources. */
+ auto_sync_new_schemas?: boolean;
+ /**
+ * Optional fnmatch-style globs (`*` and `?` wildcards) restricting which newly discovered schema names auto-sync, matched case-insensitively against both the qualified and bare table name. Null or empty means every new schema qualifies. Only used when `auto_sync_new_schemas` is true.
+ * @maxItems 100
+ * @nullable
+ * @items.maxLength 250
+ */
+ auto_sync_schema_patterns?: string[] | null;
/** Backend engine detected for the direct connection.
*
* * `duckdb` - duckdb
diff --git a/services/mcp/src/generated/warehouse_sources/api.ts b/services/mcp/src/generated/warehouse_sources/api.ts
index 4ae4cc9ecdde..bd5017a245d3 100644
--- a/services/mcp/src/generated/warehouse_sources/api.ts
+++ b/services/mcp/src/generated/warehouse_sources/api.ts
@@ -1484,6 +1484,10 @@ export const externalDataSourcesPartialUpdateBodyPrefixMax = 100
export const externalDataSourcesPartialUpdateBodyDescriptionMax = 400
+export const externalDataSourcesPartialUpdateBodyAutoSyncSchemaPatternsItemMax = 250
+
+export const externalDataSourcesPartialUpdateBodyAutoSyncSchemaPatternsMax = 100
+
export const ExternalDataSourcesPartialUpdateBody = /* @__PURE__ */ zod
.object({
created_via: zod
@@ -1509,6 +1513,24 @@ export const ExternalDataSourcesPartialUpdateBody = /* @__PURE__ */ zod
.describe(
'Whether this synced source is also live-queryable via direct connection. Defaults to false for new sources; ignored for pure direct-query sources.'
),
+ auto_sync_new_schemas: zod
+ .boolean()
+ .optional()
+ .describe(
+ 'Automatically enable syncing for schemas discovered on this source after creation, on both the scheduled discovery pass and manual schema refreshes. Defaults to false. Not supported for direct-query sources.'
+ ),
+ auto_sync_schema_patterns: zod
+ .array(
+ zod
+ .string()
+ .max(externalDataSourcesPartialUpdateBodyAutoSyncSchemaPatternsItemMax)
+ .describe('An fnmatch-style glob pattern, e.g. `raw_*`.')
+ )
+ .max(externalDataSourcesPartialUpdateBodyAutoSyncSchemaPatternsMax)
+ .nullish()
+ .describe(
+ 'Optional fnmatch-style globs (`*` and `?` wildcards) restricting which newly discovered schema names auto-sync, matched case-insensitively against both the qualified and bare table name. Null or empty means every new schema qualifies. Only used when `auto_sync_new_schemas` is true.'
+ ),
job_inputs: zod.unknown().optional(),
})
.describe('Mixin for serializers to add user access control fields')
@@ -1541,6 +1563,10 @@ export const externalDataSourcesCreateWebhookCreateBodyPrefixMax = 100
export const externalDataSourcesCreateWebhookCreateBodyDescriptionMax = 400
+export const externalDataSourcesCreateWebhookCreateBodyAutoSyncSchemaPatternsItemMax = 250
+
+export const externalDataSourcesCreateWebhookCreateBodyAutoSyncSchemaPatternsMax = 100
+
export const ExternalDataSourcesCreateWebhookCreateBody = /* @__PURE__ */ zod
.object({
created_via: zod
@@ -1566,6 +1592,24 @@ export const ExternalDataSourcesCreateWebhookCreateBody = /* @__PURE__ */ zod
.describe(
'Whether this synced source is also live-queryable via direct connection. Defaults to false for new sources; ignored for pure direct-query sources.'
),
+ auto_sync_new_schemas: zod
+ .boolean()
+ .optional()
+ .describe(
+ 'Automatically enable syncing for schemas discovered on this source after creation, on both the scheduled discovery pass and manual schema refreshes. Defaults to false. Not supported for direct-query sources.'
+ ),
+ auto_sync_schema_patterns: zod
+ .array(
+ zod
+ .string()
+ .max(externalDataSourcesCreateWebhookCreateBodyAutoSyncSchemaPatternsItemMax)
+ .describe('An fnmatch-style glob pattern, e.g. `raw_*`.')
+ )
+ .max(externalDataSourcesCreateWebhookCreateBodyAutoSyncSchemaPatternsMax)
+ .nullish()
+ .describe(
+ 'Optional fnmatch-style globs (`*` and `?` wildcards) restricting which newly discovered schema names auto-sync, matched case-insensitively against both the qualified and bare table name. Null or empty means every new schema qualifies. Only used when `auto_sync_new_schemas` is true.'
+ ),
job_inputs: zod.unknown().optional(),
})
.describe('Mixin for serializers to add user access control fields')
@@ -1586,6 +1630,10 @@ export const externalDataSourcesDeleteWebhookCreateBodyPrefixMax = 100
export const externalDataSourcesDeleteWebhookCreateBodyDescriptionMax = 400
+export const externalDataSourcesDeleteWebhookCreateBodyAutoSyncSchemaPatternsItemMax = 250
+
+export const externalDataSourcesDeleteWebhookCreateBodyAutoSyncSchemaPatternsMax = 100
+
export const ExternalDataSourcesDeleteWebhookCreateBody = /* @__PURE__ */ zod
.object({
created_via: zod
@@ -1611,6 +1659,24 @@ export const ExternalDataSourcesDeleteWebhookCreateBody = /* @__PURE__ */ zod
.describe(
'Whether this synced source is also live-queryable via direct connection. Defaults to false for new sources; ignored for pure direct-query sources.'
),
+ auto_sync_new_schemas: zod
+ .boolean()
+ .optional()
+ .describe(
+ 'Automatically enable syncing for schemas discovered on this source after creation, on both the scheduled discovery pass and manual schema refreshes. Defaults to false. Not supported for direct-query sources.'
+ ),
+ auto_sync_schema_patterns: zod
+ .array(
+ zod
+ .string()
+ .max(externalDataSourcesDeleteWebhookCreateBodyAutoSyncSchemaPatternsItemMax)
+ .describe('An fnmatch-style glob pattern, e.g. `raw_*`.')
+ )
+ .max(externalDataSourcesDeleteWebhookCreateBodyAutoSyncSchemaPatternsMax)
+ .nullish()
+ .describe(
+ 'Optional fnmatch-style globs (`*` and `?` wildcards) restricting which newly discovered schema names auto-sync, matched case-insensitively against both the qualified and bare table name. Null or empty means every new schema qualifies. Only used when `auto_sync_new_schemas` is true.'
+ ),
job_inputs: zod.unknown().optional(),
})
.describe('Mixin for serializers to add user access control fields')
@@ -1627,6 +1693,10 @@ export const ExternalDataSourcesRefreshSchemasCreateParams = /* @__PURE__ */ zod
),
})
+export const externalDataSourcesRefreshSchemasCreateBodyAutoSyncSchemaPatternsItemMax = 250
+
+export const externalDataSourcesRefreshSchemasCreateBodyAutoSyncSchemaPatternsMax = 100
+
export const ExternalDataSourcesRefreshSchemasCreateBody = /* @__PURE__ */ zod
.object({
created_via: zod
@@ -1648,6 +1718,24 @@ export const ExternalDataSourcesRefreshSchemasCreateBody = /* @__PURE__ */ zod
.describe(
'Whether this synced source is also live-queryable via direct connection. Defaults to false for new sources; ignored for pure direct-query sources.'
),
+ auto_sync_new_schemas: zod
+ .boolean()
+ .optional()
+ .describe(
+ 'Automatically enable syncing for schemas discovered on this source after creation, on both the scheduled discovery pass and manual schema refreshes. Defaults to false. Not supported for direct-query sources.'
+ ),
+ auto_sync_schema_patterns: zod
+ .array(
+ zod
+ .string()
+ .max(externalDataSourcesRefreshSchemasCreateBodyAutoSyncSchemaPatternsItemMax)
+ .describe('An fnmatch-style glob pattern, e.g. `raw_*`.')
+ )
+ .max(externalDataSourcesRefreshSchemasCreateBodyAutoSyncSchemaPatternsMax)
+ .nullish()
+ .describe(
+ 'Optional fnmatch-style globs (`*` and `?` wildcards) restricting which newly discovered schema names auto-sync, matched case-insensitively against both the qualified and bare table name. Null or empty means every new schema qualifies. Only used when `auto_sync_new_schemas` is true.'
+ ),
})
.describe('Mixin for serializers to add user access control fields')
@@ -1663,6 +1751,10 @@ export const ExternalDataSourcesReloadCreateParams = /* @__PURE__ */ zod.object(
),
})
+export const externalDataSourcesReloadCreateBodyAutoSyncSchemaPatternsItemMax = 250
+
+export const externalDataSourcesReloadCreateBodyAutoSyncSchemaPatternsMax = 100
+
export const ExternalDataSourcesReloadCreateBody = /* @__PURE__ */ zod
.object({
created_via: zod
@@ -1684,6 +1776,24 @@ export const ExternalDataSourcesReloadCreateBody = /* @__PURE__ */ zod
.describe(
'Whether this synced source is also live-queryable via direct connection. Defaults to false for new sources; ignored for pure direct-query sources.'
),
+ auto_sync_new_schemas: zod
+ .boolean()
+ .optional()
+ .describe(
+ 'Automatically enable syncing for schemas discovered on this source after creation, on both the scheduled discovery pass and manual schema refreshes. Defaults to false. Not supported for direct-query sources.'
+ ),
+ auto_sync_schema_patterns: zod
+ .array(
+ zod
+ .string()
+ .max(externalDataSourcesReloadCreateBodyAutoSyncSchemaPatternsItemMax)
+ .describe('An fnmatch-style glob pattern, e.g. `raw_*`.')
+ )
+ .max(externalDataSourcesReloadCreateBodyAutoSyncSchemaPatternsMax)
+ .nullish()
+ .describe(
+ 'Optional fnmatch-style globs (`*` and `?` wildcards) restricting which newly discovered schema names auto-sync, matched case-insensitively against both the qualified and bare table name. Null or empty means every new schema qualifies. Only used when `auto_sync_new_schemas` is true.'
+ ),
})
.describe('Mixin for serializers to add user access control fields')
@@ -1724,6 +1834,10 @@ export const externalDataSourcesUpdateWebhookInputsCreateBodyPrefixMax = 100
export const externalDataSourcesUpdateWebhookInputsCreateBodyDescriptionMax = 400
+export const externalDataSourcesUpdateWebhookInputsCreateBodyAutoSyncSchemaPatternsItemMax = 250
+
+export const externalDataSourcesUpdateWebhookInputsCreateBodyAutoSyncSchemaPatternsMax = 100
+
export const ExternalDataSourcesUpdateWebhookInputsCreateBody = /* @__PURE__ */ zod
.object({
created_via: zod
@@ -1749,6 +1863,24 @@ export const ExternalDataSourcesUpdateWebhookInputsCreateBody = /* @__PURE__ */
.describe(
'Whether this synced source is also live-queryable via direct connection. Defaults to false for new sources; ignored for pure direct-query sources.'
),
+ auto_sync_new_schemas: zod
+ .boolean()
+ .optional()
+ .describe(
+ 'Automatically enable syncing for schemas discovered on this source after creation, on both the scheduled discovery pass and manual schema refreshes. Defaults to false. Not supported for direct-query sources.'
+ ),
+ auto_sync_schema_patterns: zod
+ .array(
+ zod
+ .string()
+ .max(externalDataSourcesUpdateWebhookInputsCreateBodyAutoSyncSchemaPatternsItemMax)
+ .describe('An fnmatch-style glob pattern, e.g. `raw_*`.')
+ )
+ .max(externalDataSourcesUpdateWebhookInputsCreateBodyAutoSyncSchemaPatternsMax)
+ .nullish()
+ .describe(
+ 'Optional fnmatch-style globs (`*` and `?` wildcards) restricting which newly discovered schema names auto-sync, matched case-insensitively against both the qualified and bare table name. Null or empty means every new schema qualifies. Only used when `auto_sync_new_schemas` is true.'
+ ),
job_inputs: zod.unknown().optional(),
})
.describe('Mixin for serializers to add user access control fields')
diff --git a/services/mcp/src/tools/generated/warehouse_sources.ts b/services/mcp/src/tools/generated/warehouse_sources.ts
index dd5bf5084e19..b88b7251ca24 100644
--- a/services/mcp/src/tools/generated/warehouse_sources.ts
+++ b/services/mcp/src/tools/generated/warehouse_sources.ts
@@ -541,6 +541,12 @@ const externalDataSourcesCreateWebhookCreate = (): ToolBase<
if (params.direct_query_enabled !== undefined) {
body['direct_query_enabled'] = params.direct_query_enabled
}
+ if (params.auto_sync_new_schemas !== undefined) {
+ body['auto_sync_new_schemas'] = params.auto_sync_new_schemas
+ }
+ if (params.auto_sync_schema_patterns !== undefined) {
+ body['auto_sync_schema_patterns'] = params.auto_sync_schema_patterns
+ }
if (params.job_inputs !== undefined) {
body['job_inputs'] = params.job_inputs
}
@@ -584,6 +590,12 @@ const externalDataSourcesDeleteWebhookCreate = (): ToolBase<
if (params.direct_query_enabled !== undefined) {
body['direct_query_enabled'] = params.direct_query_enabled
}
+ if (params.auto_sync_new_schemas !== undefined) {
+ body['auto_sync_new_schemas'] = params.auto_sync_new_schemas
+ }
+ if (params.auto_sync_schema_patterns !== undefined) {
+ body['auto_sync_schema_patterns'] = params.auto_sync_schema_patterns
+ }
if (params.job_inputs !== undefined) {
body['job_inputs'] = params.job_inputs
}
@@ -671,6 +683,12 @@ const externalDataSourcesPartialUpdate = (): ToolBase<
if (params.direct_query_enabled !== undefined) {
body['direct_query_enabled'] = params.direct_query_enabled
}
+ if (params.auto_sync_new_schemas !== undefined) {
+ body['auto_sync_new_schemas'] = params.auto_sync_new_schemas
+ }
+ if (params.auto_sync_schema_patterns !== undefined) {
+ body['auto_sync_schema_patterns'] = params.auto_sync_schema_patterns
+ }
if (params.job_inputs !== undefined) {
body['job_inputs'] = params.job_inputs
}
@@ -699,6 +717,12 @@ const externalDataSourcesRefreshSchemas = (): ToolBase<typeof ExternalDataSource
if (params.direct_query_enabled !== undefined) {
body['direct_query_enabled'] = params.direct_query_enabled
}
+ if (params.auto_sync_new_schemas !== undefined) {
+ body['auto_sync_new_schemas'] = params.auto_sync_new_schemas
+ }
+ if (params.auto_sync_schema_patterns !== undefined) {
+ body['auto_sync_schema_patterns'] = params.auto_sync_schema_patterns
+ }
const result = await context.api.request<unknown>({
method: 'POST',
path: `/api/projects/${encodeURIComponent(String(projectId))}/external_data_sources/${encodeURIComponent(String(params.id))}/refresh_schemas/`,
@@ -724,6 +748,12 @@ const externalDataSourcesReload = (): ToolBase<typeof ExternalDataSourcesReloadS
if (params.direct_query_enabled !== undefined) {
body['direct_query_enabled'] = params.direct_query_enabled
}
+ if (params.auto_sync_new_schemas !== undefined) {
+ body['auto_sync_new_schemas'] = params.auto_sync_new_schemas
+ }
+ if (params.auto_sync_schema_patterns !== undefined) {
+ body['auto_sync_schema_patterns'] = params.auto_sync_schema_patterns
+ }
const result = await context.api.request<unknown>({
method: 'POST',
path: `/api/projects/${encodeURIComponent(String(projectId))}/external_data_sources/${encodeURIComponent(String(params.id))}/reload/`,
@@ -797,6 +827,12 @@ const externalDataSourcesUpdateWebhookInputsCreate = (): ToolBase<
if (params.direct_query_enabled !== undefined) {
body['direct_query_enabled'] = params.direct_query_enabled
}
+ if (params.auto_sync_new_schemas !== undefined) {
+ body['auto_sync_new_schemas'] = params.auto_sync_new_schemas
+ }
+ if (params.auto_sync_schema_patterns !== undefined) {
+ body['auto_sync_schema_patterns'] = params.auto_sync_schema_patterns
+ }
if (params.job_inputs !== undefined) {
body['job_inputs'] = params.job_inputs
}
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/external-data-sources-create-webhook-create.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/external-data-sources-create-webhook-create.json
index 712294f16e32..1fdc67fa973d 100644
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/external-data-sources-create-webhook-create.json
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/external-data-sources-create-webhook-create.json
@@ -4,6 +4,27 @@
"account_id": {
"type": "string"
},
+ "auto_sync_new_schemas": {
+ "description": "Automatically enable syncing for schemas discovered on this source after creation, on both the scheduled discovery pass and manual schema refreshes. Defaults to false. Not supported for direct-query sources.",
+ "type": "boolean"
+ },
+ "auto_sync_schema_patterns": {
+ "anyOf": [
+ {
+ "items": {
+ "description": "An fnmatch-style glob pattern, e.g. `raw_*`.",
+ "maxLength": 250,
+ "type": "string"
+ },
+ "maxItems": 100,
+ "type": "array"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "Optional fnmatch-style globs (`*` and `?` wildcards) restricting which newly discovered schema names auto-sync, matched case-insensitively against both the qualified and bare table name. Null or empty means every new schema qualifies. Only used when `auto_sync_new_schemas` is true."
+ },
"client_secret": {
"type": "string"
},
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/external-data-sources-delete-webhook-create.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/external-data-sources-delete-webhook-create.json
index 712294f16e32..1fdc67fa973d 100644
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/external-data-sources-delete-webhook-create.json
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/external-data-sources-delete-webhook-create.json
@@ -4,6 +4,27 @@
"account_id": {
"type": "string"
},
+ "auto_sync_new_schemas": {
+ "description": "Automatically enable syncing for schemas discovered on this source after creation, on both the scheduled discovery pass and manual schema refreshes. Defaults to false. Not supported for direct-query sources.",
+ "type": "boolean"
+ },
+ "auto_sync_schema_patterns": {
+ "anyOf": [
+ {
+ "items": {
+ "description": "An fnmatch-style glob pattern, e.g. `raw_*`.",
+ "maxLength": 250,
+ "type": "string"
+ },
+ "maxItems": 100,
+ "type": "array"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "Optional fnmatch-style globs (`*` and `?` wildcards) restricting which newly discovered schema names auto-sync, matched case-insensitively against both the qualified and bare table name. Null or empty means every new schema qualifies. Only used when `auto_sync_new_schemas` is true."
+ },
"client_secret": {
"type": "string"
},
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/external-data-sources-partial-update.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/external-data-sources-partial-update.json
index 11c576e13359..e9e807dfb2c1 100644
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/external-data-sources-partial-update.json
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/external-data-sources-partial-update.json
@@ -4,6 +4,27 @@
"account_id": {
"type": "string"
},
+ "auto_sync_new_schemas": {
+ "description": "Automatically enable syncing for schemas discovered on this source after creation, on both the scheduled discovery pass and manual schema refreshes. Defaults to false. Not supported for direct-query sources.",
+ "type": "boolean"
+ },
+ "auto_sync_schema_patterns": {
+ "anyOf": [
+ {
+ "items": {
+ "description": "An fnmatch-style glob pattern, e.g. `raw_*`.",
+ "maxLength": 250,
+ "type": "string"
+ },
+ "maxItems": 100,
+ "type": "array"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "Optional fnmatch-style globs (`*` and `?` wildcards) restricting which newly discovered schema names auto-sync, matched case-insensitively against both the qualified and bare table name. Null or empty means every new schema qualifies. Only used when `auto_sync_new_schemas` is true."
+ },
"client_secret": {
"type": "string"
},
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/external-data-sources-refresh-schemas.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/external-data-sources-refresh-schemas.json
index 65bcba896f0c..92548a03a0df 100644
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/external-data-sources-refresh-schemas.json
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/external-data-sources-refresh-schemas.json
@@ -1,6 +1,27 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"properties": {
+ "auto_sync_new_schemas": {
+ "description": "Automatically enable syncing for schemas discovered on this source after creation, on both the scheduled discovery pass and manual schema refreshes. Defaults to false. Not supported for direct-query sources.",
+ "type": "boolean"
+ },
+ "auto_sync_schema_patterns": {
+ "anyOf": [
+ {
+ "items": {
+ "description": "An fnmatch-style glob pattern, e.g. `raw_*`.",
+ "maxLength": 250,
+ "type": "string"
+ },
+ "maxItems": 100,
+ "type": "array"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "Optional fnmatch-style globs (`*` and `?` wildcards) restricting which newly discovered schema names auto-sync, matched case-insensitively against both the qualified and bare table name. Null or empty means every new schema qualifies. Only used when `auto_sync_new_schemas` is true."
+ },
"created_via": {
"anyOf": [
{
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/external-data-sources-reload.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/external-data-sources-reload.json
index 65bcba896f0c..92548a03a0df 100644
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/external-data-sources-reload.json
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/external-data-sources-reload.json
@@ -1,6 +1,27 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"properties": {
+ "auto_sync_new_schemas": {
+ "description": "Automatically enable syncing for schemas discovered on this source after creation, on both the scheduled discovery pass and manual schema refreshes. Defaults to false. Not supported for direct-query sources.",
+ "type": "boolean"
+ },
+ "auto_sync_schema_patterns": {
+ "anyOf": [
+ {
+ "items": {
+ "description": "An fnmatch-style glob pattern, e.g. `raw_*`.",
+ "maxLength": 250,
+ "type": "string"
+ },
+ "maxItems": 100,
+ "type": "array"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "Optional fnmatch-style globs (`*` and `?` wildcards) restricting which newly discovered schema names auto-sync, matched case-insensitively against both the qualified and bare table name. Null or empty means every new schema qualifies. Only used when `auto_sync_new_schemas` is true."
+ },
"created_via": {
"anyOf": [
{
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/external-data-sources-update-webhook-inputs-create.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/external-data-sources-update-webhook-inputs-create.json
index 712294f16e32..1fdc67fa973d 100644
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/external-data-sources-update-webhook-inputs-create.json
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/external-data-sources-update-webhook-inputs-create.json
@@ -4,6 +4,27 @@
"account_id": {
"type": "string"
},
+ "auto_sync_new_schemas": {
+ "description": "Automatically enable syncing for schemas discovered on this source after creation, on both the scheduled discovery pass and manual schema refreshes. Defaults to false. Not supported for direct-query sources.",
+ "type": "boolean"
+ },
+ "auto_sync_schema_patterns": {
+ "anyOf": [
+ {
+ "items": {
+ "description": "An fnmatch-style glob pattern, e.g. `raw_*`.",
+ "maxLength": 250,
+ "type": "string"
+ },
+ "maxItems": 100,
+ "type": "array"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "Optional fnmatch-style globs (`*` and `?` wildcards) restricting which newly discovered schema names auto-sync, matched case-insensitively against both the qualified and bare table name. Null or empty means every new schema qualifies. Only used when `auto_sync_new_schemas` is true."
+ },
"client_secret": {
"type": "string"
},