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(ws): use strict greater-than for incremental syncs in MySQL, Snowflake, and BigQuery (#57601)

estefania9072365f6f77
diff --git a/posthog/temporal/data_imports/sources/bigquery/bigquery.py b/posthog/temporal/data_imports/sources/bigquery/bigquery.py
index a74165dd9e0a..9d1f32e7cd5e 100644
--- a/posthog/temporal/data_imports/sources/bigquery/bigquery.py
+++ b/posthog/temporal/data_imports/sources/bigquery/bigquery.py
@@ -511,7 +511,7 @@ def _get_query(
return f"""
SELECT * FROM `{bq_table.dataset_id}`.`{bq_table.table_id}`
- WHERE `{incremental_field}` >= {last_value}
+ WHERE `{incremental_field}` > {last_value}
ORDER BY `{incremental_field}` ASC
"""
diff --git a/posthog/temporal/data_imports/sources/mysql/mysql.py b/posthog/temporal/data_imports/sources/mysql/mysql.py
index 58689a4963cb..75f936d5b718 100644
--- a/posthog/temporal/data_imports/sources/mysql/mysql.py
+++ b/posthog/temporal/data_imports/sources/mysql/mysql.py
@@ -192,7 +192,7 @@ def _build_query(
query = (
f"SELECT * FROM {table}{hint}"
- f" WHERE {_sanitize_identifier(incremental_field)} >= %(incremental_value)s"
+ f" WHERE {_sanitize_identifier(incremental_field)} > %(incremental_value)s"
f" ORDER BY {_sanitize_identifier(incremental_field)} ASC"
)
diff --git a/posthog/temporal/data_imports/sources/snowflake/snowflake.py b/posthog/temporal/data_imports/sources/snowflake/snowflake.py
index 235f4bac9a7b..748372f96977 100644
--- a/posthog/temporal/data_imports/sources/snowflake/snowflake.py
+++ b/posthog/temporal/data_imports/sources/snowflake/snowflake.py
@@ -161,7 +161,7 @@ def _build_query(
if db_incremental_field_last_value is None:
db_incremental_field_last_value = incremental_type_to_initial_value(incremental_field_type)
- return "SELECT * FROM IDENTIFIER(%s) WHERE IDENTIFIER(%s) >= %s ORDER BY IDENTIFIER(%s) ASC", (
+ return "SELECT * FROM IDENTIFIER(%s) WHERE IDENTIFIER(%s) > %s ORDER BY IDENTIFIER(%s) ASC", (
f"{database}.{schema}.{table_name}",
incremental_field,
db_incremental_field_last_value,