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(databricks): stop retrying a stale view schema mismatch (#118215)

Tom Owersf5bd259e7c0d
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/databricks/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/databricks/source.py
index 78a81c298531..79e6d7d38631 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/databricks/source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/databricks/source.py
@@ -223,6 +223,12 @@ class DatabricksSource(SQLSource[DatabricksSourceConfig], ValidateDatabaseHostMi
# something PostHog's retries can fix. Matched on Databricks' own stable error class,
# not the redacted JDBC URL around it.
"[FAILED_JDBC.CONNECTION]": "Databricks couldn't connect to a federated database backing a table you're syncing (a Lakehouse Federation connection). Check that the underlying database is reachable and its connection details in Databricks are still correct, then resync.",
+ # Raised when a synced view's underlying table was altered (a column renamed or dropped)
+ # and the view's own SELECT no longer resolves — a stale view definition on the
+ # customer's side that every retry fails identically until they recreate it. Matched on
+ # Databricks' own stable error class, not the view/column names or the CREATE OR REPLACE
+ # statement it suggests around it.
+ "[INCOMPATIBLE_VIEW_SCHEMA_CHANGE]": "A view this source syncs has an incompatible schema change in Databricks — its underlying table was altered and the view's query can no longer resolve a column. Recreate the view in Databricks to match the new schema, then resync.",
}
def get_retryable_errors(self) -> set[str]:
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/databricks/tests/test_databricks.py b/products/warehouse_sources/backend/temporal/data_imports/sources/databricks/tests/test_databricks.py
index bef896178d56..91de8f3d4f13 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/databricks/tests/test_databricks.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/databricks/tests/test_databricks.py
@@ -422,6 +422,18 @@ class TestDatabricksSource:
observed_error = "Command failed because warehouse abc123 was stopped."
assert any(key in observed_error for key in source.get_retryable_errors())
+ def test_get_non_retryable_errors_matches_incompatible_view_schema_change(self, source):
+ # A synced view whose underlying table schema changed fails identically on every retry
+ # until the customer recreates the view — Databricks even echoes the view and column
+ # names plus a CREATE OR REPLACE statement, so the match must key off the stable error
+ # class rather than any of that volatile detail.
+ observed_error = (
+ "[INCOMPATIBLE_VIEW_SCHEMA_CHANGE] The SQL query of view `main`.`posthog`.`alert` has an "
+ "incompatible schema change and column alert_severity cannot be resolved. Expected 1 "
+ "columns named alert_severity but got []."
+ )
+ assert any(key in observed_error for key in source.get_non_retryable_errors())
+
class TestGetSchemasDeadline:
def test_discovery_that_hangs_raises_before_the_activity_timeout(self, mocker):