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): reconcile batch schema with delta table in pipeline_v3 load consumer (#61394)

estefania5909ef0ac9af
diff --git a/posthog/temporal/data_imports/pipelines/pipeline/pipeline.py b/posthog/temporal/data_imports/pipelines/pipeline/pipeline.py
index f17cd2a7e886..fffc450f1820 100644
--- a/posthog/temporal/data_imports/pipelines/pipeline/pipeline.py
+++ b/posthog/temporal/data_imports/pipelines/pipeline/pipeline.py
@@ -39,8 +39,8 @@ from posthog.temporal.data_imports.pipelines.pipeline.hogql_schema import HogQLS
from posthog.temporal.data_imports.pipelines.pipeline.typings import PipelineResult, ResumableData, SourceResponse
from posthog.temporal.data_imports.pipelines.pipeline.utils import (
_append_debug_column_to_pyarrows_table,
- _evolve_pyarrow_schema,
_handle_null_columns_with_definitions,
+ evolve_pyarrow_schema,
normalize_table_column_names,
setup_partitioning,
)
@@ -280,7 +280,7 @@ class PipelineNonDLT(Generic[ResumableData]):
pa_table = await setup_partitioning(pa_table, delta_table, self._schema, self._resource, self._logger)
- pa_table = _evolve_pyarrow_schema(pa_table, delta_table.schema() if delta_table is not None else None)
+ pa_table = evolve_pyarrow_schema(pa_table, delta_table.schema() if delta_table is not None else None)
pa_table = _handle_null_columns_with_definitions(pa_table, self._resource)
write_type: Literal["incremental", "full_refresh", "append"] = "full_refresh"
diff --git a/posthog/temporal/data_imports/pipelines/pipeline/test/test_delta_table_helper.py b/posthog/temporal/data_imports/pipelines/pipeline/test/test_delta_table_helper.py
index 66e4bb682963..bd21bb25b1ae 100644
--- a/posthog/temporal/data_imports/pipelines/pipeline/test/test_delta_table_helper.py
+++ b/posthog/temporal/data_imports/pipelines/pipeline/test/test_delta_table_helper.py
@@ -1,12 +1,18 @@
import json
+from pathlib import Path
+from typing import Any
import pytest
from unittest.mock import AsyncMock, MagicMock, patch
+import pyarrow as pa
import deltalake
+import pyarrow.compute as pc
from parameterized import parameterized
+from posthog.temporal.data_imports.pipelines.pipeline.consts import PARTITION_KEY
from posthog.temporal.data_imports.pipelines.pipeline.delta_table_helper import DeltaTableHelper
+from posthog.temporal.data_imports.pipelines.pipeline.utils import evolve_pyarrow_schema
def _make_logger():
@@ -180,3 +186,150 @@ class TestWriteToDeltalakeCommitMetadataPassThrough:
else:
assert isinstance(commit_properties, deltalake.CommitProperties)
assert commit_properties.custom_metadata == expected_custom_metadata
+
+
+def _create_legacy_delta_table(path: str, *, partitioned: bool = False) -> deltalake.DeltaTable:
+ """Seed a Delta table that mimics what the old dlt pipeline created:
+ business columns plus NOT NULL _dlt_id and _dlt_load_id."""
+ fields: list[pa.Field] = [
+ pa.field("id", pa.int64()),
+ pa.field("name", pa.string()),
+ pa.field("_dlt_id", pa.string(), nullable=False),
+ pa.field("_dlt_load_id", pa.string(), nullable=False),
+ ]
+ if partitioned:
+ fields.append(pa.field(PARTITION_KEY, pa.string()))
+
+ data_dict: dict[str, Any] = {
+ "id": pa.array([1, 2]),
+ "name": pa.array(["a", "b"]),
+ "_dlt_id": pa.array(["id1", "id2"]),
+ "_dlt_load_id": pa.array(["load1", "load1"]),
+ }
+ if partitioned:
+ data_dict[PARTITION_KEY] = pa.array(["p0", "p0"])
+
+ table = pa.table(data_dict, schema=pa.schema(fields))
+ deltalake.write_deltalake(path, table, partition_by=PARTITION_KEY if partitioned else None)
+ return deltalake.DeltaTable(path)
+
+
+def _v3_batch(*, partitioned: bool = False) -> pa.Table:
+ """Build an incoming batch the way pipeline_v3 does: no _dlt_* columns."""
+ data_dict: dict[str, Any] = {"id": pa.array([3, 4]), "name": pa.array(["c", "d"])}
+ if partitioned:
+ data_dict[PARTITION_KEY] = pa.array(["p0", "p0"])
+ return pa.table(data_dict)
+
+
+def _make_local_helper(delta_uri: str) -> DeltaTableHelper:
+ """DeltaTableHelper that reads/writes a local filesystem path instead of S3."""
+ helper = DeltaTableHelper(resource_name="test", job=MagicMock(), logger=_make_logger())
+ patch.object(helper, "_get_delta_table_uri", new=AsyncMock(return_value=delta_uri)).start()
+ patch.object(helper, "_get_credentials", new=MagicMock(return_value={})).start()
+ helper.get_delta_table.cache_clear()
+ return helper
+
+
+class TestLegacyDltTableReconciliation:
+ """Pipeline_v3 must handle dlt-created Delta tables with NOT NULL _dlt_* columns."""
+
+ def test_raw_merge_rejects_missing_non_nullable_columns(self, tmp_path: Path) -> None:
+ """Baseline: proves delta-rs rejects merges when non-nullable columns are absent
+ from the source batch. This is the root cause of the production failures."""
+ delta_path = str(tmp_path / "table")
+ _create_legacy_delta_table(delta_path)
+ batch = _v3_batch()
+ dt = deltalake.DeltaTable(delta_path)
+
+ with pytest.raises(Exception, match="(?i)(invalid data|non-nullable|validation|not found)"):
+ dt.merge(
+ source=batch,
+ source_alias="source",
+ target_alias="target",
+ predicate="source.id = target.id",
+ ).when_matched_update_all().when_not_matched_insert_all().execute()
+
+ @pytest.mark.parametrize("partitioned", [False, True], ids=["flat", "partitioned"])
+ @pytest.mark.asyncio
+ async def test_incremental_merge_into_legacy_table(self, partitioned: bool, tmp_path: Path) -> None:
+ delta_path = str(tmp_path / "table")
+ dt = _create_legacy_delta_table(delta_path, partitioned=partitioned)
+
+ helper = _make_local_helper(delta_path)
+ batch = evolve_pyarrow_schema(_v3_batch(partitioned=partitioned), dt.schema())
+
+ result = await helper.write_to_deltalake(
+ data=batch,
+ write_type="incremental",
+ should_overwrite_table=False,
+ primary_keys=["id"],
+ )
+
+ final = result.to_pyarrow_table()
+ assert final.num_rows == 4
+ assert set(final.column("id").to_pylist()) == {1, 2, 3, 4}
+
+ new_rows = final.filter(pc.is_in(final.column("id"), value_set=pa.array([3, 4])))
+ assert all(v == "" for v in new_rows.column("_dlt_id").to_pylist())
+ assert all(v == "" for v in new_rows.column("_dlt_load_id").to_pylist())
+
+ @pytest.mark.asyncio
+ async def test_append_to_legacy_table(self, tmp_path: Path) -> None:
+ delta_path = str(tmp_path / "table")
+ dt = _create_legacy_delta_table(delta_path)
+
+ helper = _make_local_helper(delta_path)
+ batch = evolve_pyarrow_schema(_v3_batch(), dt.schema())
+
+ result = await helper.write_to_deltalake(
+ data=batch,
+ write_type="append",
+ should_overwrite_table=False,
+ primary_keys=None,
+ )
+
+ final = result.to_pyarrow_table()
+ assert final.num_rows == 4
+ assert set(final.column("id").to_pylist()) == {1, 2, 3, 4}
+
+ @pytest.mark.asyncio
+ async def test_full_refresh_overwrite_on_legacy_table(self, tmp_path: Path) -> None:
+ delta_path = str(tmp_path / "table")
+ dt = _create_legacy_delta_table(delta_path)
+
+ helper = _make_local_helper(delta_path)
+ batch = evolve_pyarrow_schema(_v3_batch(), dt.schema())
+
+ result = await helper.write_to_deltalake(
+ data=batch,
+ write_type="full_refresh",
+ should_overwrite_table=True,
+ primary_keys=None,
+ )
+
+ final = result.to_pyarrow_table()
+ assert final.num_rows == 2
+ assert all(v == "" for v in final.column("_dlt_id").to_pylist())
+ assert all(v == "" for v in final.column("_dlt_load_id").to_pylist())
+
+ @pytest.mark.asyncio
+ async def test_v3_native_table_still_merges(self, tmp_path: Path) -> None:
+ delta_path = str(tmp_path / "table")
+ fields: list[pa.Field] = [pa.field("id", pa.int64()), pa.field("name", pa.string())]
+ schema = pa.schema(fields)
+ deltalake.write_deltalake(delta_path, pa.table({"id": [1, 2], "name": ["a", "b"]}, schema=schema))
+
+ helper = _make_local_helper(delta_path)
+ batch = pa.table({"id": [3], "name": ["c"]})
+
+ result = await helper.write_to_deltalake(
+ data=batch,
+ write_type="incremental",
+ should_overwrite_table=False,
+ primary_keys=["id"],
+ )
+
+ final = result.to_pyarrow_table()
+ assert final.num_rows == 3
+ assert set(final.column("id").to_pylist()) == {1, 2, 3}
diff --git a/posthog/temporal/data_imports/pipelines/pipeline/test/test_pipeline_utils.py b/posthog/temporal/data_imports/pipelines/pipeline/test/test_pipeline_utils.py
index f1652447bc83..3dbed53abd19 100644
--- a/posthog/temporal/data_imports/pipelines/pipeline/test/test_pipeline_utils.py
+++ b/posthog/temporal/data_imports/pipelines/pipeline/test/test_pipeline_utils.py
@@ -16,9 +16,9 @@ from structlog.types import FilteringBoundLogger
from posthog.temporal.data_imports.pipelines.pipeline.consts import PARTITION_KEY
from posthog.temporal.data_imports.pipelines.pipeline.utils import (
SchemaColumnTypeChangedException,
- _evolve_pyarrow_schema,
_get_max_decimal_type,
append_partition_key_to_table,
+ evolve_pyarrow_schema,
normalize_table_column_names,
setup_partitioning,
table_from_py_list,
@@ -402,7 +402,7 @@ def test_evolve_pyarrow_schema_decimal_reconciliation(
delta_schema = deltalake.Schema.from_arrow(
pa.schema([pa.field("id", pa.int64(), nullable=False), pa.field("amount", delta_type, nullable=True)])
)
- evolved = _evolve_pyarrow_schema(arrow_table, delta_schema)
+ evolved = evolve_pyarrow_schema(arrow_table, delta_schema)
result_type = evolved.schema.field("amount").type
result_vals = evolved.column("amount").to_pylist()
if expect_string:
@@ -431,7 +431,7 @@ def test_evolve_pyarrow_schema_arrow_invalid_fallback_to_decimal256_then_string(
pa.field("amount", pa.decimal128(38, 18), nullable=True),
]
delta_schema = deltalake.Schema.from_arrow(pa.schema(delta_fields))
- evolved_table = _evolve_pyarrow_schema(arrow_table, delta_schema)
+ evolved_table = evolve_pyarrow_schema(arrow_table, delta_schema)
result_type = evolved_table.schema.field("amount").type
assert pa.types.is_string(result_type)
result_val = evolved_table.column("amount").to_pylist()[0]
@@ -440,14 +440,14 @@ def test_evolve_pyarrow_schema_arrow_invalid_fallback_to_decimal256_then_string(
def test_evolve_pyarrow_schema_decimal_integration_table_from_py_list():
- """table_from_py_list + _evolve_pyarrow_schema: 7 int digits → decimal128(38, 31)."""
+ """table_from_py_list + evolve_pyarrow_schema: 7 int digits → decimal128(38, 31)."""
schema = pa.schema({"amount": pa.decimal128(38, 32)})
table = table_from_py_list([{"amount": decimal.Decimal("1234567.5")}], schema)
delta_fields: list[pa.Field] = [
pa.field("amount", pa.decimal128(38, 32), nullable=True),
]
delta_schema = deltalake.Schema.from_arrow(pa.schema(delta_fields))
- evolved_table = _evolve_pyarrow_schema(table, delta_schema)
+ evolved_table = evolve_pyarrow_schema(table, delta_schema)
assert evolved_table.schema.field("amount").type == pa.decimal128(38, 31)
@@ -489,7 +489,7 @@ def test_evolve_pyarrow_schema_decimal_does_not_widen_unnecessarily_and_can_wide
pa.schema([pa.field("id", pa.int64(), nullable=False), pa.field("amount", pa.decimal128(10, 2), nullable=True)]) # type: ignore[arg-type]
)
- evolved_table = _evolve_pyarrow_schema(arrow_table, delta_schema)
+ evolved_table = evolve_pyarrow_schema(arrow_table, delta_schema)
assert evolved_table.schema.field("amount").type == expected_type
@@ -519,7 +519,7 @@ def test_evolve_pyarrow_schema_integer_overflow_raises_actionable_error(
)
with pytest.raises(SchemaColumnTypeChangedException, match="Source column type changed"):
- _evolve_pyarrow_schema(arrow_table, delta_schema)
+ evolve_pyarrow_schema(arrow_table, delta_schema)
def test_evolve_pyarrow_schema_integer_narrowing_within_range_is_preserved():
@@ -535,14 +535,14 @@ def test_evolve_pyarrow_schema_integer_narrowing_within_range_is_preserved():
pa.schema([pa.field("id", pa.int64(), nullable=False), pa.field("val", pa.int32(), nullable=True)])
)
- evolved_table = _evolve_pyarrow_schema(arrow_table, delta_schema)
+ evolved_table = evolve_pyarrow_schema(arrow_table, delta_schema)
assert evolved_table.schema.field("val").type == pa.int32()
assert evolved_table.column("val").to_pylist() == [10, 20]
def test_evolve_pyarrow_schema_with_struct_containing_datetime_and_decimal():
- """Test that _evolve_pyarrow_schema can handle struct columns with non-JSON-serializable types."""
+ """Test that evolve_pyarrow_schema can handle struct columns with non-JSON-serializable types."""
metadata_struct_type = pa.struct(
[
("role", pa.string()),
@@ -572,7 +572,7 @@ def test_evolve_pyarrow_schema_with_struct_containing_datetime_and_decimal():
pa.field("metadata", pa.string(), nullable=True),
]
delta_schema = deltalake.Schema.from_arrow(pa.schema(delta_fields))
- evolved_table = _evolve_pyarrow_schema(arrow_table, delta_schema)
+ evolved_table = evolve_pyarrow_schema(arrow_table, delta_schema)
assert evolved_table.schema.field("metadata").type == pa.string()
metadata_values = evolved_table.column("metadata").to_pylist()
@@ -581,7 +581,7 @@ def test_evolve_pyarrow_schema_with_struct_containing_datetime_and_decimal():
def test_evolve_pyarrow_schema_with_list_containing_datetime():
- """Test that _evolve_pyarrow_schema can handle list columns with non-JSON-serializable types."""
+ """Test that evolve_pyarrow_schema can handle list columns with non-JSON-serializable types."""
arrow_table = pa.table(
{
"id": pa.array([1, 2], type=pa.int64()),
@@ -595,7 +595,7 @@ def test_evolve_pyarrow_schema_with_list_containing_datetime():
]
delta_schema = deltalake.Schema.from_arrow(pa.schema(delta_fields))
- evolved_table = _evolve_pyarrow_schema(arrow_table, delta_schema)
+ evolved_table = evolve_pyarrow_schema(arrow_table, delta_schema)
assert evolved_table.schema.field("tags").type == pa.string()
tags_values = evolved_table.column("tags").to_pylist()
@@ -608,14 +608,14 @@ class TestEvolveSchemaFirstPass:
def test_no_delta_schema_returns_delta_compatible_table(self):
arrow_table = pa.table({"id": pa.array([1], type=pa.int64()), "name": pa.array(["a"])})
- result = _evolve_pyarrow_schema(arrow_table, None)
+ result = evolve_pyarrow_schema(arrow_table, None)
assert result.schema.field("id").type == pa.int64()
assert result.schema.field("name").type in (pa.string(), pa.large_string())
def test_duration_column_converted_to_seconds(self):
durations = pa.array([datetime.timedelta(seconds=90), datetime.timedelta(seconds=3661), None])
arrow_table = pa.table({"elapsed": durations})
- result = _evolve_pyarrow_schema(arrow_table, None)
+ result = evolve_pyarrow_schema(arrow_table, None)
values = result.column("elapsed").to_pylist()
assert values[0] == 90.0
assert values[1] == 3661.0
@@ -624,13 +624,13 @@ class TestEvolveSchemaFirstPass:
def test_nanosecond_timestamp_normalized_to_microseconds(self):
ns_ts = pa.array([1_000_000_000, 2_000_000_000], type=pa.timestamp("ns"))
arrow_table = pa.table({"ts": ns_ts})
- result = _evolve_pyarrow_schema(arrow_table, None)
+ result = evolve_pyarrow_schema(arrow_table, None)
assert result.schema.field("ts").type == pa.timestamp("us")
def test_tz_timestamp_stripped_to_utc_microseconds(self):
tz_ts = pa.array([1_000_000, 2_000_000], type=pa.timestamp("us", tz="America/New_York"))
arrow_table = pa.table({"ts": tz_ts})
- result = _evolve_pyarrow_schema(arrow_table, None)
+ result = evolve_pyarrow_schema(arrow_table, None)
assert result.schema.field("ts").type == pa.timestamp("us")
assert result.schema.field("ts").type.tz is None
@@ -643,7 +643,7 @@ class TestEvolveSchemaSecondPassMissingColumns:
delta_schema = deltalake.Schema.from_arrow(
pa.schema([pa.field("id", pa.int64()), pa.field("name", pa.string(), nullable=True)]) # type: ignore[arg-type]
)
- result = _evolve_pyarrow_schema(arrow_table, delta_schema)
+ result = evolve_pyarrow_schema(arrow_table, delta_schema)
assert "name" in result.column_names
assert result.column("name").to_pylist() == [None, None]
@@ -652,7 +652,7 @@ class TestEvolveSchemaSecondPassMissingColumns:
delta_schema = deltalake.Schema.from_arrow(
pa.schema([pa.field("id", pa.int64()), pa.field("count", pa.int64(), nullable=False)])
)
- result = _evolve_pyarrow_schema(arrow_table, delta_schema)
+ result = evolve_pyarrow_schema(arrow_table, delta_schema)
assert "count" in result.column_names
assert result.column("count").to_pylist() == [0, 0]
@@ -663,7 +663,7 @@ class TestEvolveSchemaSecondPassDecimal:
def test_downcast_skipped_when_scales_differ(self):
arrow_table = pa.table({"amount": pa.array([decimal.Decimal("1.50")], type=pa.decimal128(38, 4))})
delta_schema = deltalake.Schema.from_arrow(pa.schema([pa.field("amount", pa.decimal128(10, 2), nullable=True)]))
- result = _evolve_pyarrow_schema(arrow_table, delta_schema)
+ result = evolve_pyarrow_schema(arrow_table, delta_schema)
result_type = result.schema.field("amount").type
assert pa.types.is_decimal128(result_type)
# max_int_digits = max(8, 34) = 34, merged_scale = min(max(2,4), 38-34) = 4, precision = 38
@@ -677,14 +677,14 @@ class TestEvolveSchemaSecondPassTimestamp:
utc_ts = pa.array([datetime.datetime(2024, 1, 1, 0, 0, 0)], type=pa.timestamp("us", tz="UTC"))
arrow_table = pa.table({"ts": utc_ts})
delta_schema = deltalake.Schema.from_arrow(pa.schema([pa.field("ts", pa.timestamp("us"), nullable=True)]))
- result = _evolve_pyarrow_schema(arrow_table, delta_schema)
+ result = evolve_pyarrow_schema(arrow_table, delta_schema)
assert result.schema.field("ts").type == pa.timestamp("us")
assert result.schema.field("ts").type.tz is None
def test_string_column_parsed_to_delta_timestamp(self):
arrow_table = pa.table({"ts": pa.array(["2024-01-01T12:00:00", "2024-06-15T08:30:00"])})
delta_schema = deltalake.Schema.from_arrow(pa.schema([pa.field("ts", pa.timestamp("us"), nullable=True)]))
- result = _evolve_pyarrow_schema(arrow_table, delta_schema)
+ result = evolve_pyarrow_schema(arrow_table, delta_schema)
assert result.schema.field("ts").type == pa.timestamp("us")
values = result.column("ts").to_pylist()
assert values[0] == datetime.datetime(2024, 1, 1, 12, 0, 0)
@@ -697,7 +697,7 @@ class TestEvolveSchemaSecondPassGenericCast:
def test_int32_casted_to_int64(self):
arrow_table = pa.table({"count": pa.array([1, 2, 3], type=pa.int32())})
delta_schema = deltalake.Schema.from_arrow(pa.schema([pa.field("count", pa.int64(), nullable=True)]))
- result = _evolve_pyarrow_schema(arrow_table, delta_schema)
+ result = evolve_pyarrow_schema(arrow_table, delta_schema)
assert result.schema.field("count").type == pa.int64()
assert result.column("count").to_pylist() == [1, 2, 3]
@@ -708,7 +708,7 @@ class TestEvolveSchemaSecondPassNullability:
def test_nullable_incoming_backfilled_for_non_nullable_delta(self):
arrow_table = pa.table({"name": pa.array(["hello", None, "world"])})
delta_schema = deltalake.Schema.from_arrow(pa.schema([pa.field("name", pa.large_string(), nullable=False)]))
- result = _evolve_pyarrow_schema(arrow_table, delta_schema)
+ result = evolve_pyarrow_schema(arrow_table, delta_schema)
values = result.column("name").to_pylist()
assert values == ["hello", "", "world"]
diff --git a/posthog/temporal/data_imports/pipelines/pipeline/utils.py b/posthog/temporal/data_imports/pipelines/pipeline/utils.py
index 8933f54f0449..9c26628830eb 100644
--- a/posthog/temporal/data_imports/pipelines/pipeline/utils.py
+++ b/posthog/temporal/data_imports/pipelines/pipeline/utils.py
@@ -169,7 +169,7 @@ def get_default_value_for_pyarrow_type(arrow_type: pa.DataType) -> Any:
raise ValueError(f"Unsupported PyArrow type: {arrow_type}")
-def _evolve_pyarrow_schema(incoming_table: pa.Table, delta_schema: deltalake.Schema | None) -> pa.Table:
+def evolve_pyarrow_schema(incoming_table: pa.Table, delta_schema: deltalake.Schema | None) -> pa.Table:
# First pass: normalize types that Delta write path does not handle well.
for column_name in incoming_table.column_names:
incoming_column = incoming_table.column(column_name)
diff --git a/posthog/temporal/data_imports/pipelines/pipeline_v3/load/processor.py b/posthog/temporal/data_imports/pipelines/pipeline_v3/load/processor.py
index d502394333a2..922b952eefdf 100644
--- a/posthog/temporal/data_imports/pipelines/pipeline_v3/load/processor.py
+++ b/posthog/temporal/data_imports/pipelines/pipeline_v3/load/processor.py
@@ -16,6 +16,7 @@ from posthog.temporal.data_imports.pipelines.pipeline.delta_table_helper import
from posthog.temporal.data_imports.pipelines.pipeline.hogql_schema import HogQLSchema
from posthog.temporal.data_imports.pipelines.pipeline.utils import (
append_partition_key_to_table,
+ evolve_pyarrow_schema,
pyarrow_schema_from_arrow_exportable,
)
from posthog.temporal.data_imports.pipelines.pipeline_sync import validate_schema_and_update_table
@@ -454,6 +455,9 @@ def process_message(message: Any, progress_callback: Callable[[], None] | None =
pa_table = enrich_delete_rows(pa_table, primary_keys, existing_rows)
+ if existing_delta_table is not None:
+ pa_table = evolve_pyarrow_schema(pa_table, existing_delta_table.schema())
+
if cdc_write_mode == "scd2_append":
logger.debug(
"writing_scd2_to_delta_lake",
diff --git a/posthog/temporal/data_imports/pipelines/pipeline_v3/pipeline.py b/posthog/temporal/data_imports/pipelines/pipeline_v3/pipeline.py
index 4ff1475872ee..52220b2fd7d1 100644
--- a/posthog/temporal/data_imports/pipelines/pipeline_v3/pipeline.py
+++ b/posthog/temporal/data_imports/pipelines/pipeline_v3/pipeline.py
@@ -31,8 +31,8 @@ from posthog.temporal.data_imports.pipelines.pipeline.pipeline import async_iter
from posthog.temporal.data_imports.pipelines.pipeline.typings import PipelineResult, ResumableData, SourceResponse
from posthog.temporal.data_imports.pipelines.pipeline.utils import (
_append_debug_column_to_pyarrows_table,
- _evolve_pyarrow_schema,
_handle_null_columns_with_definitions,
+ evolve_pyarrow_schema,
normalize_table_column_names,
)
from posthog.temporal.data_imports.pipelines.pipeline_sync import set_initial_sync_complete
@@ -313,7 +313,7 @@ class PipelineV3(Generic[ResumableData]):
pa_table = _append_debug_column_to_pyarrows_table(pa_table, self._load_id)
pa_table = normalize_table_column_names(pa_table)
- pa_table = _evolve_pyarrow_schema(pa_table, None)
+ pa_table = evolve_pyarrow_schema(pa_table, None)
pa_table = _handle_null_columns_with_definitions(pa_table, self._resource)
# Add missing columns from previous batches for schema consistency
diff --git a/posthog/temporal/data_imports/sources/bigquery/source.py b/posthog/temporal/data_imports/sources/bigquery/source.py
index a24ed27bcca0..735b7c124fe9 100644
--- a/posthog/temporal/data_imports/sources/bigquery/source.py
+++ b/posthog/temporal/data_imports/sources/bigquery/source.py
@@ -41,7 +41,7 @@ class BigQuerySource(SQLSource[BigQuerySourceConfig]):
return {
"PermissionDenied: 403 request failed": "BigQuery permission denied. Please check that your service account has the necessary permissions.",
"NotFound: 404": "BigQuery dataset or table not found. Please verify your project, dataset, and table names.",
- # Raised from the shared `_evolve_pyarrow_schema` in `pipelines/pipeline/utils.py`
+ # Raised from the shared `evolve_pyarrow_schema` in `pipelines/pipeline/utils.py`
# when an integer column's source type was widened (e.g. `INT64` widened from a
# narrower numeric type) after the destination table was created with the narrower
# type. Delta Lake can't widen an existing column in place, so retrying won't help —
diff --git a/posthog/temporal/data_imports/sources/clickhouse/source.py b/posthog/temporal/data_imports/sources/clickhouse/source.py
index f1e963f7b070..3b056e4820df 100644
--- a/posthog/temporal/data_imports/sources/clickhouse/source.py
+++ b/posthog/temporal/data_imports/sources/clickhouse/source.py
@@ -157,7 +157,7 @@ class ClickHouseSource(SimpleSource[ClickHouseSourceConfig], SSHTunnelMixin, Val
"No route to host": None,
"certificate verify failed": None,
"SSL: WRONG_VERSION_NUMBER": None,
- # Raised from the shared `_evolve_pyarrow_schema` in `pipelines/pipeline/utils.py`
+ # Raised from the shared `evolve_pyarrow_schema` in `pipelines/pipeline/utils.py`
# when an integer column's source type was widened (e.g. `Int32` → `Int64`) after
# the destination table was created with the narrower type. Delta Lake can't widen
# an existing column in place, so retrying won't help — the table must be reset and
diff --git a/posthog/temporal/data_imports/sources/mssql/source.py b/posthog/temporal/data_imports/sources/mssql/source.py
index c5b8b95ae15c..f412af471c0f 100644
--- a/posthog/temporal/data_imports/sources/mssql/source.py
+++ b/posthog/temporal/data_imports/sources/mssql/source.py
@@ -49,7 +49,7 @@ class MSSQLSource(SQLSource[MSSQLSourceConfig], SSHTunnelMixin, ValidateDatabase
# Lake's decimal budget (precision > 76 or scale > 32). Fixed source-data shape —
# retrying won't help.
"Cannot build decimal array from values": "One of your numeric columns contains values that exceed our decimal storage limits (max precision 76, max scale 32). Please constrain the column with a lower precision/scale, cast it to text in a view, or round the values at the source.",
- # Raised from the shared `_evolve_pyarrow_schema` in `pipelines/pipeline/utils.py`
+ # Raised from the shared `evolve_pyarrow_schema` in `pipelines/pipeline/utils.py`
# when an integer column's source type was widened (e.g. `INT` → `BIGINT`) after the
# destination table was created with the narrower type. Delta Lake can't widen an
# existing column in place, so retrying won't help — the table must be reset and
diff --git a/posthog/temporal/data_imports/sources/mysql/source.py b/posthog/temporal/data_imports/sources/mysql/source.py
index d7d6a8000ca9..aad7a31baaff 100644
--- a/posthog/temporal/data_imports/sources/mysql/source.py
+++ b/posthog/temporal/data_imports/sources/mysql/source.py
@@ -124,7 +124,7 @@ class MySQLSource(SQLSource[MySQLSourceConfig], SSHTunnelMixin, ValidateDatabase
# decimal budget (precision > 76 or scale > 32). Fixed source-data shape — retrying
# won't help.
"Cannot build decimal array from values": "One of your numeric columns contains values that exceed our decimal storage limits (max precision 76, max scale 32). Please constrain the column with a lower precision/scale, cast it to text in a view, or round the values at the source.",
- # Raised from the shared `_evolve_pyarrow_schema` in `pipelines/pipeline/utils.py`
+ # Raised from the shared `evolve_pyarrow_schema` in `pipelines/pipeline/utils.py`
# when an integer column's source type was widened (e.g. `INT` → `BIGINT`) after the
# destination table was created with the narrower type. Delta Lake can't widen an
# existing column in place, so retrying won't help — the table must be reset and
diff --git a/posthog/temporal/data_imports/sources/snowflake/source.py b/posthog/temporal/data_imports/sources/snowflake/source.py
index f9bee5510d70..1c1143ed3c3b 100644
--- a/posthog/temporal/data_imports/sources/snowflake/source.py
+++ b/posthog/temporal/data_imports/sources/snowflake/source.py
@@ -179,7 +179,7 @@ class SnowflakeSource(SQLSource[SnowflakeSourceConfig]):
"MFA authentication is required": None,
"invalid credentials": "Snowflake authentication failed. Please check your username, password, and account details.",
"authentication failed": "Snowflake authentication failed. Please check your username, password, and account details.",
- # Raised from the shared `_evolve_pyarrow_schema` in `pipelines/pipeline/utils.py`
+ # Raised from the shared `evolve_pyarrow_schema` in `pipelines/pipeline/utils.py`
# when an integer column's source type was widened (e.g. a narrower NUMBER widened
# to a larger NUMBER/BIGINT) after the destination table was created with the
# narrower type. Delta Lake can't widen an existing column in place, so retrying