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): pick the time of day for scheduled full refreshes (#109171)

Daniel RC4462e01f4497
diff --git a/posthog/models/activity_logging/activity_log.py b/posthog/models/activity_logging/activity_log.py
index 30c75024dbd0..7f0e1d371b41 100644
--- a/posthog/models/activity_logging/activity_log.py
+++ b/posthog/models/activity_logging/activity_log.py
@@ -394,6 +394,7 @@ field_name_overrides: dict[AuditableScope, dict[str, str]] = {
"ExternalDataSchema": {
"should_sync": "enabled",
"full_refresh_interval_days": "full refresh interval (days)",
+ "full_refresh_time_of_day": "full refresh time (UTC)",
},
"SignalScoutConfig": {
"run_interval_minutes": "run interval (minutes)",
diff --git a/products/data_warehouse/frontend/scenes/SchemaScene/ConfigurationTab.tsx b/products/data_warehouse/frontend/scenes/SchemaScene/ConfigurationTab.tsx
index 5815be6d925a..ab263fca5d88 100644
--- a/products/data_warehouse/frontend/scenes/SchemaScene/ConfigurationTab.tsx
+++ b/products/data_warehouse/frontend/scenes/SchemaScene/ConfigurationTab.tsx
@@ -883,7 +883,29 @@ const MIN_FULL_REFRESH_DAYS_BY_FREQUENCY: Partial<Record<DataWarehouseSyncInterv
}
type ScheduleSectionSchema = ExternalDataSourceSchema &
- Partial<Pick<ExternalDataSchemaApi, 'full_refresh_interval_days' | 'next_full_refresh_at'>>
+ Partial<
+ Pick<ExternalDataSchemaApi, 'full_refresh_interval_days' | 'full_refresh_time_of_day' | 'next_full_refresh_at'>
+ >
+
+function utcTimeToDisplayTime(utcTime: string, isProjectTime: boolean, timezone: string): string {
+ return isProjectTime
+ ? dayjs
+ .utc(`${dayjs().format('YYYY-MM-DD')}T${utcTime}`)
+ .tz(timezone)
+ .format('HH:mm:00')
+ : utcTime
+}
+
+function displayTimeToUtcTime(displayTime: string, isProjectTime: boolean, timezone: string): string {
+ // dayjs.tz(str, zone) interprets the wall-clock time in the project
+ // timezone; plain dayjs(str) would parse it in the browser's timezone.
+ return isProjectTime
+ ? dayjs
+ .tz(`${dayjs().format('YYYY-MM-DD')}T${displayTime}`, timezone)
+ .utc()
+ .format('HH:mm:00')
+ : displayTime
+}
function fullRefreshDaysError(days: number | null, frequency: DataWarehouseSyncInterval): string | null {
if (days === null) {
@@ -927,12 +949,16 @@ function ScheduleSection({
const [draftFullRefreshDays, setDraftFullRefreshDays] = useState<number | null>(
schema.full_refresh_interval_days ?? null
)
+ const [draftFullRefreshTime, setDraftFullRefreshTime] = useState<string | null>(
+ schema.full_refresh_time_of_day ?? null
+ )
const [saving, setSaving] = useState(false)
const { disabledReason: accessDisabledReason } = useSchemaEditorAccess(schema)
const serverFrequency = schema.sync_frequency || (isCdc ? '5min' : '6hour')
const serverSyncTimeOfDay = schema.sync_time_of_day ?? null
const serverFullRefreshDays = schema.full_refresh_interval_days ?? null
+ const serverFullRefreshTime = schema.full_refresh_time_of_day ?? null
// Reset the draft when the user navigates to a different schema or when the server values
// change (e.g. after the sync type switches between CDC and non-CDC, which flips the default
@@ -941,12 +967,13 @@ function ScheduleSection({
setDraftFrequency(serverFrequency)
setDraftSyncTimeOfDay(serverSyncTimeOfDay)
setDraftFullRefreshDays(serverFullRefreshDays)
- }, [schema.id, serverFrequency, serverSyncTimeOfDay, serverFullRefreshDays])
+ setDraftFullRefreshTime(serverFullRefreshTime)
+ }, [schema.id, serverFrequency, serverSyncTimeOfDay, serverFullRefreshDays, serverFullRefreshTime])
+ const isFullRefreshDraftSaved =
+ draftFullRefreshDays === serverFullRefreshDays && draftFullRefreshTime === serverFullRefreshTime
const isDirty =
- draftFrequency !== serverFrequency ||
- draftSyncTimeOfDay !== serverSyncTimeOfDay ||
- draftFullRefreshDays !== serverFullRefreshDays
+ draftFrequency !== serverFrequency || draftSyncTimeOfDay !== serverSyncTimeOfDay || !isFullRefreshDraftSaved
const fullRefreshError = supportsScheduledFullRefresh
? fullRefreshDaysError(draftFullRefreshDays, draftFrequency)
: null
@@ -965,7 +992,12 @@ function ScheduleSection({
sync_frequency: draftFrequency,
sync_time_of_day: draftSyncTimeOfDay,
cdc_table_mode: schema.cdc_table_mode,
- ...(supportsScheduledFullRefresh ? { full_refresh_interval_days: draftFullRefreshDays } : {}),
+ ...(supportsScheduledFullRefresh
+ ? {
+ full_refresh_interval_days: draftFullRefreshDays,
+ full_refresh_time_of_day: draftFullRefreshTime,
+ }
+ : {}),
},
],
})
@@ -1013,7 +1045,10 @@ function ScheduleSection({
schema={schema}
draftFullRefreshDays={draftFullRefreshDays}
setDraftFullRefreshDays={setDraftFullRefreshDays}
- isDraftSaved={draftFullRefreshDays === serverFullRefreshDays}
+ draftFullRefreshTime={draftFullRefreshTime}
+ setDraftFullRefreshTime={setDraftFullRefreshTime}
+ isProjectTime={isProjectTime}
+ isDraftSaved={isFullRefreshDraftSaved}
/>
)}
</div>
@@ -1035,14 +1070,25 @@ function FullRefreshIntervalField({
schema,
draftFullRefreshDays,
setDraftFullRefreshDays,
+ draftFullRefreshTime,
+ setDraftFullRefreshTime,
+ isProjectTime,
isDraftSaved,
}: {
schema: ScheduleSectionSchema
draftFullRefreshDays: number | null
setDraftFullRefreshDays: (value: number | null) => void
+ draftFullRefreshTime: string | null
+ setDraftFullRefreshTime: (value: string | null) => void
+ isProjectTime: boolean
isDraftSaved: boolean
}): JSX.Element {
+ const { currentTeam } = useValues(teamLogic)
const { disabledReason: accessDisabledReason } = useSchemaEditorAccess(schema)
+ const timezone = currentTeam?.timezone || 'UTC'
+ const isTimeSet = draftFullRefreshTime !== null
+ const timeDisabledReason =
+ accessDisabledReason ?? (draftFullRefreshDays === null ? 'Enter the number of days first' : undefined)
return (
<div className="flex flex-col gap-1">
@@ -1065,9 +1111,13 @@ function FullRefreshIntervalField({
min={1}
max={MAX_FULL_REFRESH_INTERVAL_DAYS}
value={draftFullRefreshDays ?? NaN}
- onChange={(value) =>
- setDraftFullRefreshDays(value === undefined || Number.isNaN(value) ? null : value)
- }
+ onChange={(value) => {
+ const days = value === undefined || Number.isNaN(value) ? null : value
+ setDraftFullRefreshDays(days)
+ if (days === null) {
+ setDraftFullRefreshTime(null)
+ }
+ }}
placeholder="Off"
className="w-24"
disabledReason={accessDisabledReason}
@@ -1075,6 +1125,37 @@ function FullRefreshIntervalField({
/>
<span>days</span>
</div>
+ <div className="flex flex-wrap items-center gap-2">
+ <LemonSwitch
+ label="At a set time"
+ checked={isTimeSet}
+ disabledReason={timeDisabledReason}
+ onChange={(checked) => setDraftFullRefreshTime(checked ? '00:00:00' : null)}
+ data-attr="schema-full-refresh-time-toggle"
+ />
+ <LemonInput
+ type="time"
+ className="w-32"
+ disabledReason={timeDisabledReason ?? (!isTimeSet ? 'Turn on "At a set time" first' : undefined)}
+ value={
+ isTimeSet
+ ? utcTimeToDisplayTime(draftFullRefreshTime, isProjectTime, timezone).substring(0, 5)
+ : undefined
+ }
+ onChange={(value) =>
+ setDraftFullRefreshTime(
+ value ? displayTimeToUtcTime(`${value}:00`, isProjectTime, timezone) : null
+ )
+ }
+ data-attr="schema-full-refresh-time"
+ />
+ <span className="text-xs text-muted">{isProjectTime ? timezone : 'UTC'}</span>
+ </div>
+ <span className="text-xs text-muted max-w-md">
+ Set a time to keep refreshes outside working hours. The refresh runs with the first sync near or after
+ that time, which can be hours later for a table that syncs every few hours. The time is saved in UTC, so
+ it does not follow daylight saving changes.
+ </span>
{schema.next_full_refresh_at && isDraftSaved && (
<span className="text-xs text-muted">
Next full refresh:{' '}
@@ -1111,12 +1192,7 @@ function AnchorTimeField({
const isSyncTimeSet = draftSyncTimeOfDay !== null
const utcTime = draftSyncTimeOfDay || '00:00:00'
- const localTime = isProjectTime
- ? dayjs
- .utc(`${dayjs().format('YYYY-MM-DD')}T${utcTime}`)
- .tz(currentTeam?.timezone || 'UTC')
- .format('HH:mm:00')
- : utcTime
+ const localTime = utcTimeToDisplayTime(utcTime, isProjectTime, currentTeam?.timezone || 'UTC')
const disabledReasonForInput = useCallback((): string | undefined => {
if (!schema.should_sync && !isSyncTimeSet) {
@@ -1176,16 +1252,9 @@ function AnchorTimeField({
disabledReason={accessDisabledReason ?? disabledReasonForInput()}
value={isSyncTimeSet ? localTime.substring(0, 5) : undefined}
onChange={(value) => {
- const newValue = `${value}:00`
- // dayjs.tz(str, zone) interprets the wall-clock time in the project
- // timezone; plain dayjs(str) would parse it in the browser's timezone.
- const utcValue = isProjectTime
- ? dayjs
- .tz(`${dayjs().format('YYYY-MM-DD')}T${newValue}`, currentTeam?.timezone || 'UTC')
- .utc()
- .format('HH:mm:00')
- : newValue
- setDraftSyncTimeOfDay(utcValue)
+ setDraftSyncTimeOfDay(
+ displayTimeToUtcTime(`${value}:00`, isProjectTime, currentTeam?.timezone || 'UTC')
+ )
}}
suffix={
isSyncTimeSet && schema.should_sync ? (
diff --git a/products/warehouse_sources/backend/migrations/0170_externaldataschema_full_refresh_time_of_day.py b/products/warehouse_sources/backend/migrations/0170_externaldataschema_full_refresh_time_of_day.py
new file mode 100644
index 000000000000..ece2d87afae3
--- /dev/null
+++ b/products/warehouse_sources/backend/migrations/0170_externaldataschema_full_refresh_time_of_day.py
@@ -0,0 +1,28 @@
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+ dependencies = [
+ ("warehouse_sources", "0169_warehousecolumnstatistics_full_scan_at"),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name="externaldataschema",
+ name="full_refresh_time_of_day",
+ field=models.TimeField(
+ blank=True,
+ help_text="UTC time of day that scheduled full refreshes are due. Null means one interval after the last full resync or save.",
+ null=True,
+ ),
+ ),
+ migrations.AlterField(
+ model_name="externaldataschema",
+ name="next_full_refresh_at",
+ field=models.DateTimeField(
+ blank=True,
+ help_text="When the next scheduled full refresh is due. The first scheduled sync that starts at most an hour before this time re-imports the table. Saving a new interval or time, or any full resync, moves it one interval ahead, onto full_refresh_time_of_day when that is set.",
+ null=True,
+ ),
+ ),
+ ]
diff --git a/products/warehouse_sources/backend/migrations/max_migration.txt b/products/warehouse_sources/backend/migrations/max_migration.txt
index 8df71a3a3814..ba7ac3944777 100644
--- a/products/warehouse_sources/backend/migrations/max_migration.txt
+++ b/products/warehouse_sources/backend/migrations/max_migration.txt
@@ -1 +1 @@
-0169_warehousecolumnstatistics_full_scan_at
+0170_externaldataschema_full_refresh_time_of_day
diff --git a/products/warehouse_sources/backend/models/external_data_schema.py b/products/warehouse_sources/backend/models/external_data_schema.py
index 07642b61db1e..6b1f05587236 100644
--- a/products/warehouse_sources/backend/models/external_data_schema.py
+++ b/products/warehouse_sources/backend/models/external_data_schema.py
@@ -295,7 +295,14 @@ class ExternalDataSchema( # nosemgrep: semgrep.rules.security.prefer-uuid7-djan
null=True,
blank=True,
help_text="When the next scheduled full refresh is due. The first scheduled sync that starts at most an hour "
- "before this time re-imports the table. Saving a new interval, or any full resync, moves it one interval ahead.",
+ "before this time re-imports the table. Saving a new interval or time, or any full resync, moves it one "
+ "interval ahead, onto full_refresh_time_of_day when that is set.",
+ )
+ full_refresh_time_of_day = models.TimeField(
+ null=True,
+ blank=True,
+ help_text="UTC time of day that scheduled full refreshes are due. Null means one interval after the last "
+ "full resync or save.",
)
initial_sync_complete = models.BooleanField(default=False)
description = models.CharField(max_length=1000, null=True, blank=True)
@@ -1082,9 +1089,20 @@ class ExternalDataSchema( # nosemgrep: semgrep.rules.security.prefer-uuid7-djan
if self.full_refresh_interval_days is None:
self.next_full_refresh_at = None
return
- self.next_full_refresh_at = timezone.now() + timedelta(days=self.full_refresh_interval_days)
-
- def scheduled_full_refresh_due(self) -> bool:
+ interval = timedelta(days=self.full_refresh_interval_days)
+ now = timezone.now()
+ if self.full_refresh_time_of_day is None:
+ self.next_full_refresh_at = now + interval
+ return
+ # Count from the chosen time the wipe served, not from when it landed. A refresh can run up to the
+ # slack early or wait for a later sync, and counting from the wipe would move the time every cycle.
+ served = now + SCHEDULED_FULL_REFRESH_MAX_SLACK
+ anchor = datetime.combine(served.date(), self.full_refresh_time_of_day, tzinfo=UTC)
+ if anchor > served:
+ anchor -= timedelta(days=1)
+ self.next_full_refresh_at = anchor + interval
+
+ def scheduled_full_refresh_due(self, now: datetime | None = None) -> bool:
if (
self.full_refresh_interval_days is None
or self.next_full_refresh_at is None
@@ -1096,7 +1114,7 @@ class ExternalDataSchema( # nosemgrep: semgrep.rules.security.prefer-uuid7-djan
slack = SCHEDULED_FULL_REFRESH_MAX_SLACK
if self.sync_frequency_interval is not None:
slack = min(slack, self.sync_frequency_interval / 2)
- return timezone.now() >= self.next_full_refresh_at - slack
+ return (now or timezone.now()) >= self.next_full_refresh_at - slack
def update_sync_type_config_for_reset_pipeline(self, *, clear_initial_sync_complete: bool = True) -> None:
removes = [
diff --git a/products/warehouse_sources/backend/presentation/views/external_data_schema.py b/products/warehouse_sources/backend/presentation/views/external_data_schema.py
index c34287ab92a4..8619f0dfe536 100644
--- a/products/warehouse_sources/backend/presentation/views/external_data_schema.py
+++ b/products/warehouse_sources/backend/presentation/views/external_data_schema.py
@@ -225,6 +225,16 @@ SCHEDULED_FULL_REFRESH_TOO_SHORT_ERROR = (
"Choose a longer interval, or sync more often."
)
+FULL_REFRESH_TIME_OF_DAY_HELP_TEXT = (
+ "UTC time of day (HH:MM:SS) that scheduled full refreshes are due, for example outside working hours. "
+ "The refresh runs on the first scheduled sync from up to an hour before this time, so on a table that "
+ "syncs every few hours it can run hours later. Each interval counts from the slot of this time that the last "
+ "refresh or save served, where a slot less than an hour away counts as served. Saving a new time restarts "
+ "the clock, so the first refresh after a save can come up to a day before a full interval has passed. "
+ "Null counts the interval from when it was saved or from the last full resync. Cleared when "
+ "full_refresh_interval_days is null."
+)
+
def _trigger_schema_sync(instance: ExternalDataSchema) -> None:
"""Trigger the schema's sync, creating its Temporal schedule first if it has none.
@@ -429,12 +439,16 @@ class ExternalDataSchemaSerializer(UserAccessControlSerializerMixin, serializers
"Days between scheduled full refreshes, from 1 to 90, or null for none. A full refresh wipes the "
"table and re-imports every row, so rows deleted at the source are removed. It runs on the first "
"scheduled sync once the interval has passed, counted from when it was saved or from the last full "
- "resync, and can start up to an hour early. Queries keep returning the current rows until a full "
+ "resync (or, when full_refresh_time_of_day is set, from the slot of that time the last refresh served), "
+ "and can start up to an hour early. Queries keep returning the current rows until a full "
"refresh finishes, and workflows and destinations that run on new rows of the table run again for "
"every row. Available "
"for incremental, append, and xmin syncs only, and never shorter than the sync frequency."
),
)
+ full_refresh_time_of_day = serializers.TimeField(
+ required=False, allow_null=True, help_text=FULL_REFRESH_TIME_OF_DAY_HELP_TEXT
+ )
primary_key_columns = serializers.ListField(
child=serializers.CharField(),
required=False,
@@ -543,6 +557,7 @@ class ExternalDataSchemaSerializer(UserAccessControlSerializerMixin, serializers
"sync_frequency",
"sync_time_of_day",
"full_refresh_interval_days",
+ "full_refresh_time_of_day",
"next_full_refresh_at",
"description",
"primary_key_columns",
@@ -1186,10 +1201,11 @@ class ExternalDataSchemaSerializer(UserAccessControlSerializerMixin, serializers
validated_data["sync_time_of_day"] = None
instance.sync_time_of_day = None
- # The schedule settings resend the interval on every save, so only a changed value restarts the clock.
+ # The schedule settings resend the interval and time on every save, so only a changed value restarts the clock.
full_refresh_interval_days = validated_data.get(
"full_refresh_interval_days", instance.full_refresh_interval_days
)
+ full_refresh_time_of_day = validated_data.get("full_refresh_time_of_day", instance.full_refresh_time_of_day)
if full_refresh_interval_days is not None and resulting_sync_type not in SCHEDULED_FULL_REFRESH_SYNC_TYPES:
requested_days = validated_data.get("full_refresh_interval_days")
if requested_days is not None and requested_days != instance.full_refresh_interval_days:
@@ -1208,10 +1224,20 @@ class ExternalDataSchemaSerializer(UserAccessControlSerializerMixin, serializers
)
}
)
- if full_refresh_interval_days != instance.full_refresh_interval_days:
+ # A time kept without an interval would apply silently to the next interval a caller sets.
+ if full_refresh_interval_days is None:
+ full_refresh_time_of_day = None
+ if "full_refresh_time_of_day" in validated_data:
+ validated_data["full_refresh_time_of_day"] = None
+ if (
+ full_refresh_interval_days != instance.full_refresh_interval_days
+ or full_refresh_time_of_day != instance.full_refresh_time_of_day
+ ):
instance.full_refresh_interval_days = full_refresh_interval_days
+ instance.full_refresh_time_of_day = full_refresh_time_of_day
instance.restart_full_refresh_clock()
validated_data["full_refresh_interval_days"] = full_refresh_interval_days
+ validated_data["full_refresh_time_of_day"] = full_refresh_time_of_day
validated_data["next_full_refresh_at"] = instance.next_full_refresh_at
# A row can still carry a null interval from before that rejection. Turning the sync on, or
diff --git a/products/warehouse_sources/backend/presentation/views/external_data_source/schema_operations.py b/products/warehouse_sources/backend/presentation/views/external_data_source/schema_operations.py
index 9818fe1a71e8..9acfec288316 100644
--- a/products/warehouse_sources/backend/presentation/views/external_data_source/schema_operations.py
+++ b/products/warehouse_sources/backend/presentation/views/external_data_source/schema_operations.py
@@ -39,6 +39,7 @@ from products.warehouse_sources.backend.facade.source_management import (
)
from products.warehouse_sources.backend.facade.types import ExternalDataSourceType
from products.warehouse_sources.backend.presentation.views.external_data_schema import (
+ FULL_REFRESH_TIME_OF_DAY_HELP_TEXT,
ExternalDataSchemaSerializer,
RowFiltersField,
)
@@ -98,6 +99,9 @@ class ExternalDataSourceBulkUpdateSchemaSerializer(serializers.Serializer):
"and never shorter than the sync frequency."
),
)
+ full_refresh_time_of_day = serializers.TimeField(
+ required=False, allow_null=True, help_text=FULL_REFRESH_TIME_OF_DAY_HELP_TEXT
+ )
primary_key_columns = serializers.ListField(
child=serializers.CharField(),
required=False,
diff --git a/products/warehouse_sources/backend/temporal/data_imports/workflow_activities/import_data_sync.py b/products/warehouse_sources/backend/temporal/data_imports/workflow_activities/import_data_sync.py
index 15723d7257b4..956ebd9cc836 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/workflow_activities/import_data_sync.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/workflow_activities/import_data_sync.py
@@ -135,14 +135,17 @@ class ImportDataActivityInputs:
}
-def _resolve_reset_pipeline(inputs: ImportDataActivityInputs, schema: ExternalDataSchema) -> bool:
+def _resolve_reset_pipeline(
+ inputs: ImportDataActivityInputs, schema: ExternalDataSchema, *, job_created_at: dt.datetime
+) -> bool:
if inputs.reset_pipeline is not None:
return inputs.reset_pipeline
if schema.sync_type_config.get("reset_pipeline", False) is True:
return True
- # Each attempt loads the schema again, and the first wipe moves the due time a full interval ahead, so a
- # retry after the wipe carries on with the re-import instead of wiping it again.
- return inputs.scheduled_full_refresh and schema.scheduled_full_refresh_due()
+ # Each attempt loads the schema again. Checked at the job's creation, it stays due until the wipe moves the due
+ # time past that point, so a retry after the wipe carries on instead of wiping again. The current time is not
+ # safe: with a 1-day interval and a set time, a wipe more than an hour early leaves that day's slot due.
+ return inputs.scheduled_full_refresh and schema.scheduled_full_refresh_due(now=job_created_at)
@database_sync_to_async_pool
@@ -447,7 +450,7 @@ async def _import_data_with_reporting(inputs: ImportDataActivityInputs, logger:
except ExternalDataSchema.DoesNotExist as e:
await _handle_import_error(job_inputs, logger, e)
- reset_pipeline = _resolve_reset_pipeline(inputs, schema)
+ reset_pipeline = _resolve_reset_pipeline(inputs, schema, job_created_at=model.created_at)
await logger.adebug(f"schema.sync_type_config = {schema.sync_type_config}")
await logger.adebug(f"reset_pipeline = {reset_pipeline}")
diff --git a/products/warehouse_sources/backend/temporal/data_imports/workflow_activities/tests/test_import_data_sync.py b/products/warehouse_sources/backend/temporal/data_imports/workflow_activities/tests/test_import_data_sync.py
index eae2cc3a51d9..69070f6c3e52 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/workflow_activities/tests/test_import_data_sync.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/workflow_activities/tests/test_import_data_sync.py
@@ -5,6 +5,7 @@ from datetime import UTC, datetime, timedelta
from typing import Any, cast
import pytest
+import time_machine
from posthog.test.base import BaseTest
from unittest import mock
@@ -1485,21 +1486,29 @@ def test_a_staged_repartition_swap_holds_the_import_whatever_the_rollout_flag_sa
@pytest.mark.parametrize(
- "scheduled_full_refresh,due_in_days,expected",
+ "scheduled_full_refresh,next_full_refresh_at,expected",
[
- pytest.param(True, -1, True, id="first_attempt_of_a_due_refresh"),
- pytest.param(True, 7, False, id="retry_after_the_wipe_moved_the_due_time"),
- pytest.param(False, -1, False, id="run_not_marked_as_a_refresh"),
+ pytest.param(True, datetime(2026, 9, 22, 1, 0, tzinfo=UTC), True, id="first_attempt_of_a_due_refresh"),
+ pytest.param(
+ True, datetime(2026, 9, 29, 1, 31, tzinfo=UTC), False, id="retry_after_the_wipe_moved_the_due_time"
+ ),
+ # A 1-day interval at 03:00: the 01:31 wipe moved the due time to 03:00 the same day, which is within the
+ # slack of a retry at 02:11.
+ pytest.param(
+ True, datetime(2026, 9, 22, 3, 0, tzinfo=UTC), False, id="retry_after_a_wipe_before_the_chosen_time"
+ ),
+ pytest.param(False, datetime(2026, 9, 22, 1, 0, tzinfo=UTC), False, id="run_not_marked_as_a_refresh"),
],
)
def test_a_scheduled_full_refresh_resets_only_while_the_schema_is_due(
- scheduled_full_refresh: bool, due_in_days: int, expected: bool
+ scheduled_full_refresh: bool, next_full_refresh_at: datetime, expected: bool
) -> None:
schema = ExternalDataSchema(
sync_type=ExternalDataSchema.SyncType.INCREMENTAL,
sync_type_config={},
- full_refresh_interval_days=7,
- next_full_refresh_at=datetime.now(UTC) + timedelta(days=due_in_days),
+ sync_frequency_interval=timedelta(days=1),
+ full_refresh_interval_days=1,
+ next_full_refresh_at=next_full_refresh_at,
)
inputs = ImportDataActivityInputs(
team_id=1,
@@ -1509,4 +1518,7 @@ def test_a_scheduled_full_refresh_resets_only_while_the_schema_is_due(
scheduled_full_refresh=scheduled_full_refresh,
)
- assert _resolve_reset_pipeline(inputs, schema) is expected
+ with time_machine.travel(datetime(2026, 9, 22, 2, 11, tzinfo=UTC), tick=False):
+ assert (
+ _resolve_reset_pipeline(inputs, schema, job_created_at=datetime(2026, 9, 22, 1, 30, tzinfo=UTC)) is expected
+ )
diff --git a/products/warehouse_sources/backend/tests/api/test_external_data_schema.py b/products/warehouse_sources/backend/tests/api/test_external_data_schema.py
index 767314fc09ec..a0378caaa705 100644
--- a/products/warehouse_sources/backend/tests/api/test_external_data_schema.py
+++ b/products/warehouse_sources/backend/tests/api/test_external_data_schema.py
@@ -1,6 +1,6 @@
import uuid
import contextlib
-from datetime import UTC, datetime, timedelta
+from datetime import UTC, datetime, time, timedelta
from typing import Any
import pytest
@@ -1732,6 +1732,44 @@ class TestExternalDataSchema(APIBaseTest):
400,
(3, datetime(2026, 9, 26, tzinfo=UTC)),
),
+ (
+ "setting_a_time_moves_the_next_refresh_to_it",
+ ExternalDataSchema.SyncType.INCREMENTAL,
+ 7,
+ {"full_refresh_interval_days": 7, "full_refresh_time_of_day": "03:00:00"},
+ 200,
+ (7, datetime(2026, 10, 1, 3, tzinfo=UTC)),
+ None,
+ time(3, 0),
+ ),
+ (
+ "resaving_the_same_time_keeps_the_clock",
+ ExternalDataSchema.SyncType.INCREMENTAL,
+ 7,
+ {"full_refresh_interval_days": 7, "full_refresh_time_of_day": "03:00:00"},
+ 200,
+ (7, datetime(2026, 9, 26, tzinfo=UTC)),
+ time(3, 0),
+ time(3, 0),
+ ),
+ (
+ "a_time_without_an_interval_is_not_stored",
+ ExternalDataSchema.SyncType.INCREMENTAL,
+ None,
+ {"full_refresh_time_of_day": "03:00:00"},
+ 200,
+ (None, None),
+ ),
+ (
+ "clearing_the_interval_clears_the_time",
+ ExternalDataSchema.SyncType.INCREMENTAL,
+ 7,
+ {"full_refresh_interval_days": None, "full_refresh_time_of_day": "03:00:00"},
+ 200,
+ (None, None),
+ time(3, 0),
+ None,
+ ),
]
)
def test_full_refresh_interval_schedules_the_next_full_refresh(
@@ -1742,6 +1780,8 @@ class TestExternalDataSchema(APIBaseTest):
payload: dict[str, Any],
expected_status: int,
expected: tuple[int | None, datetime | None],
+ initial_time: time | None = None,
+ expected_time: time | None = None,
) -> None:
source = ExternalDataSource.objects.create(
team=self.team,
@@ -1756,6 +1796,7 @@ class TestExternalDataSchema(APIBaseTest):
sync_type=sync_type,
sync_type_config={"incremental_field": "updated_at", "incremental_field_type": "timestamp"},
full_refresh_interval_days=initial_days,
+ full_refresh_time_of_day=initial_time,
next_full_refresh_at=datetime(2026, 9, 26, tzinfo=UTC) if initial_days else None,
)
@@ -1773,6 +1814,7 @@ class TestExternalDataSchema(APIBaseTest):
assert response.status_code == expected_status, response.content
schema.refresh_from_db()
assert (schema.full_refresh_interval_days, schema.next_full_refresh_at) == expected
+ assert schema.full_refresh_time_of_day == expected_time
def test_update_schema_enable_should_sync_rejects_cdc_without_primary_key(self):
# Schemas already in CDC mode with an empty primary_key_columns (created before the
diff --git a/products/warehouse_sources/backend/tests/api/test_external_data_source.py b/products/warehouse_sources/backend/tests/api/test_external_data_source.py
index 12aee82db667..9d6e525de67e 100644
--- a/products/warehouse_sources/backend/tests/api/test_external_data_source.py
+++ b/products/warehouse_sources/backend/tests/api/test_external_data_source.py
@@ -1278,7 +1278,11 @@ class TestExternalDataSource(APIBaseTest):
response = self.client.patch(
f"/api/environments/{self.team.pk}/external_data_sources/{source.id}/bulk_update_schemas",
- data={"schemas": [{"id": str(schema.id), "full_refresh_interval_days": 7}]},
+ data={
+ "schemas": [
+ {"id": str(schema.id), "full_refresh_interval_days": 7, "full_refresh_time_of_day": "03:00:00"}
+ ]
+ },
format="json",
)
@@ -1286,7 +1290,9 @@ class TestExternalDataSource(APIBaseTest):
assert response.json()[0]["full_refresh_interval_days"] == 7
schema.refresh_from_db()
assert schema.full_refresh_interval_days == 7
+ assert str(schema.full_refresh_time_of_day) == "03:00:00"
assert schema.next_full_refresh_at is not None
+ assert schema.next_full_refresh_at.strftime("%H:%M:%S") == "03:00:00"
@patch(
"products.warehouse_sources.backend.presentation.views.external_data_schema.external_data_workflow_exists",
@@ -3176,6 +3182,7 @@ class TestExternalDataSource(APIBaseTest):
"sync_frequency": sync_frequency_interval_to_sync_frequency(schema.sync_frequency_interval),
"sync_time_of_day": schema.sync_time_of_day,
"full_refresh_interval_days": None,
+ "full_refresh_time_of_day": None,
"next_full_refresh_at": None,
"description": schema.description,
"primary_key_columns": None,
diff --git a/products/warehouse_sources/backend/tests/test_models.py b/products/warehouse_sources/backend/tests/test_models.py
index fa490e9f1efe..cff86f45e690 100644
--- a/products/warehouse_sources/backend/tests/test_models.py
+++ b/products/warehouse_sources/backend/tests/test_models.py
@@ -1,7 +1,7 @@
import uuid
from collections.abc import Iterator
from contextlib import contextmanager
-from datetime import UTC, date, datetime, timedelta
+from datetime import UTC, date, datetime, time, timedelta
from typing import Any
import pytest
@@ -1100,6 +1100,22 @@ class TestScheduledFullRefreshDue:
assert schema.scheduled_full_refresh_due() is False
+class TestRestartFullRefreshClock:
+ @parameterized.expand(
+ [
+ ("wipe_just_after_the_time", datetime(2026, 9, 22, 3, 4), datetime(2026, 9, 29, 3, 0)),
+ ("wipe_on_a_sync_up_to_an_hour_early", datetime(2026, 9, 22, 2, 10), datetime(2026, 9, 29, 3, 0)),
+ ("wipe_on_a_later_daily_sync", datetime(2026, 9, 22, 5, 0), datetime(2026, 9, 29, 3, 0)),
+ ("saved_hours_before_the_time", datetime(2026, 9, 22, 1, 0), datetime(2026, 9, 28, 3, 0)),
+ ]
+ )
+ def test_the_next_refresh_keeps_the_chosen_time(self, _name: str, now: datetime, expected: datetime) -> None:
+ schema = ExternalDataSchema(full_refresh_interval_days=7, full_refresh_time_of_day=time(3, 0))
+ with time_machine.travel(now.replace(tzinfo=UTC), tick=False):
+ schema.restart_full_refresh_clock()
+ assert schema.next_full_refresh_at == expected.replace(tzinfo=UTC)
+
+
def test_set_partitioning_enabled_consumes_partition_mode_override() -> None:
schema = ExternalDataSchema(
sync_type_config={"partition_mode_override": "datetime", "partitioning_keys_override": ["action_date"]}
diff --git a/products/warehouse_sources/frontend/generated/api.schemas.ts b/products/warehouse_sources/frontend/generated/api.schemas.ts
index c3483c8b5b83..ed4dc2df7e22 100644
--- a/products/warehouse_sources/frontend/generated/api.schemas.ts
+++ b/products/warehouse_sources/frontend/generated/api.schemas.ts
@@ -340,14 +340,19 @@ export interface ExternalDataSchemaApi {
*/
sync_time_of_day?: string | null
/**
- * Days between scheduled full refreshes, from 1 to 90, or null for none. A full refresh wipes the table and re-imports every row, so rows deleted at the source are removed. It runs on the first scheduled sync once the interval has passed, counted from when it was saved or from the last full resync, and can start up to an hour early. Queries keep returning the current rows until a full refresh finishes, and workflows and destinations that run on new rows of the table run again for every row. Available for incremental, append, and xmin syncs only, and never shorter than the sync frequency.
+ * Days between scheduled full refreshes, from 1 to 90, or null for none. A full refresh wipes the table and re-imports every row, so rows deleted at the source are removed. It runs on the first scheduled sync once the interval has passed, counted from when it was saved or from the last full resync (or, when full_refresh_time_of_day is set, from the slot of that time the last refresh served), and can start up to an hour early. Queries keep returning the current rows until a full refresh finishes, and workflows and destinations that run on new rows of the table run again for every row. Available for incremental, append, and xmin syncs only, and never shorter than the sync frequency.
* @minimum 1
* @maximum 90
* @nullable
*/
full_refresh_interval_days?: number | null
/**
- * When the next scheduled full refresh is due. The first scheduled sync that starts at most an hour before this time re-imports the table. Saving a new interval, or any full resync, moves it one interval ahead.
+ * UTC time of day (HH:MM:SS) that scheduled full refreshes are due, for example outside working hours. The refresh runs on the first scheduled sync from up to an hour before this time, so on a table that syncs every few hours it can run hours later. Each interval counts from the slot of this time that the last refresh or save served, where a slot less than an hour away counts as served. Saving a new time restarts the clock, so the first refresh after a save can come up to a day before a full interval has passed. Null counts the interval from when it was saved or from the last full resync. Cleared when full_refresh_interval_days is null.
+ * @nullable
+ */
+ full_refresh_time_of_day?: string | null
+ /**
+ * When the next scheduled full refresh is due. The first scheduled sync that starts at most an hour before this time re-imports the table. Saving a new interval or time, or any full resync, moves it one interval ahead, onto full_refresh_time_of_day when that is set.
* @nullable
*/
readonly next_full_refresh_at: string | null
@@ -520,14 +525,19 @@ export interface PatchedExternalDataSchemaApi {
*/
sync_time_of_day?: string | null
/**
- * Days between scheduled full refreshes, from 1 to 90, or null for none. A full refresh wipes the table and re-imports every row, so rows deleted at the source are removed. It runs on the first scheduled sync once the interval has passed, counted from when it was saved or from the last full resync, and can start up to an hour early. Queries keep returning the current rows until a full refresh finishes, and workflows and destinations that run on new rows of the table run again for every row. Available for incremental, append, and xmin syncs only, and never shorter than the sync frequency.
+ * Days between scheduled full refreshes, from 1 to 90, or null for none. A full refresh wipes the table and re-imports every row, so rows deleted at the source are removed. It runs on the first scheduled sync once the interval has passed, counted from when it was saved or from the last full resync (or, when full_refresh_time_of_day is set, from the slot of that time the last refresh served), and can start up to an hour early. Queries keep returning the current rows until a full refresh finishes, and workflows and destinations that run on new rows of the table run again for every row. Available for incremental, append, and xmin syncs only, and never shorter than the sync frequency.
* @minimum 1
* @maximum 90
* @nullable
*/
full_refresh_interval_days?: number | null
/**
- * When the next scheduled full refresh is due. The first scheduled sync that starts at most an hour before this time re-imports the table. Saving a new interval, or any full resync, moves it one interval ahead.
+ * UTC time of day (HH:MM:SS) that scheduled full refreshes are due, for example outside working hours. The refresh runs on the first scheduled sync from up to an hour before this time, so on a table that syncs every few hours it can run hours later. Each interval counts from the slot of this time that the last refresh or save served, where a slot less than an hour away counts as served. Saving a new time restarts the clock, so the first refresh after a save can come up to a day before a full interval has passed. Null counts the interval from when it was saved or from the last full resync. Cleared when full_refresh_interval_days is null.
+ * @nullable
+ */
+ full_refresh_time_of_day?: string | null
+ /**
+ * When the next scheduled full refresh is due. The first scheduled sync that starts at most an hour before this time re-imports the table. Saving a new interval or time, or any full resync, moves it one interval ahead, onto full_refresh_time_of_day when that is set.
* @nullable
*/
readonly next_full_refresh_at?: string | null
@@ -5006,6 +5016,11 @@ export interface ExternalDataSourceBulkUpdateSchemaApi {
* @nullable
*/
full_refresh_interval_days?: number | null
+ /**
+ * UTC time of day (HH:MM:SS) that scheduled full refreshes are due, for example outside working hours. The refresh runs on the first scheduled sync from up to an hour before this time, so on a table that syncs every few hours it can run hours later. Each interval counts from the slot of this time that the last refresh or save served, where a slot less than an hour away counts as served. Saving a new time restarts the clock, so the first refresh after a save can come up to a day before a full interval has passed. Null counts the interval from when it was saved or from the last full resync. Cleared when full_refresh_interval_days is null.
+ * @nullable
+ */
+ full_refresh_time_of_day?: string | null
/**
* Column names for primary key deduplication.
* @nullable
diff --git a/products/warehouse_sources/frontend/generated/api.zod.ts b/products/warehouse_sources/frontend/generated/api.zod.ts
index e505564288ae..14e53aa39cb0 100644
--- a/products/warehouse_sources/frontend/generated/api.zod.ts
+++ b/products/warehouse_sources/frontend/generated/api.zod.ts
@@ -181,7 +181,13 @@ export const ExternalDataSchemasUpdateBody = /* @__PURE__ */ zod
.max(externalDataSchemasUpdateBodyFullRefreshIntervalDaysMax)
.nullish()
.describe(
- 'Days between scheduled full refreshes, from 1 to 90, or null for none. A full refresh wipes the table and re-imports every row, so rows deleted at the source are removed. It runs on the first scheduled sync once the interval has passed, counted from when it was saved or from the last full resync, and can start up to an hour early. Queries keep returning the current rows until a full refresh finishes, and workflows and destinations that run on new rows of the table run again for every row. Available for incremental, append, and xmin syncs only, and never shorter than the sync frequency.'
+ 'Days between scheduled full refreshes, from 1 to 90, or null for none. A full refresh wipes the table and re-imports every row, so rows deleted at the source are removed. It runs on the first scheduled sync once the interval has passed, counted from when it was saved or from the last full resync (or, when full_refresh_time_of_day is set, from the slot of that time the last refresh served), and can start up to an hour early. Queries keep returning the current rows until a full refresh finishes, and workflows and destinations that run on new rows of the table run again for every row. Available for incremental, append, and xmin syncs only, and never shorter than the sync frequency.'
+ ),
+ full_refresh_time_of_day: zod.iso
+ .time({})
+ .nullish()
+ .describe(
+ 'UTC time of day (HH:MM:SS) that scheduled full refreshes are due, for example outside working hours. The refresh runs on the first scheduled sync from up to an hour before this time, so on a table that syncs every few hours it can run hours later. Each interval counts from the slot of this time that the last refresh or save served, where a slot less than an hour away counts as served. Saving a new time restarts the clock, so the first refresh after a save can come up to a day before a full interval has passed. Null counts the interval from when it was saved or from the last full resync. Cleared when full_refresh_interval_days is null.'
),
primary_key_columns: zod.array(zod.string()).nullish().describe('Column names for primary key deduplication.'),
cdc_table_mode: zod
@@ -292,7 +298,13 @@ export const ExternalDataSchemasPartialUpdateBody = /* @__PURE__ */ zod
.max(externalDataSchemasPartialUpdateBodyFullRefreshIntervalDaysMax)
.nullish()
.describe(
- 'Days between scheduled full refreshes, from 1 to 90, or null for none. A full refresh wipes the table and re-imports every row, so rows deleted at the source are removed. It runs on the first scheduled sync once the interval has passed, counted from when it was saved or from the last full resync, and can start up to an hour early. Queries keep returning the current rows until a full refresh finishes, and workflows and destinations that run on new rows of the table run again for every row. Available for incremental, append, and xmin syncs only, and never shorter than the sync frequency.'
+ 'Days between scheduled full refreshes, from 1 to 90, or null for none. A full refresh wipes the table and re-imports every row, so rows deleted at the source are removed. It runs on the first scheduled sync once the interval has passed, counted from when it was saved or from the last full resync (or, when full_refresh_time_of_day is set, from the slot of that time the last refresh served), and can start up to an hour early. Queries keep returning the current rows until a full refresh finishes, and workflows and destinations that run on new rows of the table run again for every row. Available for incremental, append, and xmin syncs only, and never shorter than the sync frequency.'
+ ),
+ full_refresh_time_of_day: zod.iso
+ .time({})
+ .nullish()
+ .describe(
+ 'UTC time of day (HH:MM:SS) that scheduled full refreshes are due, for example outside working hours. The refresh runs on the first scheduled sync from up to an hour before this time, so on a table that syncs every few hours it can run hours later. Each interval counts from the slot of this time that the last refresh or save served, where a slot less than an hour away counts as served. Saving a new time restarts the clock, so the first refresh after a save can come up to a day before a full interval has passed. Null counts the interval from when it was saved or from the last full resync. Cleared when full_refresh_interval_days is null.'
),
primary_key_columns: zod.array(zod.string()).nullish().describe('Column names for primary key deduplication.'),
cdc_table_mode: zod
@@ -412,6 +424,12 @@ export const ExternalDataSourcesBulkUpdateSchemasPartialUpdateBody = /* @__PURE_
.describe(
'Days between scheduled full refreshes, from 1 to 90, or null for none. A full refresh wipes the table and re-imports every row. Re-imported rows count toward usage, and workflows and destinations that run on new rows of the table run again for every row. Incremental, append, and xmin syncs only, and never shorter than the sync frequency.'
),
+ full_refresh_time_of_day: zod.iso
+ .time({})
+ .nullish()
+ .describe(
+ 'UTC time of day (HH:MM:SS) that scheduled full refreshes are due, for example outside working hours. The refresh runs on the first scheduled sync from up to an hour before this time, so on a table that syncs every few hours it can run hours later. Each interval counts from the slot of this time that the last refresh or save served, where a slot less than an hour away counts as served. Saving a new time restarts the clock, so the first refresh after a save can come up to a day before a full interval has passed. Null counts the interval from when it was saved or from the last full resync. Cleared when full_refresh_interval_days is null.'
+ ),
primary_key_columns: zod
.array(zod.string())
.nullish()
diff --git a/products/warehouse_sources/mcp/tools.yaml b/products/warehouse_sources/mcp/tools.yaml
index f951a12722a7..cea862a0417c 100644
--- a/products/warehouse_sources/mcp/tools.yaml
+++ b/products/warehouse_sources/mcp/tools.yaml
@@ -232,18 +232,18 @@ tools:
title: Update data warehouse table schema sync config
description: "Update one table schema's sync configuration: enable/disable syncing (should_sync), sync_type
(incremental, full_refresh, append, webhook, cdc, xmin), sync frequency and UTC time of day, scheduled full
- refresh interval (full_refresh_interval_days), incremental field (plus type and lookback window), primary
- key columns, CDC table mode, column selection (enabled_columns), row filters, and vendor API version.
- Changes take effect on the next sync, not retroactively. Before changing incremental_field or sync_type,
- call 'external-data-schemas-incremental-fields-create' to see which fields and sync methods the source
- actually supports; before switching to cdc, validate with
- 'external-data-sources-check-cdc-prerequisites-create'. To run a sync immediately after reconfiguring, use
- 'external-data-schemas-reload'. This is also how a table reported by `incremental_sync_blocked` is resolved:
- send primary_key_columns, or a different sync_type, or should_sync=true to retry a table fixed at the
- source. For `duplicate_primary_key`, a different key is refused once data has synced, because rows already
- merged under the old key would repeat; delete the synced data first with
- 'external-data-schemas-delete-data', or fix the duplicates at the source and retry. That field reports the
- last run's failure, so it clears once a run succeeds rather than when the update lands."
+ refresh interval and UTC time of day (full_refresh_interval_days, full_refresh_time_of_day), incremental
+ field (plus type and lookback window), primary key columns, CDC table mode, column selection
+ (enabled_columns), row filters, and vendor API version. Changes take effect on the next sync, not
+ retroactively. Before changing incremental_field or sync_type, call
+ 'external-data-schemas-incremental-fields-create' to see which fields and sync methods the source actually
+ supports; before switching to cdc, validate with 'external-data-sources-check-cdc-prerequisites-create'. To
+ run a sync immediately after reconfiguring, use 'external-data-schemas-reload'. This is also how a table
+ reported by `incremental_sync_blocked` is resolved: send primary_key_columns, or a different sync_type, or
+ should_sync=true to retry a table fixed at the source. For `duplicate_primary_key`, a different key is
+ refused once data has synced, because rows already merged under the old key would repeat; delete the synced
+ data first with 'external-data-schemas-delete-data', or fix the duplicates at the source and retry. That
+ field reports the last run's failure, so it clears once a run succeeds rather than when the update lands."
external-data-schemas-reload:
operation: external_data_schemas_reload_create
enabled: true
@@ -303,13 +303,13 @@ tools:
title: Update many table schemas in one request
description: >
Apply sync configuration to several of a source's table schemas at once: enable or disable syncing
- (should_sync), sync_type, sync frequency and UTC time of day, scheduled full refresh interval
- (full_refresh_interval_days), incremental field, and primary key columns. Each entry needs the schema id
- plus the fields to change. Prefer this over looping 'external-data-schemas-partial-update' when
- reconfiguring more than a couple of tables of the same source, such as moving every table that cannot sync
- incrementally onto full_refresh. Every entry is validated before anything is written, and a schema that
- fails is reported by name while the rest of the batch is saved. Changes take effect on the next sync, not
- retroactively.
+ (should_sync), sync_type, sync frequency and UTC time of day, scheduled full refresh interval and UTC time
+ of day (full_refresh_interval_days, full_refresh_time_of_day), incremental field, and primary key columns.
+ Each entry needs the schema id plus the fields to change. Prefer this over looping
+ 'external-data-schemas-partial-update' when reconfiguring more than a couple of tables of the same source,
+ such as moving every table that cannot sync incrementally onto full_refresh. Every entry is validated before
+ anything is written, and a schema that fails is reported by name while the rest of the batch is saved.
+ Changes take effect on the next sync, not retroactively.
external-data-sources-cdc-status-retrieve:
operation: external_data_sources_cdc_status_retrieve
enabled: false
diff --git a/services/mcp/schema/generated-tool-definitions.json b/services/mcp/schema/generated-tool-definitions.json
index 4cf1f5cf808a..892e476b3bf0 100644
--- a/services/mcp/schema/generated-tool-definitions.json
+++ b/services/mcp/schema/generated-tool-definitions.json
@@ -5559,7 +5559,7 @@
}
},
"external-data-schemas-partial-update": {
- "description": "Update one table schema's sync configuration: enable/disable syncing (should_sync), sync_type (incremental, full_refresh, append, webhook, cdc, xmin), sync frequency and UTC time of day, scheduled full refresh interval (full_refresh_interval_days), incremental field (plus type and lookback window), primary key columns, CDC table mode, column selection (enabled_columns), row filters, and vendor API version. Changes take effect on the next sync, not retroactively. Before changing incremental_field or sync_type, call 'external-data-schemas-incremental-fields-create' to see which fields and sync methods the source actually supports; before switching to cdc, validate with 'external-data-sources-check-cdc-prerequisites-create'. To run a sync immediately after reconfiguring, use 'external-data-schemas-reload'. This is also how a table reported by `incremental_sync_blocked` is resolved: send primary_key_columns, or a different sync_type, or should_sync=true to retry a table fixed at the source. For `duplicate_primary_key`, a different key is refused once data has synced, because rows already merged under the old key would repeat; delete the synced data first with 'external-data-schemas-delete-data', or fix the duplicates at the source and retry. That field reports the last run's failure, so it clears once a run succeeds rather than when the update lands.",
+ "description": "Update one table schema's sync configuration: enable/disable syncing (should_sync), sync_type (incremental, full_refresh, append, webhook, cdc, xmin), sync frequency and UTC time of day, scheduled full refresh interval and UTC time of day (full_refresh_interval_days, full_refresh_time_of_day), incremental field (plus type and lookback window), primary key columns, CDC table mode, column selection (enabled_columns), row filters, and vendor API version. Changes take effect on the next sync, not retroactively. Before changing incremental_field or sync_type, call 'external-data-schemas-incremental-fields-create' to see which fields and sync methods the source actually supports; before switching to cdc, validate with 'external-data-sources-check-cdc-prerequisites-create'. To run a sync immediately after reconfiguring, use 'external-data-schemas-reload'. This is also how a table reported by `incremental_sync_blocked` is resolved: send primary_key_columns, or a different sync_type, or should_sync=true to retry a table fixed at the source. For `duplicate_primary_key`, a different key is refused once data has synced, because rows already merged under the old key would repeat; delete the synced data first with 'external-data-schemas-delete-data', or fix the duplicates at the source and retry. That field reports the last run's failure, so it clears once a run succeeds rather than when the update lands.",
"category": "Warehouse sources",
"feature": "warehouse_sources",
"summary": "Update data warehouse table schema sync config",
@@ -5615,7 +5615,7 @@
}
},
"external-data-sources-bulk-update-schemas": {
- "description": "Apply sync configuration to several of a source's table schemas at once: enable or disable syncing (should_sync), sync_type, sync frequency and UTC time of day, scheduled full refresh interval (full_refresh_interval_days), incremental field, and primary key columns. Each entry needs the schema id plus the fields to change. Prefer this over looping 'external-data-schemas-partial-update' when reconfiguring more than a couple of tables of the same source, such as moving every table that cannot sync incrementally onto full_refresh. Every entry is validated before anything is written, and a schema that fails is reported by name while the rest of the batch is saved. Changes take effect on the next sync, not retroactively.",
+ "description": "Apply sync configuration to several of a source's table schemas at once: enable or disable syncing (should_sync), sync_type, sync frequency and UTC time of day, scheduled full refresh interval and UTC time of day (full_refresh_interval_days, full_refresh_time_of_day), incremental field, and primary key columns. Each entry needs the schema id plus the fields to change. Prefer this over looping 'external-data-schemas-partial-update' when reconfiguring more than a couple of tables of the same source, such as moving every table that cannot sync incrementally onto full_refresh. Every entry is validated before anything is written, and a schema that fails is reported by name while the rest of the batch is saved. Changes take effect on the next sync, not retroactively.",
"category": "Warehouse sources",
"feature": "warehouse_sources",
"summary": "Update many table schemas in one request",
diff --git a/services/mcp/schema/tool-definitions-all.json b/services/mcp/schema/tool-definitions-all.json
index 48d8d66c19f6..b69993ea2e6c 100644
--- a/services/mcp/schema/tool-definitions-all.json
+++ b/services/mcp/schema/tool-definitions-all.json
@@ -5658,7 +5658,7 @@
}
},
"external-data-schemas-partial-update": {
- "description": "Update one table schema's sync configuration: enable/disable syncing (should_sync), sync_type (incremental, full_refresh, append, webhook, cdc, xmin), sync frequency and UTC time of day, scheduled full refresh interval (full_refresh_interval_days), incremental field (plus type and lookback window), primary key columns, CDC table mode, column selection (enabled_columns), row filters, and vendor API version. Changes take effect on the next sync, not retroactively. Before changing incremental_field or sync_type, call 'external-data-schemas-incremental-fields-create' to see which fields and sync methods the source actually supports; before switching to cdc, validate with 'external-data-sources-check-cdc-prerequisites-create'. To run a sync immediately after reconfiguring, use 'external-data-schemas-reload'. This is also how a table reported by `incremental_sync_blocked` is resolved: send primary_key_columns, or a different sync_type, or should_sync=true to retry a table fixed at the source. For `duplicate_primary_key`, a different key is refused once data has synced, because rows already merged under the old key would repeat; delete the synced data first with 'external-data-schemas-delete-data', or fix the duplicates at the source and retry. That field reports the last run's failure, so it clears once a run succeeds rather than when the update lands.",
+ "description": "Update one table schema's sync configuration: enable/disable syncing (should_sync), sync_type (incremental, full_refresh, append, webhook, cdc, xmin), sync frequency and UTC time of day, scheduled full refresh interval and UTC time of day (full_refresh_interval_days, full_refresh_time_of_day), incremental field (plus type and lookback window), primary key columns, CDC table mode, column selection (enabled_columns), row filters, and vendor API version. Changes take effect on the next sync, not retroactively. Before changing incremental_field or sync_type, call 'external-data-schemas-incremental-fields-create' to see which fields and sync methods the source actually supports; before switching to cdc, validate with 'external-data-sources-check-cdc-prerequisites-create'. To run a sync immediately after reconfiguring, use 'external-data-schemas-reload'. This is also how a table reported by `incremental_sync_blocked` is resolved: send primary_key_columns, or a different sync_type, or should_sync=true to retry a table fixed at the source. For `duplicate_primary_key`, a different key is refused once data has synced, because rows already merged under the old key would repeat; delete the synced data first with 'external-data-schemas-delete-data', or fix the duplicates at the source and retry. That field reports the last run's failure, so it clears once a run succeeds rather than when the update lands.",
"category": "Warehouse sources",
"feature": "warehouse_sources",
"summary": "Update data warehouse table schema sync config",
@@ -5714,7 +5714,7 @@
}
},
"external-data-sources-bulk-update-schemas": {
- "description": "Apply sync configuration to several of a source's table schemas at once: enable or disable syncing (should_sync), sync_type, sync frequency and UTC time of day, scheduled full refresh interval (full_refresh_interval_days), incremental field, and primary key columns. Each entry needs the schema id plus the fields to change. Prefer this over looping 'external-data-schemas-partial-update' when reconfiguring more than a couple of tables of the same source, such as moving every table that cannot sync incrementally onto full_refresh. Every entry is validated before anything is written, and a schema that fails is reported by name while the rest of the batch is saved. Changes take effect on the next sync, not retroactively.",
+ "description": "Apply sync configuration to several of a source's table schemas at once: enable or disable syncing (should_sync), sync_type, sync frequency and UTC time of day, scheduled full refresh interval and UTC time of day (full_refresh_interval_days, full_refresh_time_of_day), incremental field, and primary key columns. Each entry needs the schema id plus the fields to change. Prefer this over looping 'external-data-schemas-partial-update' when reconfiguring more than a couple of tables of the same source, such as moving every table that cannot sync incrementally onto full_refresh. Every entry is validated before anything is written, and a schema that fails is reported by name while the rest of the batch is saved. Changes take effect on the next sync, not retroactively.",
"category": "Warehouse sources",
"feature": "warehouse_sources",
"summary": "Update many table schemas in one request",
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index 5e8f1f87f106..9523360d118a 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -44764,14 +44764,19 @@ export namespace Schemas {
*/
sync_time_of_day?: string | null;
/**
- * Days between scheduled full refreshes, from 1 to 90, or null for none. A full refresh wipes the table and re-imports every row, so rows deleted at the source are removed. It runs on the first scheduled sync once the interval has passed, counted from when it was saved or from the last full resync, and can start up to an hour early. Queries keep returning the current rows until a full refresh finishes, and workflows and destinations that run on new rows of the table run again for every row. Available for incremental, append, and xmin syncs only, and never shorter than the sync frequency.
+ * Days between scheduled full refreshes, from 1 to 90, or null for none. A full refresh wipes the table and re-imports every row, so rows deleted at the source are removed. It runs on the first scheduled sync once the interval has passed, counted from when it was saved or from the last full resync (or, when full_refresh_time_of_day is set, from the slot of that time the last refresh served), and can start up to an hour early. Queries keep returning the current rows until a full refresh finishes, and workflows and destinations that run on new rows of the table run again for every row. Available for incremental, append, and xmin syncs only, and never shorter than the sync frequency.
* @minimum 1
* @maximum 90
* @nullable
*/
full_refresh_interval_days?: number | null;
/**
- * When the next scheduled full refresh is due. The first scheduled sync that starts at most an hour before this time re-imports the table. Saving a new interval, or any full resync, moves it one interval ahead.
+ * UTC time of day (HH:MM:SS) that scheduled full refreshes are due, for example outside working hours. The refresh runs on the first scheduled sync from up to an hour before this time, so on a table that syncs every few hours it can run hours later. Each interval counts from the slot of this time that the last refresh or save served, where a slot less than an hour away counts as served. Saving a new time restarts the clock, so the first refresh after a save can come up to a day before a full interval has passed. Null counts the interval from when it was saved or from the last full resync. Cleared when full_refresh_interval_days is null.
+ * @nullable
+ */
+ full_refresh_time_of_day?: string | null;
+ /**
+ * When the next scheduled full refresh is due. The first scheduled sync that starts at most an hour before this time re-imports the table. Saving a new interval or time, or any full resync, moves it one interval ahead, onto full_refresh_time_of_day when that is set.
* @nullable
*/
readonly next_full_refresh_at: string | null;
@@ -44888,6 +44893,11 @@ export namespace Schemas {
* @nullable
*/
full_refresh_interval_days?: number | null;
+ /**
+ * UTC time of day (HH:MM:SS) that scheduled full refreshes are due, for example outside working hours. The refresh runs on the first scheduled sync from up to an hour before this time, so on a table that syncs every few hours it can run hours later. Each interval counts from the slot of this time that the last refresh or save served, where a slot less than an hour away counts as served. Saving a new time restarts the clock, so the first refresh after a save can come up to a day before a full interval has passed. Null counts the interval from when it was saved or from the last full resync. Cleared when full_refresh_interval_days is null.
+ * @nullable
+ */
+ full_refresh_time_of_day?: string | null;
/**
* Column names for primary key deduplication.
* @nullable
@@ -76002,14 +76012,19 @@ export namespace Schemas {
*/
sync_time_of_day?: string | null;
/**
- * Days between scheduled full refreshes, from 1 to 90, or null for none. A full refresh wipes the table and re-imports every row, so rows deleted at the source are removed. It runs on the first scheduled sync once the interval has passed, counted from when it was saved or from the last full resync, and can start up to an hour early. Queries keep returning the current rows until a full refresh finishes, and workflows and destinations that run on new rows of the table run again for every row. Available for incremental, append, and xmin syncs only, and never shorter than the sync frequency.
+ * Days between scheduled full refreshes, from 1 to 90, or null for none. A full refresh wipes the table and re-imports every row, so rows deleted at the source are removed. It runs on the first scheduled sync once the interval has passed, counted from when it was saved or from the last full resync (or, when full_refresh_time_of_day is set, from the slot of that time the last refresh served), and can start up to an hour early. Queries keep returning the current rows until a full refresh finishes, and workflows and destinations that run on new rows of the table run again for every row. Available for incremental, append, and xmin syncs only, and never shorter than the sync frequency.
* @minimum 1
* @maximum 90
* @nullable
*/
full_refresh_interval_days?: number | null;
/**
- * When the next scheduled full refresh is due. The first scheduled sync that starts at most an hour before this time re-imports the table. Saving a new interval, or any full resync, moves it one interval ahead.
+ * UTC time of day (HH:MM:SS) that scheduled full refreshes are due, for example outside working hours. The refresh runs on the first scheduled sync from up to an hour before this time, so on a table that syncs every few hours it can run hours later. Each interval counts from the slot of this time that the last refresh or save served, where a slot less than an hour away counts as served. Saving a new time restarts the clock, so the first refresh after a save can come up to a day before a full interval has passed. Null counts the interval from when it was saved or from the last full resync. Cleared when full_refresh_interval_days is null.
+ * @nullable
+ */
+ full_refresh_time_of_day?: string | null;
+ /**
+ * When the next scheduled full refresh is due. The first scheduled sync that starts at most an hour before this time re-imports the table. Saving a new interval or time, or any full resync, moves it one interval ahead, onto full_refresh_time_of_day when that is set.
* @nullable
*/
readonly next_full_refresh_at?: string | null;
diff --git a/services/mcp/src/generated/warehouse_sources/api.ts b/services/mcp/src/generated/warehouse_sources/api.ts
index d43eee20acb8..ab51d1faddfa 100644
--- a/services/mcp/src/generated/warehouse_sources/api.ts
+++ b/services/mcp/src/generated/warehouse_sources/api.ts
@@ -139,7 +139,13 @@ export const ExternalDataSchemasPartialUpdateBody = () => zod
.max(externalDataSchemasPartialUpdateBodyFullRefreshIntervalDaysMax)
.nullish()
.describe(
- 'Days between scheduled full refreshes, from 1 to 90, or null for none. A full refresh wipes the table and re-imports every row, so rows deleted at the source are removed. It runs on the first scheduled sync once the interval has passed, counted from when it was saved or from the last full resync, and can start up to an hour early. Queries keep returning the current rows until a full refresh finishes, and workflows and destinations that run on new rows of the table run again for every row. Available for incremental, append, and xmin syncs only, and never shorter than the sync frequency.'
+ 'Days between scheduled full refreshes, from 1 to 90, or null for none. A full refresh wipes the table and re-imports every row, so rows deleted at the source are removed. It runs on the first scheduled sync once the interval has passed, counted from when it was saved or from the last full resync (or, when full_refresh_time_of_day is set, from the slot of that time the last refresh served), and can start up to an hour early. Queries keep returning the current rows until a full refresh finishes, and workflows and destinations that run on new rows of the table run again for every row. Available for incremental, append, and xmin syncs only, and never shorter than the sync frequency.'
+ ),
+ full_refresh_time_of_day: zod.iso
+ .time({})
+ .nullish()
+ .describe(
+ 'UTC time of day (HH:MM:SS) that scheduled full refreshes are due, for example outside working hours. The refresh runs on the first scheduled sync from up to an hour before this time, so on a table that syncs every few hours it can run hours later. Each interval counts from the slot of this time that the last refresh or save served, where a slot less than an hour away counts as served. Saving a new time restarts the clock, so the first refresh after a save can come up to a day before a full interval has passed. Null counts the interval from when it was saved or from the last full resync. Cleared when full_refresh_interval_days is null.'
),
primary_key_columns: zod.array(zod.string()).nullish().describe('Column names for primary key deduplication.'),
cdc_table_mode: zod
@@ -1825,6 +1831,12 @@ export const ExternalDataSourcesBulkUpdateSchemasPartialUpdateBody = () => zod.o
.describe(
'Days between scheduled full refreshes, from 1 to 90, or null for none. A full refresh wipes the table and re-imports every row. Re-imported rows count toward usage, and workflows and destinations that run on new rows of the table run again for every row. Incremental, append, and xmin syncs only, and never shorter than the sync frequency.'
),
+ full_refresh_time_of_day: zod.iso
+ .time({})
+ .nullish()
+ .describe(
+ 'UTC time of day (HH:MM:SS) that scheduled full refreshes are due, for example outside working hours. The refresh runs on the first scheduled sync from up to an hour before this time, so on a table that syncs every few hours it can run hours later. Each interval counts from the slot of this time that the last refresh or save served, where a slot less than an hour away counts as served. Saving a new time restarts the clock, so the first refresh after a save can come up to a day before a full interval has passed. Null counts the interval from when it was saved or from the last full resync. Cleared when full_refresh_interval_days is null.'
+ ),
primary_key_columns: zod
.array(zod.string())
.nullish()
diff --git a/services/mcp/src/tools/generated/warehouse_sources.ts b/services/mcp/src/tools/generated/warehouse_sources.ts
index 0fa909d07bf5..058c1a0d032d 100644
--- a/services/mcp/src/tools/generated/warehouse_sources.ts
+++ b/services/mcp/src/tools/generated/warehouse_sources.ts
@@ -303,6 +303,9 @@ const externalDataSchemasPartialUpdate = (): ToolBase<
if (params.full_refresh_interval_days !== undefined) {
body['full_refresh_interval_days'] = params.full_refresh_interval_days
}
+ if (params.full_refresh_time_of_day !== undefined) {
+ body['full_refresh_time_of_day'] = params.full_refresh_time_of_day
+ }
if (params.primary_key_columns !== undefined) {
body['primary_key_columns'] = params.primary_key_columns
}
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/external-data-schemas-partial-update.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/external-data-schemas-partial-update.json
index e545c3fb1685..d58ad1c2e9a5 100644
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/external-data-schemas-partial-update.json
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/external-data-schemas-partial-update.json
@@ -51,7 +51,19 @@
"type": "null"
}
],
- "description": "Days between scheduled full refreshes, from 1 to 90, or null for none. A full refresh wipes the table and re-imports every row, so rows deleted at the source are removed. It runs on the first scheduled sync once the interval has passed, counted from when it was saved or from the last full resync, and can start up to an hour early. Queries keep returning the current rows until a full refresh finishes, and workflows and destinations that run on new rows of the table run again for every row. Available for incremental, append, and xmin syncs only, and never shorter than the sync frequency."
+ "description": "Days between scheduled full refreshes, from 1 to 90, or null for none. A full refresh wipes the table and re-imports every row, so rows deleted at the source are removed. It runs on the first scheduled sync once the interval has passed, counted from when it was saved or from the last full resync (or, when full_refresh_time_of_day is set, from the slot of that time the last refresh served), and can start up to an hour early. Queries keep returning the current rows until a full refresh finishes, and workflows and destinations that run on new rows of the table run again for every row. Available for incremental, append, and xmin syncs only, and never shorter than the sync frequency."
+ },
+ "full_refresh_time_of_day": {
+ "anyOf": [
+ {
+ "pattern": "^(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?$",
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "UTC time of day (HH:MM:SS) that scheduled full refreshes are due, for example outside working hours. The refresh runs on the first scheduled sync from up to an hour before this time, so on a table that syncs every few hours it can run hours later. Each interval counts from the slot of this time that the last refresh or save served, where a slot less than an hour away counts as served. Saving a new time restarts the clock, so the first refresh after a save can come up to a day before a full interval has passed. Null counts the interval from when it was saved or from the last full resync. Cleared when full_refresh_interval_days is null."
},
"id": {
"description": "A UUID string identifying this external data schema.",
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/external-data-sources-bulk-update-schemas.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/external-data-sources-bulk-update-schemas.json
index 8baff5e1c528..6840db34bdfc 100644
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/external-data-sources-bulk-update-schemas.json
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/external-data-sources-bulk-update-schemas.json
@@ -53,6 +53,18 @@
],
"description": "Days between scheduled full refreshes, from 1 to 90, or null for none. A full refresh wipes the table and re-imports every row. Re-imported rows count toward usage, and workflows and destinations that run on new rows of the table run again for every row. Incremental, append, and xmin syncs only, and never shorter than the sync frequency."
},
+ "full_refresh_time_of_day": {
+ "anyOf": [
+ {
+ "pattern": "^(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?$",
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "UTC time of day (HH:MM:SS) that scheduled full refreshes are due, for example outside working hours. The refresh runs on the first scheduled sync from up to an hour before this time, so on a table that syncs every few hours it can run hours later. Each interval counts from the slot of this time that the last refresh or save served, where a slot less than an hour away counts as served. Saving a new time restarts the clock, so the first refresh after a save can come up to a day before a full interval has passed. Null counts the interval from when it was saved or from the last full resync. Cleared when full_refresh_interval_days is null."
+ },
"id": {
"description": "Schema identifier to update.",
"type": "string"