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-imports): catch ArrowNotImplementedError during Delta schema evolution (#73699)

Tom Owers863bce505350
diff --git a/products/warehouse_sources/backend/temporal/data_imports/pipelines/pipeline/test/test_pipeline_utils.py b/products/warehouse_sources/backend/temporal/data_imports/pipelines/pipeline/test/test_pipeline_utils.py
index 75202a084caa..0b89bb01fff9 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/pipelines/pipeline/test/test_pipeline_utils.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/pipelines/pipeline/test/test_pipeline_utils.py
@@ -782,6 +782,9 @@ def test_evolve_pyarrow_schema_whole_valued_floats_cast_into_stored_integer_colu
(pa.bool_(), pa.array(["true", "processed"], type=pa.string())),
# A value that overflows the stored decimal precision (Cannot convert ... overflow).
(pa.decimal128(3, 1), pa.array([1.0, 999999999.0], type=pa.float64())),
+ # A cast pyarrow has no kernel for at all — raised as ArrowNotImplementedError, not
+ # ArrowInvalid (e.g. a source column that used to be numeric now arrives as a time).
+ (pa.float64(), pa.array([datetime.time(12, 30, 0), datetime.time(1, 0, 0)], type=pa.time64("us"))),
],
)
def test_evolve_pyarrow_schema_incompatible_cast_raises_actionable_error(
diff --git a/products/warehouse_sources/backend/temporal/data_imports/pipelines/pipeline/utils.py b/products/warehouse_sources/backend/temporal/data_imports/pipelines/pipeline/utils.py
index 93cfee3b5a7c..b420a300f395 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/pipelines/pipeline/utils.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/pipelines/pipeline/utils.py
@@ -295,7 +295,7 @@ def evolve_pyarrow_schema(incoming_table: pa.Table, delta_schema: deltalake.Sche
else:
try:
casted_column = incoming_column.cast(delta_field.type).combine_chunks()
- except pa.ArrowInvalid as e:
+ except (pa.ArrowInvalid, pa.ArrowNotImplementedError) as e:
# Reaching this cast already means the incoming type differs from the stored
# Delta type (see the guard above) and the timestamp path didn't apply, so a
# failure here is a deterministic, unretryable incompatibility: the source
@@ -303,12 +303,13 @@ def evolve_pyarrow_schema(incoming_table: pa.Table, delta_schema: deltalake.Sche
# shapes are an integer column widened upstream (Postgres `integer` → `bigint`),
# an integer-created column now receiving fractional values ("Float value 19.99
# was truncated converting to int64"), non-numeric text arriving for a numeric
- # column ("Failed to parse string: '80-150' as a scalar of type int32"), or a
- # value that overflows the stored decimal precision. delta-rs cannot change a
- # column's type in place, so retrying is futile — surface an actionable error
- # telling the user to reset and fully re-sync. Lossless widening (e.g. a
- # whole-valued float into an integer column) still casts fine and never reaches
- # here.
+ # column ("Failed to parse string: '80-150' as a scalar of type int32"), a
+ # value that overflows the stored decimal precision, or a cast pyarrow has no
+ # kernel for at all (e.g. `time64` → `double`, raised as ArrowNotImplementedError
+ # rather than ArrowInvalid). delta-rs cannot change a column's type in place, so
+ # retrying is futile — surface an actionable error telling the user to reset and
+ # fully re-sync. Lossless widening (e.g. a whole-valued float into an integer
+ # column) still casts fine and never reaches here.
raise SchemaColumnTypeChangedException(
f"Source column type changed: '{delta_field.name}' has values that no longer "
f"fit its stored type {delta_field.type} (incoming data is now "