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): stop capturing chdb schema-drift errors (#92812)

Tom Owersdb73aaeb51e5
diff --git a/products/warehouse_sources/backend/models/table.py b/products/warehouse_sources/backend/models/table.py
index 3b14f13ff604..b0962a247d07 100644
--- a/products/warehouse_sources/backend/models/table.py
+++ b/products/warehouse_sources/backend/models/table.py
@@ -481,8 +481,21 @@ class DataWarehouseTable(CreatedMetaFields, UpdatedMetaFields, UUIDTModel, Delet
except:
return False
+ # chdb failures the ClickHouse fallback below handles on its own. Capturing them sends one
+ # exception per affected read to error tracking, where nothing is actionable, because the read
+ # still returns. The fallback keeps its own capture, so a genuine failure is still reported.
+ _SUPPRESSED_CHDB_ERROR_SUBSTRINGS = (
+ "unsupported deltalake type: timestamp_ntz",
+ # A source added a column mid-stream, so the parquet parts under one table disagree on
+ # column count. ClickHouse reads the same files fine; only chdb refuses the mixed set.
+ "reading from files with different schema is not possible",
+ )
+
def _is_suppressed_chdb_error(self, err: Exception) -> bool:
- return isinstance(err, RuntimeError) and "unsupported deltalake type: timestamp_ntz" in str(err).lower()
+ if not isinstance(err, RuntimeError):
+ return False
+ message = str(err).lower()
+ return any(substring in message for substring in self._SUPPRESSED_CHDB_ERROR_SUBSTRINGS)
def set_columns(self, columns: dict[str, Any]) -> None:
"""Assign ``columns`` and record its order together.
diff --git a/products/warehouse_sources/backend/tests/test_table.py b/products/warehouse_sources/backend/tests/test_table.py
index d67eaad44ce8..0ec42666d7fe 100644
--- a/products/warehouse_sources/backend/tests/test_table.py
+++ b/products/warehouse_sources/backend/tests/test_table.py
@@ -208,18 +208,36 @@ class TestRunChdbQuery:
with pytest.raises(RuntimeError, match="timed out"):
run_chdb_query("SELECT sleep(2)", timeout=0.5)
- def test_suppressed_delta_error_classification_survives_subprocess_boundary(self) -> None:
+ @pytest.mark.parametrize(
+ "stderr",
+ [
+ "Code: 36. DB::Exception: Unsupported DeltaLake type: timestamp_ntz. (BAD_ARGUMENTS)",
+ # Emitted when a source adds a column mid-stream and the parquet parts under one
+ # table disagree on column count. Kept verbatim: the suppression matches on this
+ # wording, so a ClickHouse rephrasing has to fail the test rather than pass silently.
+ "Code: 48. DB::Exception: Reading from files with different schema is not possible. "
+ "The table has 23 columns, which is different from 24 columns in the file. (NOT_IMPLEMENTED)",
+ ],
+ )
+ def test_suppressed_chdb_error_classification_survives_subprocess_boundary(self, stderr: str) -> None:
+ completed = subprocess.CompletedProcess(args=[], returncode=1, stdout="", stderr=stderr)
+ with patch("products.warehouse_sources.backend.models.table.subprocess.run", return_value=completed):
+ with pytest.raises(RuntimeError) as exc_info:
+ run_chdb_query("DESCRIBE TABLE s3('https://example.com/table/')")
+
+ assert DataWarehouseTable()._is_suppressed_chdb_error(exc_info.value)
+
+ def test_unrelated_chdb_error_is_not_suppressed(self) -> None:
+ # The suppression must stay a narrow allow-list. A chdb failure the ClickHouse fallback
+ # cannot absorb has to keep reaching error tracking.
completed = subprocess.CompletedProcess(
- args=[],
- returncode=1,
- stdout="",
- stderr="Code: 36. DB::Exception: Unsupported DeltaLake type: timestamp_ntz. (BAD_ARGUMENTS)",
+ args=[], returncode=1, stdout="", stderr="Code: 499. DB::Exception: Access Denied. (S3_ERROR)"
)
with patch("products.warehouse_sources.backend.models.table.subprocess.run", return_value=completed):
with pytest.raises(RuntimeError) as exc_info:
run_chdb_query("DESCRIBE TABLE s3('https://example.com/table/')")
- assert DataWarehouseTable()._is_suppressed_chdb_error(exc_info.value)
+ assert not DataWarehouseTable()._is_suppressed_chdb_error(exc_info.value)
class TestGetHogqlFieldForColumn(SimpleTestCase):