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.

fix(data-warehouse): set duckgres apply-marker applied_at explicitly (#65889)

Eric Duong74d27541b138
diff --git a/posthog/temporal/data_imports/pipelines/pipeline_v3/duckgres/processor.py b/posthog/temporal/data_imports/pipelines/pipeline_v3/duckgres/processor.py
index eb800804dcfb..29da2ca8004e 100644
--- a/posthog/temporal/data_imports/pipelines/pipeline_v3/duckgres/processor.py
+++ b/posthog/temporal/data_imports/pipelines/pipeline_v3/duckgres/processor.py
@@ -347,8 +347,11 @@ def _mark_duckgres_batch_applied(conn: psycopg.Connection[Any], duckgres_schema:
cursor = conn.execute(
sql.SQL(
"""
- INSERT INTO {}.{} (schema_id, run_uuid, batch_index, batch_id)
- VALUES (%s, %s, %s, %s)
+ -- applied_at is set explicitly: DuckLake does not apply the column's
+ -- DEFAULT now() on insert (unlike Postgres), so omitting it writes NULL
+ -- and trips the NOT NULL constraint.
+ INSERT INTO {}.{} (schema_id, run_uuid, batch_index, batch_id, applied_at)
+ VALUES (%s, %s, %s, %s, now())
ON CONFLICT (schema_id, run_uuid, batch_index) DO NOTHING
"""
).format(