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): add lookback window for incremental syncs (#64417)

Daniel RCd22b26a42b4c
diff --git a/frontend/src/types.ts b/frontend/src/types.ts
index 2034717a2399..4e1fd7bcfc02 100644
--- a/frontend/src/types.ts
+++ b/frontend/src/types.ts
@@ -6133,6 +6133,9 @@ export interface ExternalDataSourceSyncSchema {
sync_time_of_day: string | null
incremental_field: string | null
incremental_field_type: string | null
+ /** Seconds subtracted from the incremental watermark at sync time to re-read a rolling overlap
+ * window (catches late/backdated rows). Timestamp/date incremental fields only. */
+ incremental_field_lookback_seconds?: number | null
sync_type: 'full_refresh' | 'incremental' | 'append' | 'webhook' | 'cdc' | null
incremental_fields: IncrementalField[]
incremental_available: boolean
@@ -6181,6 +6184,9 @@ export interface ExternalDataSourceSchema extends SimpleExternalDataSourceSchema
latest_error: string | null
incremental_field: string | null
incremental_field_type: string | null
+ /** Seconds subtracted from the incremental watermark at sync time to re-read a rolling overlap
+ * window (catches late/backdated rows). Timestamp/date incremental fields only. */
+ incremental_field_lookback_seconds?: number | null
sync_frequency: DataWarehouseSyncInterval
description?: string | null
should_sync_default?: boolean
diff --git a/posthog/temporal/data_imports/workflow_activities/import_data_sync.py b/posthog/temporal/data_imports/workflow_activities/import_data_sync.py
index efa8a70a525d..e532f136b60e 100644
--- a/posthog/temporal/data_imports/workflow_activities/import_data_sync.py
+++ b/posthog/temporal/data_imports/workflow_activities/import_data_sync.py
@@ -36,7 +36,11 @@ from posthog.temporal.data_imports.sources.postgres.exceptions import CDCHandled
from products.data_warehouse.backend.types import ExternalDataSourceType
from products.warehouse_sources.backend.models.external_data_job import ExternalDataJob
-from products.warehouse_sources.backend.models.external_data_schema import ExternalDataSchema, process_incremental_value
+from products.warehouse_sources.backend.models.external_data_schema import (
+ ExternalDataSchema,
+ apply_incremental_lookback,
+ process_incremental_value,
+)
from products.warehouse_sources.backend.models.external_data_source import ExternalDataSource
from products.warehouse_sources.backend.models.table import DataWarehouseTable
@@ -140,6 +144,17 @@ async def import_data_activity_sync(inputs: ImportDataActivityInputs) -> Pipelin
schema.incremental_field_type,
)
+ # Shift the watermark back by the user-configured lookback for the source query only
+ # (the stored watermark is untouched), so each incremental run re-reads a rolling
+ # overlap window and catches late or backdated rows. Incremental merge makes the
+ # re-read idempotent — append would duplicate, so it's gated to incremental.
+ if schema.is_incremental:
+ processed_incremental_last_value = apply_incremental_lookback(
+ processed_incremental_last_value,
+ schema.incremental_field_type,
+ schema.incremental_field_lookback_seconds,
+ )
+
if schema.should_use_incremental_field:
await logger.adebug(f"Incremental last value being used is: {processed_incremental_last_value}")
diff --git a/posthog/temporal/data_imports/workflow_activities/tests/test_import_data_sync.py b/posthog/temporal/data_imports/workflow_activities/tests/test_import_data_sync.py
index 5948600f35c2..905d283e6f87 100644
--- a/posthog/temporal/data_imports/workflow_activities/tests/test_import_data_sync.py
+++ b/posthog/temporal/data_imports/workflow_activities/tests/test_import_data_sync.py
@@ -1,5 +1,6 @@
import uuid
import contextlib
+from datetime import datetime
import pytest
from unittest import mock
@@ -12,6 +13,8 @@ from posthog.temporal.data_imports.workflow_activities.import_data_sync import (
import_data_activity_sync,
)
+from products.data_warehouse.backend.types import IncrementalFieldType
+
class _FakeAsyncCM:
async def __aenter__(self):
@@ -107,3 +110,76 @@ async def test_retryable_setup_error_is_reraised():
await import_data_activity_sync(_inputs())
handle_mock.assert_not_awaited()
+
+
+def _incremental_schema(*, is_incremental: bool, lookback_seconds: int | None) -> mock.MagicMock:
+ schema = mock.MagicMock()
+ schema.should_use_incremental_field = True
+ schema.is_incremental = is_incremental
+ schema.incremental_field_type = IncrementalFieldType.Timestamp
+ schema.incremental_field_lookback_seconds = lookback_seconds
+ schema.incremental_field_earliest_value = None
+ schema.row_filters = None
+ schema.sync_type_config = {
+ "incremental_field_last_value": "2026-06-14T15:33:31.802833",
+ "incremental_field_type": "timestamp",
+ }
+ return schema
+
+
+def _patched_activity_reaching_run(source_mock, schema):
+ model = mock.MagicMock()
+ model.pipeline.source_type = "MongoDB"
+ model.pipeline.job_inputs = {}
+ model.folder_path = mock.Mock(return_value="dataset")
+
+ with (
+ mock.patch.object(module, "tag_queries"),
+ mock.patch.object(module, "report_heartbeat_timeout"),
+ mock.patch.object(module, "Heartbeater", return_value=_FakeAsyncCM()),
+ mock.patch.object(module, "ShutdownMonitor", return_value=_FakeAsyncCM()),
+ mock.patch.object(module, "setup_row_tracking", new=mock.AsyncMock()),
+ mock.patch.object(module, "_get_external_data_job", new=mock.AsyncMock(return_value=model)),
+ mock.patch.object(module, "_get_external_data_schema", new=mock.AsyncMock(return_value=schema)),
+ mock.patch.object(module, "ExternalDataSourceType", return_value="MongoDB"),
+ mock.patch.object(module, "bind_job_context"),
+ mock.patch.object(module, "trim_source_job_inputs", new=mock.AsyncMock()),
+ mock.patch.object(module, "database_sync_to_async_pool", new=_passthrough),
+ 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, "_run", new=mock.AsyncMock(return_value=mock.sentinel.run_result)),
+ ):
+ yield
+
+
+def _inputs_no_reset() -> ImportDataActivityInputs:
+ return ImportDataActivityInputs(
+ team_id=1,
+ schema_id=uuid.uuid4(),
+ source_id=uuid.uuid4(),
+ run_id=str(uuid.uuid4()),
+ reset_pipeline=False,
+ )
+
+
+ "is_incremental,expected_last_value",
+ [
+ (True, datetime(2026, 6, 14, 14, 33, 31, 802833)),
+ (False, datetime(2026, 6, 14, 15, 33, 31, 802833)),
+ ],
+)
+async def test_incremental_lookback_shifts_query_value_not_stored_watermark(is_incremental, expected_last_value):
+ source = mock.MagicMock(spec=SimpleSource)
+ source.parse_config.return_value = {}
+ source.source_for_pipeline.return_value = mock.MagicMock()
+ schema = _incremental_schema(is_incremental=is_incremental, lookback_seconds=3600)
+
+ with _patched_activity_reaching_run(source, schema):
+ await import_data_activity_sync(_inputs_no_reset())
+
+ _, source_inputs = source.source_for_pipeline.call_args.args
+ assert source_inputs.db_incremental_field_last_value == expected_last_value
+ assert schema.sync_type_config["incremental_field_last_value"] == "2026-06-14T15:33:31.802833"
diff --git a/products/data_warehouse/backend/api/external_data_schema.py b/products/data_warehouse/backend/api/external_data_schema.py
index 9e4d1576f515..fb0f672e11c6 100644
--- a/products/data_warehouse/backend/api/external_data_schema.py
+++ b/products/data_warehouse/backend/api/external_data_schema.py
@@ -198,6 +198,18 @@ class ExternalDataSchemaSerializer(serializers.ModelSerializer):
allow_null=True,
help_text="Data type of the incremental field.",
)
+ incremental_field_lookback_seconds = serializers.IntegerField(
+ required=False,
+ allow_null=True,
+ min_value=0,
+ max_value=5_184_000, # 60 days — larger windows defeat incremental efficiency
+ help_text=(
+ "Seconds to subtract from the stored incremental watermark at sync time, so each "
+ "incremental run re-reads a rolling overlap window and catches late or backdated rows. "
+ "Applies to timestamp/date incremental fields only. The stored watermark is unchanged. "
+ "Maximum 5184000 (60 days)."
+ ),
+ )
sync_frequency = serializers.ChoiceField(
choices=[
("never", "never"),
@@ -282,6 +294,7 @@ class ExternalDataSchemaSerializer(serializers.ModelSerializer):
"sync_type",
"incremental_field",
"incremental_field_type",
+ "incremental_field_lookback_seconds",
"sync_frequency",
"sync_time_of_day",
"description",
@@ -404,6 +417,7 @@ class ExternalDataSchemaSerializer(serializers.ModelSerializer):
ret["incremental_field_type"] = (
instance.sync_type_config.get("incremental_field_type") if instance.sync_type_config else None
)
+ ret["incremental_field_lookback_seconds"] = instance.incremental_field_lookback_seconds
ret["primary_key_columns"] = instance.primary_key_columns
ret["cdc_table_mode"] = instance.cdc_table_mode
return ret
@@ -443,6 +457,7 @@ class ExternalDataSchemaSerializer(serializers.ModelSerializer):
validated_data.pop("sync_time_of_day", None)
validated_data.pop("incremental_field", None)
validated_data.pop("incremental_field_type", None)
+ validated_data.pop("incremental_field_lookback_seconds", None)
validated_data.pop("primary_key_columns", None)
validated_data.pop("cdc_table_mode", None)
@@ -540,6 +555,11 @@ class ExternalDataSchemaSerializer(serializers.ModelSerializer):
if "incremental_field_type" in data:
payload["incremental_field_type"] = data.get("incremental_field_type")
+ # Lookback only applies to incremental — merge-by-PK makes re-reading the overlap window
+ # idempotent. `null` clears it.
+ if sync_type == ExternalDataSchema.SyncType.INCREMENTAL and "incremental_field_lookback_seconds" in data:
+ payload["incremental_field_lookback_seconds"] = data.get("incremental_field_lookback_seconds")
+
if incremental_field_changed:
if instance.table is not None and isinstance(incremental_field, str):
# Get the max_value and set it on incremental_field_last_value
diff --git a/products/data_warehouse/backend/api/external_data_source.py b/products/data_warehouse/backend/api/external_data_source.py
index 3a9dae3af3f0..30b0e1c04db2 100644
--- a/products/data_warehouse/backend/api/external_data_source.py
+++ b/products/data_warehouse/backend/api/external_data_source.py
@@ -1673,11 +1673,34 @@ class ExternalDataSourceViewSet(TeamAndOrgViewSetMixin, AccessControlViewSetMixi
effective_primary_key_columns = primary_key_columns or (
source_schema.detected_primary_keys if source_schema else None
)
+ # Lookback only applies to incremental (merge-by-PK makes the overlap re-read idempotent).
+ # Mirror the schema-update path's IntegerField(min_value=0, max_value=5_184_000) so both
+ # creation paths reject the same inputs instead of silently dropping null/float values.
+ lookback_seconds = schema.get("incremental_field_lookback_seconds")
+ if lookback_seconds is not None:
+ # Coerce whole-number floats (e.g. 90.0) the way DRF's IntegerField does.
+ if isinstance(lookback_seconds, float) and lookback_seconds.is_integer():
+ lookback_seconds = int(lookback_seconds)
+ # bool is an int subclass — exclude it so true/false aren't treated as 1/0.
+ is_valid_int = isinstance(lookback_seconds, int) and not isinstance(lookback_seconds, bool)
+ if not is_valid_int or not (0 <= lookback_seconds <= 5_184_000):
+ new_source_model.delete()
+ return Response(
+ status=status.HTTP_400_BAD_REQUEST,
+ data={
+ "message": f"incremental_field_lookback_seconds must be an integer between 0 and 5184000 (60 days) for schema '{schema_name}'."
+ },
+ )
sync_type_config = {
"incremental_field": incremental_field,
"incremental_field_type": incremental_field_type,
"schema_metadata": schema_metadata,
**({"primary_key_columns": effective_primary_key_columns} if effective_primary_key_columns else {}),
+ **(
+ {"incremental_field_lookback_seconds": lookback_seconds}
+ if sync_type == "incremental" and lookback_seconds is not None
+ else {}
+ ),
}
elif is_cdc_schema and not cdc_not_set_up:
cdc_table_mode = schema.get("cdc_table_mode", "consolidated")
diff --git a/products/data_warehouse/backend/api/test/test_external_data_schema.py b/products/data_warehouse/backend/api/test/test_external_data_schema.py
index 01b8475f126e..aa07f5a5ba3b 100644
--- a/products/data_warehouse/backend/api/test/test_external_data_schema.py
+++ b/products/data_warehouse/backend/api/test/test_external_data_schema.py
@@ -381,6 +381,208 @@ class TestExternalDataSchema(APIBaseTest):
assert schema.sync_type_config.get("reset_pipeline") is None
assert schema.sync_type == ExternalDataSchema.SyncType.FULL_REFRESH
+ def test_update_schema_sets_and_clears_incremental_field_lookback_seconds(self):
+ source = ExternalDataSource.objects.create(
+ team=self.team,
+ source_type=ExternalDataSourceType.STRIPE,
+ job_inputs={"auth_method": {"selection": "api_key", "stripe_secret_key": "123"}},
+ )
+ schema = ExternalDataSchema.objects.create(
+ name="BalanceTransaction",
+ team=self.team,
+ source=source,
+ should_sync=True,
+ status=ExternalDataSchema.Status.COMPLETED,
+ sync_type=ExternalDataSchema.SyncType.INCREMENTAL,
+ )
+
+ with (
+ mock.patch("products.data_warehouse.backend.api.external_data_schema.trigger_external_data_workflow"),
+ mock.patch(
+ "products.data_warehouse.backend.api.external_data_schema.external_data_workflow_exists",
+ return_value=False,
+ ),
+ ):
+ response = self.client.patch(
+ f"/api/environments/{self.team.pk}/external_data_schemas/{schema.id}",
+ data={
+ "sync_type": "incremental",
+ "incremental_field": "updated_at",
+ "incremental_field_type": "timestamp",
+ "incremental_field_lookback_seconds": 3600,
+ },
+ )
+ assert response.status_code == 200, response.json()
+ assert response.json()["incremental_field_lookback_seconds"] == 3600
+ schema.refresh_from_db()
+ assert schema.sync_type_config["incremental_field_lookback_seconds"] == 3600
+
+ response = self.client.patch(
+ f"/api/environments/{self.team.pk}/external_data_schemas/{schema.id}",
+ data={
+ "sync_type": "incremental",
+ "incremental_field": "updated_at",
+ "incremental_field_type": "timestamp",
+ "incremental_field_lookback_seconds": None,
+ },
+ )
+ assert response.status_code == 200, response.json()
+ assert response.json()["incremental_field_lookback_seconds"] is None
+ schema.refresh_from_db()
+ assert schema.sync_type_config["incremental_field_lookback_seconds"] is None
+
+ def test_incremental_field_lookback_seconds_survives_reset(self):
+ source = ExternalDataSource.objects.create(
+ team=self.team,
+ source_type=ExternalDataSourceType.STRIPE,
+ job_inputs={"auth_method": {"selection": "api_key", "stripe_secret_key": "123"}},
+ )
+ schema = ExternalDataSchema.objects.create(
+ name="BalanceTransaction",
+ team=self.team,
+ source=source,
+ sync_type=ExternalDataSchema.SyncType.INCREMENTAL,
+ sync_type_config={
+ "incremental_field": "updated_at",
+ "incremental_field_type": "timestamp",
+ "incremental_field_last_value": "2026-06-14T15:33:31.802833",
+ "incremental_field_lookback_seconds": 7200,
+ },
+ )
+
+ schema.update_sync_type_config_for_reset_pipeline()
+
+ schema.refresh_from_db()
+ assert "incremental_field_last_value" not in schema.sync_type_config
+ assert schema.sync_type_config["incremental_field_lookback_seconds"] == 7200
+
+ def test_create_source_persists_lookback_for_incremental_omits_for_non_incremental(self):
+ incremental_schema = SourceSchema(
+ name="Orders",
+ supports_incremental=True,
+ supports_append=False,
+ supports_webhooks=False,
+ )
+ full_refresh_schema = SourceSchema(
+ name="Products",
+ supports_incremental=False,
+ supports_append=False,
+ supports_webhooks=False,
+ )
+
+ with (
+ mock.patch.object(StripeSource, "validate_credentials", return_value=(True, None)),
+ mock.patch.object(StripeSource, "get_schemas", return_value=[incremental_schema, full_refresh_schema]),
+ ):
+ response = self.client.post(
+ f"/api/environments/{self.team.pk}/external_data_sources/",
+ data={
+ "source_type": "Stripe",
+ "payload": {
+ "auth_method": {"selection": "api_key", "stripe_secret_key": "sk_test_123"},
+ "schemas": [
+ {
+ "name": "Orders",
+ "should_sync": True,
+ "sync_type": "incremental",
+ "incremental_field": "updated_at",
+ "incremental_field_type": "timestamp",
+ "incremental_field_lookback_seconds": 3600,
+ },
+ {
+ "name": "Products",
+ "should_sync": True,
+ "sync_type": "full_refresh",
+ "incremental_field_lookback_seconds": 3600,
+ },
+ ],
+ },
+ },
+ content_type="application/json",
+ )
+
+ assert response.status_code == 201, response.json()
+
+ incremental = ExternalDataSchema.objects.get(
+ source__team=self.team, name="Orders", sync_type=ExternalDataSchema.SyncType.INCREMENTAL
+ )
+ assert incremental.sync_type_config["incremental_field_lookback_seconds"] == 3600
+
+ full_refresh = ExternalDataSchema.objects.get(
+ source__team=self.team, name="Products", sync_type=ExternalDataSchema.SyncType.FULL_REFRESH
+ )
+ assert "incremental_field_lookback_seconds" not in full_refresh.sync_type_config
+
+ def test_update_schema_rejects_lookback_above_60_days(self):
+ source = ExternalDataSource.objects.create(
+ team=self.team,
+ source_type=ExternalDataSourceType.STRIPE,
+ job_inputs={"auth_method": {"selection": "api_key", "stripe_secret_key": "123"}},
+ )
+ schema = ExternalDataSchema.objects.create(
+ name="BalanceTransaction",
+ team=self.team,
+ source=source,
+ should_sync=True,
+ sync_type=ExternalDataSchema.SyncType.INCREMENTAL,
+ )
+
+ with (
+ mock.patch("products.data_warehouse.backend.api.external_data_schema.trigger_external_data_workflow"),
+ mock.patch(
+ "products.data_warehouse.backend.api.external_data_schema.external_data_workflow_exists",
+ return_value=False,
+ ),
+ ):
+ response = self.client.patch(
+ f"/api/environments/{self.team.pk}/external_data_schemas/{schema.id}",
+ data={
+ "sync_type": "incremental",
+ "incremental_field": "updated_at",
+ "incremental_field_type": "timestamp",
+ "incremental_field_lookback_seconds": 5_184_001, # 60 days + 1 second
+ },
+ )
+
+ assert response.status_code == 400
+
+ def test_create_source_rejects_lookback_above_60_days(self):
+ incremental_schema = SourceSchema(
+ name="Orders",
+ supports_incremental=True,
+ supports_append=False,
+ supports_webhooks=False,
+ )
+
+ with (
+ mock.patch.object(StripeSource, "validate_credentials", return_value=(True, None)),
+ mock.patch.object(StripeSource, "get_schemas", return_value=[incremental_schema]),
+ ):
+ response = self.client.post(
+ f"/api/environments/{self.team.pk}/external_data_sources/",
+ data={
+ "source_type": "Stripe",
+ "payload": {
+ "auth_method": {"selection": "api_key", "stripe_secret_key": "sk_test_123"},
+ "schemas": [
+ {
+ "name": "Orders",
+ "should_sync": True,
+ "sync_type": "incremental",
+ "incremental_field": "updated_at",
+ "incremental_field_type": "timestamp",
+ "incremental_field_lookback_seconds": 5_184_001, # 60 days + 1 second
+ },
+ ],
+ },
+ },
+ content_type="application/json",
+ )
+
+ assert response.status_code == 400
+ assert "5184000" in response.json().get("message", "")
+ assert not ExternalDataSource.objects.filter(team=self.team, source_type="Stripe").exists()
+
@parameterized.expand(
[
# Stored PK from earlier discovery — reuse it; no caller override needed.
diff --git a/products/data_warehouse/backend/api/test/test_external_data_source.py b/products/data_warehouse/backend/api/test/test_external_data_source.py
index ea209ef4719e..6a65a1289c1b 100644
--- a/products/data_warehouse/backend/api/test/test_external_data_source.py
+++ b/products/data_warehouse/backend/api/test/test_external_data_source.py
@@ -1160,6 +1160,82 @@ class TestExternalDataSource(APIBaseTest):
assert response.status_code == 400
assert len(ExternalDataSource.objects.all()) == 0
+ @parameterized.expand(
+ [
+ ("too_large", 5_184_001),
+ ("negative", -1),
+ ("non_integer_string", "soon"),
+ ("non_integer_float", 1.5),
+ ("boolean", True),
+ ]
+ )
+ @patch(
+ "posthog.temporal.data_imports.sources.stripe.source.StripeSource.validate_credentials",
+ return_value=(True, None),
+ )
+ def test_create_external_data_source_incremental_invalid_lookback(
+ self, _name: str, lookback_value: object, _mock_validate: MagicMock
+ ):
+ response = self.client.post(
+ f"/api/environments/{self.team.pk}/external_data_sources/",
+ data={
+ "source_type": "Stripe",
+ "created_via": "web",
+ "payload": {
+ "auth_method": {"selection": "api_key", "stripe_secret_key": "sk_test_123"},
+ "schemas": [
+ {
+ "name": STRIPE_BALANCE_TRANSACTION_RESOURCE_NAME,
+ "should_sync": True,
+ "sync_type": "incremental",
+ "incremental_field": "created",
+ "incremental_field_type": "integer",
+ "incremental_field_lookback_seconds": lookback_value,
+ },
+ ],
+ },
+ },
+ )
+ assert response.status_code == 400
+ assert len(ExternalDataSource.objects.all()) == 0
+
+ @parameterized.expand(
+ [
+ ("max_allowed", 5_184_000),
+ ("zero", 0),
+ ("whole_number_float", 3600.0),
+ ("none", None),
+ ]
+ )
+ @patch(
+ "posthog.temporal.data_imports.sources.stripe.source.StripeSource.validate_credentials",
+ return_value=(True, None),
+ )
+ def test_create_external_data_source_incremental_valid_lookback(
+ self, _name: str, lookback_value: object, _mock_validate: MagicMock
+ ):
+ response = self.client.post(
+ f"/api/environments/{self.team.pk}/external_data_sources/",
+ data={
+ "source_type": "Stripe",
+ "created_via": "web",
+ "payload": {
+ "auth_method": {"selection": "api_key", "stripe_secret_key": "sk_test_123"},
+ "schemas": [
+ {
+ "name": STRIPE_BALANCE_TRANSACTION_RESOURCE_NAME,
+ "should_sync": True,
+ "sync_type": "incremental",
+ "incremental_field": "created",
+ "incremental_field_type": "integer",
+ "incremental_field_lookback_seconds": lookback_value,
+ },
+ ],
+ },
+ },
+ )
+ assert response.status_code == 201
+
def test_create_external_data_source_bigquery_removes_project_id_prefix(self):
"""Test we remove the `project_id` prefix of a `dataset_id`."""
with (
@@ -1586,6 +1662,7 @@ class TestExternalDataSource(APIBaseTest):
"incremental": False,
"incremental_field": None,
"incremental_field_type": None,
+ "incremental_field_lookback_seconds": None,
"last_synced_at": schema.last_synced_at,
"name": schema.name,
"label": schema.label,
diff --git a/products/data_warehouse/frontend/scenes/NewSourceScene/sourceWizardLogic.tsx b/products/data_warehouse/frontend/scenes/NewSourceScene/sourceWizardLogic.tsx
index 95de772dec50..1bab917a0d86 100644
--- a/products/data_warehouse/frontend/scenes/NewSourceScene/sourceWizardLogic.tsx
+++ b/products/data_warehouse/frontend/scenes/NewSourceScene/sourceWizardLogic.tsx
@@ -335,7 +335,8 @@ export const sourceWizardLogic = kea<sourceWizardLogicType>([
incrementalField: string | null,
incrementalFieldType: string | null,
primaryKeyColumns: string[] | null,
- cdcTableMode?: 'consolidated' | 'cdc_only' | 'both'
+ cdcTableMode?: 'consolidated' | 'cdc_only' | 'both',
+ incrementalFieldLookbackSeconds?: number | null
) => ({
schema,
syncType,
@@ -343,6 +344,7 @@ export const sourceWizardLogic = kea<sourceWizardLogicType>([
incrementalFieldType,
primaryKeyColumns,
cdcTableMode,
+ incrementalFieldLookbackSeconds,
}),
clearSource: true,
updateSource: (source: Partial<ExternalDataSourceCreatePayload>) => ({
@@ -485,7 +487,15 @@ export const sourceWizardLogic = kea<sourceWizardLogicType>([
},
updateSchemaSyncType: (
state,
- { schema, syncType, incrementalField, incrementalFieldType, primaryKeyColumns, cdcTableMode }
+ {
+ schema,
+ syncType,
+ incrementalField,
+ incrementalFieldType,
+ primaryKeyColumns,
+ cdcTableMode,
+ incrementalFieldLookbackSeconds,
+ }
) => {
return state.map((s) => ({
...s,
@@ -493,6 +503,10 @@ export const sourceWizardLogic = kea<sourceWizardLogicType>([
incremental_field: s.table === schema.table ? incrementalField : s.incremental_field,
incremental_field_type:
s.table === schema.table ? incrementalFieldType : s.incremental_field_type,
+ incremental_field_lookback_seconds:
+ s.table === schema.table
+ ? (incrementalFieldLookbackSeconds ?? null)
+ : s.incremental_field_lookback_seconds,
primary_key_columns: s.table === schema.table ? primaryKeyColumns : s.primary_key_columns,
...(s.table === schema.table && syncType === 'cdc' && cdcTableMode
? { cdc_table_mode: cdcTableMode }
@@ -595,12 +609,21 @@ export const sourceWizardLogic = kea<sourceWizardLogicType>([
cancelSyncMethodModal: () => null,
updateSchemaSyncType: (
_,
- { schema, syncType, incrementalField, incrementalFieldType, primaryKeyColumns, cdcTableMode }
+ {
+ schema,
+ syncType,
+ incrementalField,
+ incrementalFieldType,
+ primaryKeyColumns,
+ cdcTableMode,
+ incrementalFieldLookbackSeconds,
+ }
) => ({
...schema,
sync_type: syncType,
incremental_field: incrementalField,
incremental_field_type: incrementalFieldType,
+ incremental_field_lookback_seconds: incrementalFieldLookbackSeconds ?? null,
primary_key_columns: primaryKeyColumns,
...(syncType === 'cdc' && cdcTableMode ? { cdc_table_mode: cdcTableMode } : {}),
}),
@@ -1204,6 +1227,8 @@ export const sourceWizardLogic = kea<sourceWizardLogicType>([
sync_type: schema.sync_type,
incremental_field: schema.incremental_field,
incremental_field_type: schema.incremental_field_type,
+ incremental_field_lookback_seconds:
+ schema.incremental_field_lookback_seconds ?? null,
sync_time_of_day: schema.sync_time_of_day,
primary_key_columns: schema.primary_key_columns,
enabled_columns: schema.enabled_columns ?? null,
@@ -1441,6 +1466,7 @@ export const sourceWizardLogic = kea<sourceWizardLogicType>([
sync_type: schema.sync_type,
incremental_field: schema.incremental_field,
incremental_field_type: schema.incremental_field_type,
+ incremental_field_lookback_seconds: schema.incremental_field_lookback_seconds ?? null,
sync_time_of_day: schema.sync_time_of_day ?? null,
primary_key_columns: schema.primary_key_columns,
...(schema.sync_type === 'cdc' && schema.cdc_table_mode
diff --git a/products/data_warehouse/frontend/scenes/SchemaScene/ConfigurationTab.tsx b/products/data_warehouse/frontend/scenes/SchemaScene/ConfigurationTab.tsx
index cb3af439f954..d0880c2cd4d2 100644
--- a/products/data_warehouse/frontend/scenes/SchemaScene/ConfigurationTab.tsx
+++ b/products/data_warehouse/frontend/scenes/SchemaScene/ConfigurationTab.tsx
@@ -355,7 +355,8 @@ function SyncMethodSection({
incrementalField: string | null,
incrementalFieldType: string | null,
primaryKeyColumns: string[] | null,
- cdcTableMode?: 'consolidated' | 'cdc_only' | 'both'
+ cdcTableMode?: 'consolidated' | 'cdc_only' | 'both',
+ incrementalFieldLookbackSeconds?: number | null
): Promise<void> => {
const noIncrementalField = syncType === 'full_refresh' || syncType === 'cdc'
setSaving(true)
@@ -365,6 +366,8 @@ function SyncMethodSection({
sync_type: syncType,
incremental_field: noIncrementalField ? null : incrementalField,
incremental_field_type: noIncrementalField ? null : incrementalFieldType,
+ incremental_field_lookback_seconds:
+ syncType === 'incremental' ? (incrementalFieldLookbackSeconds ?? null) : null,
primary_key_columns: syncType === 'incremental' ? (primaryKeyColumns ?? null) : null,
...(syncType === 'cdc' && cdcTableMode ? { cdc_table_mode: cdcTableMode } : {}),
})
@@ -406,6 +409,7 @@ function SyncMethodSection({
sync_time_of_day: schema.sync_time_of_day ?? null,
incremental_field: schema.incremental_field ?? null,
incremental_field_type: schema.incremental_field_type ?? null,
+ incremental_field_lookback_seconds: schema.incremental_field_lookback_seconds ?? null,
incremental_available: schemaIncrementalFields.incremental_available,
append_available: schemaIncrementalFields.append_available,
cdc_available: schemaIncrementalFields.cdc_available,
diff --git a/products/data_warehouse/frontend/scenes/SourceScene/tabs/sourceSettingsLogic.ts b/products/data_warehouse/frontend/scenes/SourceScene/tabs/sourceSettingsLogic.ts
index 463ef918c9c3..501bf34ec02a 100644
--- a/products/data_warehouse/frontend/scenes/SourceScene/tabs/sourceSettingsLogic.ts
+++ b/products/data_warehouse/frontend/scenes/SourceScene/tabs/sourceSettingsLogic.ts
@@ -131,6 +131,7 @@ function buildSchemaUpdatePayload(
| 'sync_type'
| 'incremental_field'
| 'incremental_field_type'
+ | 'incremental_field_lookback_seconds'
| 'sync_frequency'
| 'sync_time_of_day'
| 'cdc_table_mode'
@@ -142,6 +143,7 @@ function buildSchemaUpdatePayload(
sync_type: schema.sync_type,
incremental_field: schema.incremental_field,
incremental_field_type: schema.incremental_field_type,
+ incremental_field_lookback_seconds: schema.incremental_field_lookback_seconds ?? null,
sync_frequency: schema.sync_frequency,
sync_time_of_day: schema.sync_time_of_day,
cdc_table_mode: schema.cdc_table_mode,
diff --git a/products/data_warehouse/frontend/shared/components/forms/SchemaForm.tsx b/products/data_warehouse/frontend/shared/components/forms/SchemaForm.tsx
index 3c08ebc609e8..60439631b4c2 100644
--- a/products/data_warehouse/frontend/shared/components/forms/SchemaForm.tsx
+++ b/products/data_warehouse/frontend/shared/components/forms/SchemaForm.tsx
@@ -704,14 +704,23 @@ const SyncMethodModal = (): JSX.Element => {
schema={currentSyncMethodModalSchema}
onClose={cancelSyncMethodModal}
isNewSource
- onSave={(syncType, incrementalField, incrementalFieldType, primaryKeyColumns, cdcTableMode) => {
+ onSave={(
+ syncType,
+ incrementalField,
+ incrementalFieldType,
+ primaryKeyColumns,
+ cdcTableMode,
+ incrementalFieldLookbackSeconds
+ ) => {
if (syncType === 'incremental' || syncType === 'append') {
updateSchemaSyncType(
currentSyncMethodModalSchema,
syncType,
incrementalField,
incrementalFieldType,
- primaryKeyColumns
+ primaryKeyColumns,
+ undefined,
+ syncType === 'incremental' ? incrementalFieldLookbackSeconds : null
)
} else if (syncType === 'cdc') {
updateSchemaSyncType(currentSyncMethodModalSchema, syncType, null, null, null, cdcTableMode)
diff --git a/products/data_warehouse/frontend/shared/components/forms/SyncMethodForm.tsx b/products/data_warehouse/frontend/shared/components/forms/SyncMethodForm.tsx
index 26160601a607..6ff5b15d215f 100644
--- a/products/data_warehouse/frontend/shared/components/forms/SyncMethodForm.tsx
+++ b/products/data_warehouse/frontend/shared/components/forms/SyncMethodForm.tsx
@@ -1,6 +1,6 @@
import { forwardRef, useEffect, useImperativeHandle, useState } from 'react'
-import { LemonButton, LemonSelect, LemonTag, lemonToast } from '@posthog/lemon-ui'
+import { LemonButton, LemonInput, LemonSelect, LemonTag, lemonToast } from '@posthog/lemon-ui'
import { LemonBanner } from 'lib/lemon-ui/LemonBanner'
import { LemonInputSelect } from 'lib/lemon-ui/LemonInputSelect'
@@ -8,6 +8,36 @@ import { LemonRadio } from 'lib/lemon-ui/LemonRadio'
import { AvailableColumn, ExternalDataSourceSyncSchema } from '~/types'
+const LOOKBACK_UNIT_SECONDS = {
+ minutes: 60,
+ hours: 3600,
+ days: 86400,
+} as const
+type LookbackUnit = keyof typeof LOOKBACK_UNIT_SECONDS
+
+// Only timestamp/date incremental fields support a lookback window; the watermark for these is a
+// point in time we can safely re-read from. Mirrors IncrementalFieldType on the backend.
+const LOOKBACK_ELIGIBLE_TYPES = new Set(['datetime', 'date', 'timestamp'])
+export const isLookbackEligibleType = (fieldType: string | null | undefined): boolean =>
+ !!fieldType && LOOKBACK_ELIGIBLE_TYPES.has(fieldType)
+
+export const secondsToLookbackParts = (
+ seconds: number | null | undefined
+): { amount: number | null; unit: LookbackUnit } => {
+ if (!seconds || seconds <= 0) {
+ return { amount: null, unit: 'hours' }
+ }
+ // Show the largest unit the value divides into evenly so a 2-day window reads as "2 days", not "48 hours".
+ for (const unit of ['days', 'hours', 'minutes'] as LookbackUnit[]) {
+ if (seconds % LOOKBACK_UNIT_SECONDS[unit] === 0) {
+ return { amount: seconds / LOOKBACK_UNIT_SECONDS[unit], unit }
+ }
+ }
+ // Floor (not round) so a non-divisible value never displays as more than it is and then
+ // saves back the inflated number — e.g. 90 s shows "1 minute" and round-trips to 60 s.
+ return { amount: Math.floor(seconds / 60), unit: 'minutes' }
+}
+
const getIncrementalSyncSupported = (
schema: ExternalDataSourceSyncSchema
): { disabled: true; disabledReason: string } | { disabled: false } => {
@@ -60,7 +90,8 @@ interface SyncMethodFormProps {
incrementalField: string | null,
incrementalFieldType: string | null,
primaryKeyColumns: string[] | null,
- cdcTableMode?: 'consolidated' | 'cdc_only' | 'both'
+ cdcTableMode?: 'consolidated' | 'cdc_only' | 'both',
+ incrementalFieldLookbackSeconds?: number | null
) => void
availableColumns?: AvailableColumn[]
detectedPrimaryKeys?: string[] | null
@@ -175,14 +206,23 @@ export const SyncMethodForm = forwardRef<SyncMethodFormHandle, SyncMethodFormPro
const [cdcTableMode, setCdcTableMode] = useState<'consolidated' | 'cdc_only' | 'both'>(
schema.cdc_table_mode ?? 'consolidated'
)
+ const initialLookback = secondsToLookbackParts(schema.incremental_field_lookback_seconds)
+ const [lookbackAmount, setLookbackAmount] = useState<number | null>(initialLookback.amount)
+ const [lookbackUnit, setLookbackUnit] = useState<LookbackUnit>(initialLookback.unit)
useEffect(() => {
setRadioValue(getInitialRadioState(schema, !incrementalSyncSupported.disabled, !appendSyncSupported.disabled))
setIncrementalFieldValue(defaultField)
setAppendFieldValue(defaultField)
setPrimaryKeyColumns(schema.primary_key_columns ?? (primaryKeyLocked ? [] : (resolvedDetectedPks ?? [])))
+ const resetLookback = secondsToLookbackParts(schema.incremental_field_lookback_seconds)
+ setLookbackAmount(resetLookback.amount)
+ setLookbackUnit(resetLookback.unit)
}, [schema.table]) // oxlint-disable-line react-hooks/exhaustive-deps
+ const lookbackSeconds =
+ lookbackAmount != null && lookbackAmount > 0 ? lookbackAmount * LOOKBACK_UNIT_SECONDS[lookbackUnit] : null
+
const radioOptions: {
value: 'webhook' | 'incremental' | 'append' | 'full_refresh' | 'cdc'
disabledReason?: string
@@ -349,6 +389,48 @@ export const SyncMethodForm = forwardRef<SyncMethodFormHandle, SyncMethodFormPro
different incremental field.
</LemonBanner>
)}
+ {radioValue === 'incremental' &&
+ incrementalFieldValue &&
+ isLookbackEligibleType(
+ schema.incremental_fields.find((n) => n.field === incrementalFieldValue)
+ ?.field_type
+ ) && (
+ <div className="mt-4">
+ <p className="mb-1 font-semibold">Lookback window (optional)</p>
+ <p className="mb-2 text-secondary text-sm">
+ On each sync, re-read rows from this far before the last synced value of{' '}
+ <code>{incrementalFieldValue}</code>. Catches rows that arrive late or
+ with a backdated value. The stored sync position isn't changed.
+ </p>
+ <div className="flex items-center gap-2">
+ <LemonInput
+ type="number"
+ min={0}
+ max={60}
+ value={lookbackAmount ?? undefined}
+ onChange={(newValue) => setLookbackAmount(newValue ?? null)}
+ placeholder="0"
+ className="w-24"
+ />
+ <LemonSelect
+ value={lookbackUnit}
+ onChange={(newValue) => setLookbackUnit(newValue)}
+ options={[
+ { value: 'minutes', label: 'minutes' },
+ { value: 'hours', label: 'hours' },
+ { value: 'days', label: 'days' },
+ ]}
+ />
+ </div>
+ {lookbackSeconds !== null && lookbackSeconds > 604800 && (
+ <LemonBanner type="warning" className="mt-2">
+ Large lookback windows re-read more source data on every sync, which
+ increases warehouse cost and sync duration. Consider a shorter
+ window if your source timestamps are broadly reliable.
+ </LemonBanner>
+ )}
+ </div>
+ )}
{radioValue === 'incremental' && columns.length > 0 && (
<>
<p className="mt-4 mb-2">
@@ -504,6 +586,9 @@ export const SyncMethodForm = forwardRef<SyncMethodFormHandle, SyncMethodFormPro
if (primaryKeyColumns.some((pk, index) => pk !== serverPrimaryKeys[index])) {
return true
}
+ if (lookbackSeconds !== (schema.incremental_field_lookback_seconds ?? null)) {
+ return true
+ }
}
if (radioValue === 'append' && appendFieldValue !== (schema.incremental_field ?? null)) {
return true
@@ -533,7 +618,9 @@ export const SyncMethodForm = forwardRef<SyncMethodFormHandle, SyncMethodFormPro
'incremental',
incrementalFieldValue,
fieldSelected.field_type,
- primaryKeyColumns.length > 0 ? primaryKeyColumns : null
+ primaryKeyColumns.length > 0 ? primaryKeyColumns : null,
+ undefined,
+ isLookbackEligibleType(fieldSelected.field_type) ? lookbackSeconds : null
)
} else if (radioValue === 'append') {
const fieldSelected = schema.incremental_fields.find((n) => n.field === appendFieldValue)
diff --git a/products/data_warehouse/frontend/shared/components/forms/__tests__/SyncMethodForm.test.ts b/products/data_warehouse/frontend/shared/components/forms/__tests__/SyncMethodForm.test.ts
new file mode 100644
index 000000000000..d484c7d26478
--- /dev/null
+++ b/products/data_warehouse/frontend/shared/components/forms/__tests__/SyncMethodForm.test.ts
@@ -0,0 +1,39 @@
+import { isLookbackEligibleType, secondsToLookbackParts } from '../SyncMethodForm'
+
+describe('SyncMethodForm lookback helpers', () => {
+ it.each([
+ ['datetime', true],
+ ['date', true],
+ ['timestamp', true],
+ ['integer', false],
+ ['numeric', false],
+ ['objectid', false],
+ [null, false],
+ [undefined, false],
+ ])('isLookbackEligibleType(%s) === %s', (fieldType, expected) => {
+ expect(isLookbackEligibleType(fieldType as string | null | undefined)).toBe(expected)
+ })
+
+ it.each([
+ [3600, { amount: 1, unit: 'hours' }],
+ [7200, { amount: 2, unit: 'hours' }],
+ [86400, { amount: 1, unit: 'days' }],
+ [172800, { amount: 2, unit: 'days' }],
+ [5184000, { amount: 60, unit: 'days' }], // 60-day max
+ [60, { amount: 1, unit: 'minutes' }],
+ [900, { amount: 15, unit: 'minutes' }],
+ // Non-divisible values floor down to whole minutes (lossy round-trip), never round up.
+ [90, { amount: 1, unit: 'minutes' }],
+ [150, { amount: 2, unit: 'minutes' }],
+ [null, { amount: null, unit: 'hours' }],
+ [0, { amount: null, unit: 'hours' }],
+ [-5, { amount: null, unit: 'hours' }],
+ ])('secondsToLookbackParts(%s) picks the largest exact unit', (seconds, expected) => {
+ expect(secondsToLookbackParts(seconds as number | null)).toEqual(expected)
+ })
+
+ it('LOOKBACK_MAX_SECONDS is 60 days (5184000)', () => {
+ // 60 days × 86400 s/day
+ expect(60 * 86400).toBe(5184000)
+ })
+})
diff --git a/products/warehouse_sources/backend/models/external_data_schema.py b/products/warehouse_sources/backend/models/external_data_schema.py
index 61a42cfd6a2d..2d684be9f3e5 100644
--- a/products/warehouse_sources/backend/models/external_data_schema.py
+++ b/products/warehouse_sources/backend/models/external_data_schema.py
@@ -60,7 +60,7 @@ class ExternalDataSchema(ModelActivityMixin, CreatedMetaFields, UpdatedMetaField
status = models.CharField(max_length=400, null=True, blank=True)
last_synced_at = models.DateTimeField(null=True, blank=True)
sync_type = models.CharField(max_length=128, choices=SyncType, null=True, blank=True)
- # { "incremental_field": string, "incremental_field_type": string, "incremental_field_last_value": any, "incremental_field_earliest_value": any, "reset_pipeline": bool, "partitioning_enabled": bool, "partition_count": int, "partition_size": int, "partition_mode": str, "partitioning_keys": list[str], "chunk_size_override": int | None, "primary_key_columns": list[str] | None, "xmin_last_value": int, "xmin_ceiling": int, "xmin_num_wraparound": int }
+ # { "incremental_field": string, "incremental_field_type": string, "incremental_field_last_value": any, "incremental_field_earliest_value": any, "incremental_field_lookback_seconds": int | None, "reset_pipeline": bool, "partitioning_enabled": bool, "partition_count": int, "partition_size": int, "partition_mode": str, "partitioning_keys": list[str], "chunk_size_override": int | None, "primary_key_columns": list[str] | None, "xmin_last_value": int, "xmin_ceiling": int, "xmin_num_wraparound": int }
sync_type_config = models.JSONField(
default=dict,
blank=True,
@@ -195,6 +195,13 @@ class ExternalDataSchema(ModelActivityMixin, CreatedMetaFields, UpdatedMetaField
return None
+ @property
+ def incremental_field_lookback_seconds(self) -> int | None:
+ if self.sync_type_config:
+ return self.sync_type_config.get("incremental_field_lookback_seconds", None)
+
+ return None
+
@property
def reset_pipeline(self) -> bool:
if self.sync_type_config:
@@ -448,6 +455,25 @@ def process_incremental_value(value: Any | None, field_type: IncrementalFieldTyp
return str(value)
+def apply_incremental_lookback(
+ value: Any, field_type: IncrementalFieldType | None, lookback_seconds: int | None
+) -> Any:
+ """Shift a processed incremental watermark back by `lookback_seconds` for the source query only.
+
+ Used to re-read a rolling overlap window each incremental run so late or backdated rows (whose
+ incremental field lands at or below the stored watermark) are picked up. The persisted watermark
+ is never mutated — this only adjusts the value bound into the source's WHERE clause. Timestamp/date
+ fields only; for `Date` a sub-day lookback rounds down to whole days.
+ """
+ if value is None or not isinstance(lookback_seconds, int) or lookback_seconds <= 0:
+ return value
+
+ if field_type in (IncrementalFieldType.DateTime, IncrementalFieldType.Timestamp, IncrementalFieldType.Date):
+ return value - timedelta(seconds=lookback_seconds)
+
+ return value
+
+
@database_sync_to_async
def asave_external_data_schema(schema: ExternalDataSchema) -> None:
schema.save()
diff --git a/products/warehouse_sources/backend/tests/test_models.py b/products/warehouse_sources/backend/tests/test_models.py
index f5bae41b5d3c..8a45c989bdb9 100644
--- a/products/warehouse_sources/backend/tests/test_models.py
+++ b/products/warehouse_sources/backend/tests/test_models.py
@@ -1,4 +1,5 @@
import uuid
+from datetime import date, datetime
import pytest
from posthog.test.base import BaseTest
@@ -9,7 +10,11 @@ from django.db.models import Model
from products.data_warehouse.backend.types import IncrementalFieldType
from products.warehouse_sources.backend.models.credential import DataWarehouseCredential
from products.warehouse_sources.backend.models.external_data_job import ExternalDataJob
-from products.warehouse_sources.backend.models.external_data_schema import ExternalDataSchema, process_incremental_value
+from products.warehouse_sources.backend.models.external_data_schema import (
+ ExternalDataSchema,
+ apply_incremental_lookback,
+ process_incremental_value,
+)
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.models.util import CLICKHOUSE_HOGQL_MAPPING, clean_type
@@ -159,3 +164,25 @@ def test_reset_pipeline_clears_xmin_state() -> None:
def test_process_incremental_value_xid_returns_value_as_is() -> None:
assert process_incremental_value(4294967396, IncrementalFieldType.XID) == 4294967396
assert process_incremental_value(None, IncrementalFieldType.XID) is None
+
+
+ "value,field_type,lookback_seconds,expected",
+ [
+ (datetime(2026, 6, 14, 15, 33, 31), IncrementalFieldType.Timestamp, 3600, datetime(2026, 6, 14, 14, 33, 31)),
+ (datetime(2026, 6, 14, 15, 33, 31), IncrementalFieldType.DateTime, 86400, datetime(2026, 6, 13, 15, 33, 31)),
+ (date(2026, 6, 14), IncrementalFieldType.Date, 86400, date(2026, 6, 13)),
+ # Date arithmetic ignores the sub-day part of the delta, so a <1-day lookback is a no-op for date fields.
+ (date(2026, 6, 14), IncrementalFieldType.Date, 3600, date(2026, 6, 14)),
+ (datetime(2026, 6, 14, 15, 33, 31), IncrementalFieldType.Timestamp, None, datetime(2026, 6, 14, 15, 33, 31)),
+ (datetime(2026, 6, 14, 15, 33, 31), IncrementalFieldType.Timestamp, 0, datetime(2026, 6, 14, 15, 33, 31)),
+ (datetime(2026, 6, 14, 15, 33, 31), IncrementalFieldType.Timestamp, -5, datetime(2026, 6, 14, 15, 33, 31)),
+ (100, IncrementalFieldType.Integer, 3600, 100),
+ (100, IncrementalFieldType.Numeric, 3600, 100),
+ ("abc123", IncrementalFieldType.ObjectID, 3600, "abc123"),
+ (None, IncrementalFieldType.Timestamp, 3600, None),
+ (datetime(2026, 6, 14, 15, 33, 31), None, 3600, datetime(2026, 6, 14, 15, 33, 31)),
+ ],
+)
+def test_apply_incremental_lookback(value, field_type, lookback_seconds, expected) -> None:
+ assert apply_incremental_lookback(value, field_type, lookback_seconds) == expected
diff --git a/products/warehouse_sources/frontend/generated/api.schemas.ts b/products/warehouse_sources/frontend/generated/api.schemas.ts
index 45582c9654c7..0b5fcbd87c91 100644
--- a/products/warehouse_sources/frontend/generated/api.schemas.ts
+++ b/products/warehouse_sources/frontend/generated/api.schemas.ts
@@ -162,6 +162,13 @@ export interface ExternalDataSchemaApi {
* * `objectid` - objectid
* * `xid` - xid */
incremental_field_type?: IncrementalFieldTypeEnumApi | null
+ /**
+ * Seconds to subtract from the stored incremental watermark at sync time, so each incremental run re-reads a rolling overlap window and catches late or backdated rows. Applies to timestamp/date incremental fields only. The stored watermark is unchanged. Maximum 5184000 (60 days).
+ * @minimum 0
+ * @maximum 5184000
+ * @nullable
+ */
+ incremental_field_lookback_seconds?: number | null
/** How often to sync.
*
* * `never` - never
@@ -295,6 +302,13 @@ export interface PatchedExternalDataSchemaApi {
* * `objectid` - objectid
* * `xid` - xid */
incremental_field_type?: IncrementalFieldTypeEnumApi | null
+ /**
+ * Seconds to subtract from the stored incremental watermark at sync time, so each incremental run re-reads a rolling overlap window and catches late or backdated rows. Applies to timestamp/date incremental fields only. The stored watermark is unchanged. Maximum 5184000 (60 days).
+ * @minimum 0
+ * @maximum 5184000
+ * @nullable
+ */
+ incremental_field_lookback_seconds?: number | null
/** How often to sync.
*
* * `never` - never
diff --git a/products/warehouse_sources/frontend/generated/api.zod.ts b/products/warehouse_sources/frontend/generated/api.zod.ts
index 3041254dfbb1..009e0eb818e3 100644
--- a/products/warehouse_sources/frontend/generated/api.zod.ts
+++ b/products/warehouse_sources/frontend/generated/api.zod.ts
@@ -9,6 +9,9 @@
*/
import * as zod from 'zod'
+export const externalDataSchemasCreateBodyIncrementalFieldLookbackSecondsMin = 0
+export const externalDataSchemasCreateBodyIncrementalFieldLookbackSecondsMax = 5184000
+
export const ExternalDataSchemasCreateBody = /* @__PURE__ */ zod.object({
should_sync: zod.boolean().optional(),
sync_type: zod
@@ -38,6 +41,14 @@ export const ExternalDataSchemasCreateBody = /* @__PURE__ */ zod.object({
.describe(
'Data type of the incremental field.\n\n\* `integer` - integer\n\* `numeric` - numeric\n\* `datetime` - datetime\n\* `date` - date\n\* `timestamp` - timestamp\n\* `objectid` - objectid\n\* `xid` - xid'
),
+ incremental_field_lookback_seconds: zod
+ .number()
+ .min(externalDataSchemasCreateBodyIncrementalFieldLookbackSecondsMin)
+ .max(externalDataSchemasCreateBodyIncrementalFieldLookbackSecondsMax)
+ .nullish()
+ .describe(
+ 'Seconds to subtract from the stored incremental watermark at sync time, so each incremental run re-reads a rolling overlap window and catches late or backdated rows. Applies to timestamp\/date incremental fields only. The stored watermark is unchanged. Maximum 5184000 (60 days).'
+ ),
sync_frequency: zod
.union([
zod
@@ -100,6 +111,9 @@ export const ExternalDataSchemasCreateBody = /* @__PURE__ */ zod.object({
),
})
+export const externalDataSchemasUpdateBodyIncrementalFieldLookbackSecondsMin = 0
+export const externalDataSchemasUpdateBodyIncrementalFieldLookbackSecondsMax = 5184000
+
export const ExternalDataSchemasUpdateBody = /* @__PURE__ */ zod.object({
should_sync: zod.boolean().optional(),
sync_type: zod
@@ -129,6 +143,14 @@ export const ExternalDataSchemasUpdateBody = /* @__PURE__ */ zod.object({
.describe(
'Data type of the incremental field.\n\n\* `integer` - integer\n\* `numeric` - numeric\n\* `datetime` - datetime\n\* `date` - date\n\* `timestamp` - timestamp\n\* `objectid` - objectid\n\* `xid` - xid'
),
+ incremental_field_lookback_seconds: zod
+ .number()
+ .min(externalDataSchemasUpdateBodyIncrementalFieldLookbackSecondsMin)
+ .max(externalDataSchemasUpdateBodyIncrementalFieldLookbackSecondsMax)
+ .nullish()
+ .describe(
+ 'Seconds to subtract from the stored incremental watermark at sync time, so each incremental run re-reads a rolling overlap window and catches late or backdated rows. Applies to timestamp\/date incremental fields only. The stored watermark is unchanged. Maximum 5184000 (60 days).'
+ ),
sync_frequency: zod
.union([
zod
@@ -191,6 +213,9 @@ export const ExternalDataSchemasUpdateBody = /* @__PURE__ */ zod.object({
),
})
+export const externalDataSchemasPartialUpdateBodyIncrementalFieldLookbackSecondsMin = 0
+export const externalDataSchemasPartialUpdateBodyIncrementalFieldLookbackSecondsMax = 5184000
+
export const ExternalDataSchemasPartialUpdateBody = /* @__PURE__ */ zod.object({
should_sync: zod.boolean().optional(),
sync_type: zod
@@ -220,6 +245,14 @@ export const ExternalDataSchemasPartialUpdateBody = /* @__PURE__ */ zod.object({
.describe(
'Data type of the incremental field.\n\n\* `integer` - integer\n\* `numeric` - numeric\n\* `datetime` - datetime\n\* `date` - date\n\* `timestamp` - timestamp\n\* `objectid` - objectid\n\* `xid` - xid'
),
+ incremental_field_lookback_seconds: zod
+ .number()
+ .min(externalDataSchemasPartialUpdateBodyIncrementalFieldLookbackSecondsMin)
+ .max(externalDataSchemasPartialUpdateBodyIncrementalFieldLookbackSecondsMax)
+ .nullish()
+ .describe(
+ 'Seconds to subtract from the stored incremental watermark at sync time, so each incremental run re-reads a rolling overlap window and catches late or backdated rows. Applies to timestamp\/date incremental fields only. The stored watermark is unchanged. Maximum 5184000 (60 days).'
+ ),
sync_frequency: zod
.union([
zod
@@ -282,6 +315,9 @@ export const ExternalDataSchemasPartialUpdateBody = /* @__PURE__ */ zod.object({
),
})
+export const externalDataSchemasCancelCreateBodyIncrementalFieldLookbackSecondsMin = 0
+export const externalDataSchemasCancelCreateBodyIncrementalFieldLookbackSecondsMax = 5184000
+
export const ExternalDataSchemasCancelCreateBody = /* @__PURE__ */ zod.object({
should_sync: zod.boolean().optional(),
sync_type: zod
@@ -311,6 +347,14 @@ export const ExternalDataSchemasCancelCreateBody = /* @__PURE__ */ zod.object({
.describe(
'Data type of the incremental field.\n\n\* `integer` - integer\n\* `numeric` - numeric\n\* `datetime` - datetime\n\* `date` - date\n\* `timestamp` - timestamp\n\* `objectid` - objectid\n\* `xid` - xid'
),
+ incremental_field_lookback_seconds: zod
+ .number()
+ .min(externalDataSchemasCancelCreateBodyIncrementalFieldLookbackSecondsMin)
+ .max(externalDataSchemasCancelCreateBodyIncrementalFieldLookbackSecondsMax)
+ .nullish()
+ .describe(
+ 'Seconds to subtract from the stored incremental watermark at sync time, so each incremental run re-reads a rolling overlap window and catches late or backdated rows. Applies to timestamp\/date incremental fields only. The stored watermark is unchanged. Maximum 5184000 (60 days).'
+ ),
sync_frequency: zod
.union([
zod
@@ -373,6 +417,9 @@ export const ExternalDataSchemasCancelCreateBody = /* @__PURE__ */ zod.object({
),
})
+export const externalDataSchemasIncrementalFieldsCreateBodyIncrementalFieldLookbackSecondsMin = 0
+export const externalDataSchemasIncrementalFieldsCreateBodyIncrementalFieldLookbackSecondsMax = 5184000
+
export const ExternalDataSchemasIncrementalFieldsCreateBody = /* @__PURE__ */ zod.object({
should_sync: zod.boolean().optional(),
sync_type: zod
@@ -402,6 +449,14 @@ export const ExternalDataSchemasIncrementalFieldsCreateBody = /* @__PURE__ */ zo
.describe(
'Data type of the incremental field.\n\n\* `integer` - integer\n\* `numeric` - numeric\n\* `datetime` - datetime\n\* `date` - date\n\* `timestamp` - timestamp\n\* `objectid` - objectid\n\* `xid` - xid'
),
+ incremental_field_lookback_seconds: zod
+ .number()
+ .min(externalDataSchemasIncrementalFieldsCreateBodyIncrementalFieldLookbackSecondsMin)
+ .max(externalDataSchemasIncrementalFieldsCreateBodyIncrementalFieldLookbackSecondsMax)
+ .nullish()
+ .describe(
+ 'Seconds to subtract from the stored incremental watermark at sync time, so each incremental run re-reads a rolling overlap window and catches late or backdated rows. Applies to timestamp\/date incremental fields only. The stored watermark is unchanged. Maximum 5184000 (60 days).'
+ ),
sync_frequency: zod
.union([
zod
@@ -464,6 +519,9 @@ export const ExternalDataSchemasIncrementalFieldsCreateBody = /* @__PURE__ */ zo
),
})
+export const externalDataSchemasReloadCreateBodyIncrementalFieldLookbackSecondsMin = 0
+export const externalDataSchemasReloadCreateBodyIncrementalFieldLookbackSecondsMax = 5184000
+
export const ExternalDataSchemasReloadCreateBody = /* @__PURE__ */ zod.object({
should_sync: zod.boolean().optional(),
sync_type: zod
@@ -493,6 +551,14 @@ export const ExternalDataSchemasReloadCreateBody = /* @__PURE__ */ zod.object({
.describe(
'Data type of the incremental field.\n\n\* `integer` - integer\n\* `numeric` - numeric\n\* `datetime` - datetime\n\* `date` - date\n\* `timestamp` - timestamp\n\* `objectid` - objectid\n\* `xid` - xid'
),
+ incremental_field_lookback_seconds: zod
+ .number()
+ .min(externalDataSchemasReloadCreateBodyIncrementalFieldLookbackSecondsMin)
+ .max(externalDataSchemasReloadCreateBodyIncrementalFieldLookbackSecondsMax)
+ .nullish()
+ .describe(
+ 'Seconds to subtract from the stored incremental watermark at sync time, so each incremental run re-reads a rolling overlap window and catches late or backdated rows. Applies to timestamp\/date incremental fields only. The stored watermark is unchanged. Maximum 5184000 (60 days).'
+ ),
sync_frequency: zod
.union([
zod
@@ -555,6 +621,9 @@ export const ExternalDataSchemasReloadCreateBody = /* @__PURE__ */ zod.object({
),
})
+export const externalDataSchemasResyncCreateBodyIncrementalFieldLookbackSecondsMin = 0
+export const externalDataSchemasResyncCreateBodyIncrementalFieldLookbackSecondsMax = 5184000
+
export const ExternalDataSchemasResyncCreateBody = /* @__PURE__ */ zod.object({
should_sync: zod.boolean().optional(),
sync_type: zod
@@ -584,6 +653,14 @@ export const ExternalDataSchemasResyncCreateBody = /* @__PURE__ */ zod.object({
.describe(
'Data type of the incremental field.\n\n\* `integer` - integer\n\* `numeric` - numeric\n\* `datetime` - datetime\n\* `date` - date\n\* `timestamp` - timestamp\n\* `objectid` - objectid\n\* `xid` - xid'
),
+ incremental_field_lookback_seconds: zod
+ .number()
+ .min(externalDataSchemasResyncCreateBodyIncrementalFieldLookbackSecondsMin)
+ .max(externalDataSchemasResyncCreateBodyIncrementalFieldLookbackSecondsMax)
+ .nullish()
+ .describe(
+ 'Seconds to subtract from the stored incremental watermark at sync time, so each incremental run re-reads a rolling overlap window and catches late or backdated rows. Applies to timestamp\/date incremental fields only. The stored watermark is unchanged. Maximum 5184000 (60 days).'
+ ),
sync_frequency: zod
.union([
zod
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index f2bf5c9a36ff..d9003f2ea7e7 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -21114,6 +21114,13 @@ export namespace Schemas {
* * `objectid` - objectid
* * `xid` - xid */
incremental_field_type?: IncrementalFieldTypeEnum | null;
+ /**
+ * Seconds to subtract from the stored incremental watermark at sync time, so each incremental run re-reads a rolling overlap window and catches late or backdated rows. Applies to timestamp/date incremental fields only. The stored watermark is unchanged. Maximum 5184000 (60 days).
+ * @minimum 0
+ * @maximum 5184000
+ * @nullable
+ */
+ incremental_field_lookback_seconds?: number | null;
/** How often to sync.
*
* * `never` - never
@@ -35442,6 +35449,13 @@ export namespace Schemas {
* * `objectid` - objectid
* * `xid` - xid */
incremental_field_type?: IncrementalFieldTypeEnum | null;
+ /**
+ * Seconds to subtract from the stored incremental watermark at sync time, so each incremental run re-reads a rolling overlap window and catches late or backdated rows. Applies to timestamp/date incremental fields only. The stored watermark is unchanged. Maximum 5184000 (60 days).
+ * @minimum 0
+ * @maximum 5184000
+ * @nullable
+ */
+ incremental_field_lookback_seconds?: number | null;
/** How often to sync.
*
* * `never` - never
diff --git a/services/mcp/src/generated/warehouse_sources/api.ts b/services/mcp/src/generated/warehouse_sources/api.ts
index a6bfc3792a58..0d40e987e01b 100644
--- a/services/mcp/src/generated/warehouse_sources/api.ts
+++ b/services/mcp/src/generated/warehouse_sources/api.ts
@@ -40,6 +40,9 @@ export const ExternalDataSchemasPartialUpdateParams = /* @__PURE__ */ zod.object
),
})
+export const externalDataSchemasPartialUpdateBodyIncrementalFieldLookbackSecondsMin = 0
+export const externalDataSchemasPartialUpdateBodyIncrementalFieldLookbackSecondsMax = 5184000
+
export const ExternalDataSchemasPartialUpdateBody = /* @__PURE__ */ zod.object({
should_sync: zod.boolean().optional(),
sync_type: zod
@@ -69,6 +72,14 @@ export const ExternalDataSchemasPartialUpdateBody = /* @__PURE__ */ zod.object({
.describe(
'Data type of the incremental field.\n\n* `integer` - integer\n* `numeric` - numeric\n* `datetime` - datetime\n* `date` - date\n* `timestamp` - timestamp\n* `objectid` - objectid\n* `xid` - xid'
),
+ incremental_field_lookback_seconds: zod
+ .number()
+ .min(externalDataSchemasPartialUpdateBodyIncrementalFieldLookbackSecondsMin)
+ .max(externalDataSchemasPartialUpdateBodyIncrementalFieldLookbackSecondsMax)
+ .nullish()
+ .describe(
+ 'Seconds to subtract from the stored incremental watermark at sync time, so each incremental run re-reads a rolling overlap window and catches late or backdated rows. Applies to timestamp/date incremental fields only. The stored watermark is unchanged. Maximum 5184000 (60 days).'
+ ),
sync_frequency: zod
.union([
zod
@@ -140,6 +151,9 @@ export const ExternalDataSchemasCancelCreateParams = /* @__PURE__ */ zod.object(
),
})
+export const externalDataSchemasCancelCreateBodyIncrementalFieldLookbackSecondsMin = 0
+export const externalDataSchemasCancelCreateBodyIncrementalFieldLookbackSecondsMax = 5184000
+
export const ExternalDataSchemasCancelCreateBody = /* @__PURE__ */ zod.object({
should_sync: zod.boolean().optional(),
sync_type: zod
@@ -169,6 +183,14 @@ export const ExternalDataSchemasCancelCreateBody = /* @__PURE__ */ zod.object({
.describe(
'Data type of the incremental field.\n\n* `integer` - integer\n* `numeric` - numeric\n* `datetime` - datetime\n* `date` - date\n* `timestamp` - timestamp\n* `objectid` - objectid\n* `xid` - xid'
),
+ incremental_field_lookback_seconds: zod
+ .number()
+ .min(externalDataSchemasCancelCreateBodyIncrementalFieldLookbackSecondsMin)
+ .max(externalDataSchemasCancelCreateBodyIncrementalFieldLookbackSecondsMax)
+ .nullish()
+ .describe(
+ 'Seconds to subtract from the stored incremental watermark at sync time, so each incremental run re-reads a rolling overlap window and catches late or backdated rows. Applies to timestamp/date incremental fields only. The stored watermark is unchanged. Maximum 5184000 (60 days).'
+ ),
sync_frequency: zod
.union([
zod
@@ -249,6 +271,9 @@ export const ExternalDataSchemasIncrementalFieldsCreateParams = /* @__PURE__ */
),
})
+export const externalDataSchemasIncrementalFieldsCreateBodyIncrementalFieldLookbackSecondsMin = 0
+export const externalDataSchemasIncrementalFieldsCreateBodyIncrementalFieldLookbackSecondsMax = 5184000
+
export const ExternalDataSchemasIncrementalFieldsCreateBody = /* @__PURE__ */ zod.object({
should_sync: zod.boolean().optional(),
sync_type: zod
@@ -278,6 +303,14 @@ export const ExternalDataSchemasIncrementalFieldsCreateBody = /* @__PURE__ */ zo
.describe(
'Data type of the incremental field.\n\n* `integer` - integer\n* `numeric` - numeric\n* `datetime` - datetime\n* `date` - date\n* `timestamp` - timestamp\n* `objectid` - objectid\n* `xid` - xid'
),
+ incremental_field_lookback_seconds: zod
+ .number()
+ .min(externalDataSchemasIncrementalFieldsCreateBodyIncrementalFieldLookbackSecondsMin)
+ .max(externalDataSchemasIncrementalFieldsCreateBodyIncrementalFieldLookbackSecondsMax)
+ .nullish()
+ .describe(
+ 'Seconds to subtract from the stored incremental watermark at sync time, so each incremental run re-reads a rolling overlap window and catches late or backdated rows. Applies to timestamp/date incremental fields only. The stored watermark is unchanged. Maximum 5184000 (60 days).'
+ ),
sync_frequency: zod
.union([
zod
@@ -349,6 +382,9 @@ export const ExternalDataSchemasReloadCreateParams = /* @__PURE__ */ zod.object(
),
})
+export const externalDataSchemasReloadCreateBodyIncrementalFieldLookbackSecondsMin = 0
+export const externalDataSchemasReloadCreateBodyIncrementalFieldLookbackSecondsMax = 5184000
+
export const ExternalDataSchemasReloadCreateBody = /* @__PURE__ */ zod.object({
should_sync: zod.boolean().optional(),
sync_type: zod
@@ -378,6 +414,14 @@ export const ExternalDataSchemasReloadCreateBody = /* @__PURE__ */ zod.object({
.describe(
'Data type of the incremental field.\n\n* `integer` - integer\n* `numeric` - numeric\n* `datetime` - datetime\n* `date` - date\n* `timestamp` - timestamp\n* `objectid` - objectid\n* `xid` - xid'
),
+ incremental_field_lookback_seconds: zod
+ .number()
+ .min(externalDataSchemasReloadCreateBodyIncrementalFieldLookbackSecondsMin)
+ .max(externalDataSchemasReloadCreateBodyIncrementalFieldLookbackSecondsMax)
+ .nullish()
+ .describe(
+ 'Seconds to subtract from the stored incremental watermark at sync time, so each incremental run re-reads a rolling overlap window and catches late or backdated rows. Applies to timestamp/date incremental fields only. The stored watermark is unchanged. Maximum 5184000 (60 days).'
+ ),
sync_frequency: zod
.union([
zod
@@ -449,6 +493,9 @@ export const ExternalDataSchemasResyncCreateParams = /* @__PURE__ */ zod.object(
),
})
+export const externalDataSchemasResyncCreateBodyIncrementalFieldLookbackSecondsMin = 0
+export const externalDataSchemasResyncCreateBodyIncrementalFieldLookbackSecondsMax = 5184000
+
export const ExternalDataSchemasResyncCreateBody = /* @__PURE__ */ zod.object({
should_sync: zod.boolean().optional(),
sync_type: zod
@@ -478,6 +525,14 @@ export const ExternalDataSchemasResyncCreateBody = /* @__PURE__ */ zod.object({
.describe(
'Data type of the incremental field.\n\n* `integer` - integer\n* `numeric` - numeric\n* `datetime` - datetime\n* `date` - date\n* `timestamp` - timestamp\n* `objectid` - objectid\n* `xid` - xid'
),
+ incremental_field_lookback_seconds: zod
+ .number()
+ .min(externalDataSchemasResyncCreateBodyIncrementalFieldLookbackSecondsMin)
+ .max(externalDataSchemasResyncCreateBodyIncrementalFieldLookbackSecondsMax)
+ .nullish()
+ .describe(
+ 'Seconds to subtract from the stored incremental watermark at sync time, so each incremental run re-reads a rolling overlap window and catches late or backdated rows. Applies to timestamp/date incremental fields only. The stored watermark is unchanged. Maximum 5184000 (60 days).'
+ ),
sync_frequency: zod
.union([
zod
diff --git a/services/mcp/src/tools/generated/warehouse_sources.ts b/services/mcp/src/tools/generated/warehouse_sources.ts
index 78e8cca54229..d0e7b00e57e8 100644
--- a/services/mcp/src/tools/generated/warehouse_sources.ts
+++ b/services/mcp/src/tools/generated/warehouse_sources.ts
@@ -140,6 +140,9 @@ const externalDataSchemasCancel = (): ToolBase<typeof ExternalDataSchemasCancelS
if (params.incremental_field_type !== undefined) {
body['incremental_field_type'] = params.incremental_field_type
}
+ if (params.incremental_field_lookback_seconds !== undefined) {
+ body['incremental_field_lookback_seconds'] = params.incremental_field_lookback_seconds
+ }
if (params.sync_frequency !== undefined) {
body['sync_frequency'] = params.sync_frequency
}
@@ -207,6 +210,9 @@ const externalDataSchemasIncrementalFieldsCreate = (): ToolBase<
if (params.incremental_field_type !== undefined) {
body['incremental_field_type'] = params.incremental_field_type
}
+ if (params.incremental_field_lookback_seconds !== undefined) {
+ body['incremental_field_lookback_seconds'] = params.incremental_field_lookback_seconds
+ }
if (params.sync_frequency !== undefined) {
body['sync_frequency'] = params.sync_frequency
}
@@ -282,6 +288,9 @@ const externalDataSchemasPartialUpdate = (): ToolBase<
if (params.incremental_field_type !== undefined) {
body['incremental_field_type'] = params.incremental_field_type
}
+ if (params.incremental_field_lookback_seconds !== undefined) {
+ body['incremental_field_lookback_seconds'] = params.incremental_field_lookback_seconds
+ }
if (params.sync_frequency !== undefined) {
body['sync_frequency'] = params.sync_frequency
}
@@ -331,6 +340,9 @@ const externalDataSchemasReload = (): ToolBase<typeof ExternalDataSchemasReloadS
if (params.incremental_field_type !== undefined) {
body['incremental_field_type'] = params.incremental_field_type
}
+ if (params.incremental_field_lookback_seconds !== undefined) {
+ body['incremental_field_lookback_seconds'] = params.incremental_field_lookback_seconds
+ }
if (params.sync_frequency !== undefined) {
body['sync_frequency'] = params.sync_frequency
}
@@ -380,6 +392,9 @@ const externalDataSchemasResync = (): ToolBase<typeof ExternalDataSchemasResyncS
if (params.incremental_field_type !== undefined) {
body['incremental_field_type'] = params.incremental_field_type
}
+ if (params.incremental_field_lookback_seconds !== undefined) {
+ body['incremental_field_lookback_seconds'] = params.incremental_field_lookback_seconds
+ }
if (params.sync_frequency !== undefined) {
body['sync_frequency'] = params.sync_frequency
}
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/external-data-schemas-cancel.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/external-data-schemas-cancel.json
index 4e71e345f00a..807d7db27c1b 100644
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/external-data-schemas-cancel.json
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/external-data-schemas-cancel.json
@@ -43,6 +43,19 @@
],
"description": "Column name used to track sync progress."
},
+ "incremental_field_lookback_seconds": {
+ "anyOf": [
+ {
+ "maximum": 5184000,
+ "minimum": 0,
+ "type": "number"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "Seconds to subtract from the stored incremental watermark at sync time, so each incremental run re-reads a rolling overlap window and catches late or backdated rows. Applies to timestamp/date incremental fields only. The stored watermark is unchanged. Maximum 5184000 (60 days)."
+ },
"incremental_field_type": {
"anyOf": [
{
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/external-data-schemas-incremental-fields-create.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/external-data-schemas-incremental-fields-create.json
index 4e71e345f00a..807d7db27c1b 100644
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/external-data-schemas-incremental-fields-create.json
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/external-data-schemas-incremental-fields-create.json
@@ -43,6 +43,19 @@
],
"description": "Column name used to track sync progress."
},
+ "incremental_field_lookback_seconds": {
+ "anyOf": [
+ {
+ "maximum": 5184000,
+ "minimum": 0,
+ "type": "number"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "Seconds to subtract from the stored incremental watermark at sync time, so each incremental run re-reads a rolling overlap window and catches late or backdated rows. Applies to timestamp/date incremental fields only. The stored watermark is unchanged. Maximum 5184000 (60 days)."
+ },
"incremental_field_type": {
"anyOf": [
{
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 4e71e345f00a..807d7db27c1b 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
@@ -43,6 +43,19 @@
],
"description": "Column name used to track sync progress."
},
+ "incremental_field_lookback_seconds": {
+ "anyOf": [
+ {
+ "maximum": 5184000,
+ "minimum": 0,
+ "type": "number"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "Seconds to subtract from the stored incremental watermark at sync time, so each incremental run re-reads a rolling overlap window and catches late or backdated rows. Applies to timestamp/date incremental fields only. The stored watermark is unchanged. Maximum 5184000 (60 days)."
+ },
"incremental_field_type": {
"anyOf": [
{
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/external-data-schemas-reload.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/external-data-schemas-reload.json
index 4e71e345f00a..807d7db27c1b 100644
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/external-data-schemas-reload.json
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/external-data-schemas-reload.json
@@ -43,6 +43,19 @@
],
"description": "Column name used to track sync progress."
},
+ "incremental_field_lookback_seconds": {
+ "anyOf": [
+ {
+ "maximum": 5184000,
+ "minimum": 0,
+ "type": "number"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "Seconds to subtract from the stored incremental watermark at sync time, so each incremental run re-reads a rolling overlap window and catches late or backdated rows. Applies to timestamp/date incremental fields only. The stored watermark is unchanged. Maximum 5184000 (60 days)."
+ },
"incremental_field_type": {
"anyOf": [
{
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/external-data-schemas-resync.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/external-data-schemas-resync.json
index 4e71e345f00a..807d7db27c1b 100644
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/external-data-schemas-resync.json
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/external-data-schemas-resync.json
@@ -43,6 +43,19 @@
],
"description": "Column name used to track sync progress."
},
+ "incremental_field_lookback_seconds": {
+ "anyOf": [
+ {
+ "maximum": 5184000,
+ "minimum": 0,
+ "type": "number"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "Seconds to subtract from the stored incremental watermark at sync time, so each incremental run re-reads a rolling overlap window and catches late or backdated rows. Applies to timestamp/date incremental fields only. The stored watermark is unchanged. Maximum 5184000 (60 days)."
+ },
"incremental_field_type": {
"anyOf": [
{