Skip to content

fix(sources): reject stored logical Arrow columns (ITL-1333) - #656

Merged
eywalker merged 13 commits into
mainfrom
eywalker/itl-1333-source-refuses-stored-form-logical-column
Nov 29, 2026
Merged

eywalker merged 13 commits into
mainfrom
eywalker/itl-1333-source-refuses-stored-form-logical-column

Conversation

@eywalker

@eywalker eywalker commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

Fixes ITL-1333

Sources now raise InputValidationError when a plain Arrow field carries a logical type annotation, including in list, struct and map children. The error names the affected columns and their identifiers. Provide a live Arrow extension column, or drop its annotation when the values are meant as plain data.

On main, the stored-form Path example read as plain text while sharing the pipeline and content hashes of the live Path example. After removing both extension annotations, the resulting ordinary text input has its own hashes. The golden hashes match and the live form retains its table and hashes.

A directly constructed ArrowTableStream retains main's behavior and reads the storage values. Cache, derived source, operator and function result reads retain their existing decoding.

Independent review

Finding Classification origin/main PR before the fix Resolution
Live unregistered extension in native PyArrow inputs REGRESSION Both frame sources accept a table, record batch or reader constructed with pa.ExtensionArray.from_storage(CustomExtension(), storage). All six inputs raise InputValidationError after the C round-trip. Use the original PyArrow field type to distinguish live extensions from annotated storage. The six inputs retain main's rows, schemas and hashes.
Nested stored annotation in a pandas Arrow-backed column INCOMPLETE Both sources accept a struct with an annotated storage child after table.to_pandas(types_mapper=pd.ArrowDtype). Polars drops the unknown annotation. Both sources accept the same input. Validate the Arrow-backed dtype before Polars conversion. Both sources now name the nested field and extension in InputValidationError.
arro3 Arrow C stream with a registered Path annotation PRE-EXISTING C import behavior PyArrow rehydrates the annotated Path field and both sources accept it. Same. The imported field has a live extension type. Arro3 exports these stored and live fields in the same C representation. When an unknown annotation survives import on a plain storage field, main accepts it and both the pre-fix and final PR heads refuse it. The arro3 tests cover both cases.

The merge from main also brought in a Delta operator-log test that fed an annotated list through ArrowTableSource. The test now injects the annotation through a raw stream with source provenance, so it still reaches the Delta write guard in both sync and async jobs.

The UUID-list example from #654 now shows the source refusal and retains the hash comparison for accepted inputs.

Found in review, present on main, not addressed here

  • Registered Path on an annotated struct child can make Polars raise RuntimeError during pandas ingestion. Reproduce with pl.DataFrame(table.to_pandas(types_mapper=pd.ArrowDtype)) where the struct's string child carries the Path extension keys. The two Orcapod sources now catch the stored child before it reaches Polars.
  • PyArrow rehydrates a registered Path in an arro3 export. Reproduce with pa.table(ArroTable.from_arrow(normalize_extension_columns(live_paths))) and inspect the imported field type.
  • Delta refuses an invalid Path annotation on int64 storage before source validation. Write a Delta table whose int64 field carries the Path extension keys and open it with DeltaTableSource to reproduce the same TypeIdentityError on both revisions.

Second independent review

INCOMPLETE — a plain declaration hid stored logical annotations in Polars inputs. Build a Polars frame with two string columns marked using pl.col("path", "other").ext.to(pl.Extension("test.polars.stored", pl.String, "{}")). Export it to Arrow and remove the metadata from the fields in the declared schema only. Both origin/main (1fb2a7f7) and the reviewed PR head (959001cd) accepted the annotated data through DataFrameSource and through synchronous and asynchronous PollingSource reads. All six cases, covering both column orders, failed the refusal test on both revisions. Both sources now check the incoming fields before applying the plain declaration. Their error names both fields and gives the extension identifier and remedy.

The shared check is require_live_logical_types. Its source intake call sites are:

Sources Where the incoming fields are checked
ArrowTableSource, ListSource, and Python-inferred DictSource SourceStreamBuilder.build checks the raw schema. Nullability inference preserves field metadata.
DictSource with an Arrow declaration DictSource.__init__ checks the declaration before conversion.
DataFrameSource and PollingSource read_arrow_frame_input checks native PyArrow schemas before C import, other Arrow exporters after import, and pandas Arrow-backed dtypes before Polars ingestion. DataFrameSource.__init__ checks the Polars Arrow exports before dropping reserved fields or applying a cast. PollingSource._build_stream_from_df checks the Polars Arrow export before rebuilding any fields, for both sync and async reads. Each source also checks its explicit Arrow declaration.
CSVSource CSVSource._read_table checks declarations before parsing. The builder checks inferred reader output.
DBTableSource, SQLiteTableSource, and PostgreSQLTableSource DBTableSource._read_table checks Arrow batches before applying database column information.
DeltaTableSource SourceStreamBuilder.build checks the dataset's Arrow table on open and rebuild. DeltaTableSource.check_for_new_data checks a changed Arrow schema before reporting schema drift.
SpiralDBTableSource SpiralDBTableSource._read_batches checks raw Arrow batches before projection and enrichment.

The intake coverage test walks the public source exports and verifies that every external source reader reaches the shared walker on an incoming data field. The cache and derived readers retain decoding for Orcapod-owned records. The proxy delegates to a bound source. RootSource defines the shared base.

Summary by CodeRabbit

  • Bug Fixes

    • Sources now reject logical-type annotations stored only in Arrow field metadata, including annotations nested in lists, structs, or maps. Errors identify the affected column and logical type.
    • Live Arrow extension types remain accepted. Cached and derived Orcapod results continue to decode as before.
  • Documentation

    • Clarified that logical columns supplied to sources must use live extension types; remove stored annotations when providing plain storage data.

@coderabbitai

coderabbitai Bot commented Nov 29, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Arrow source inputs now reject fields that carry stored logical-type annotations instead of live extension types, including nested fields. Input schemas are checked before conversion. Data from validated Orcapod sources can bypass the boundary check. Tests and documentation cover rejection and stored-result decoding.

Changes: Arrow Logical-Type Source Boundary

Layer / File(s) Summary
Shared validation and stream-building rules
src/orcapod/core/sources/stream_builder.py
Recursive checks detect stored logical-type annotations. Stream building validates external schemas unless data comes from an existing Orcapod source or job node.
Source adapter checks and origin wiring
src/orcapod/core/sources/*_source.py, tests/test_core/sources/*, tests/test_pipeline/test_delta_refusals_in_jobs.py
Source adapters validate declared or fetched schemas and preserve authoritative Arrow input schemas. Derived-source stream building marks data as originating from another source. Tests cover stored-form rejection, system-tag exclusions, live values, and stored-result decoding.
Hashing behavior and documented input rules
tests/test_hashing/*, docs/concepts/*, docs/reference/hashing.md, docs/dev/design_issues/ITL-1333-BL17.md, changelog.d/ITL-1333.md
Hashing tests distinguish live-form source inputs from stored-form inputs and use internal streams for nested identifiers. Documentation describes source input rules, schema hashing, and retained decoding of stored results.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant ArrowInput
  participant read_arrow_frame_input
  participant DataFrameSource
  participant SourceStreamBuilder
  participant require_live_logical_types
  ArrowInput->>read_arrow_frame_input: provide Arrow frame and schema
  read_arrow_frame_input-->>DataFrameSource: return table and authoritative schema
  DataFrameSource->>SourceStreamBuilder: build with input schema
  SourceStreamBuilder->>require_live_logical_types: validate external schema
  require_live_logical_types-->>SourceStreamBuilder: accept schema or raise InputValidationError
Loading
Merge Risk: Minimal · up to 8bc56

Sources now reject stored logical-type annotations on plain Arrow fields, including nested ones, and still accept live extension types. Data from Orcapod's own derived sources keeps its existing decoding. No concrete regression was found, so the change looks safe to merge.

Security architecture risk: Low · up to 8bc56

The new validation prevents plain data from being mistaken for a logical type. The main rollout risk is that a running polling feed can stop when it encounters an older, now-rejected schema. The rejected batch is not published or skipped.

Retained concerns

  • Low · reliability · observed: A polled batch whose stored logical annotation was previously accepted can now terminate the active async iterator. The existing fatal validation handler exits and calls the producer's close method without committing the rejected batch. The feed will not recover within that iterator, even if the producer later corrects its schema.
Security review details

Security Blast Radius

  • inferred — The demonstrated availability effect is limited to the polling iterator that consumes the rejected batch. Reaching it requires influence over data returned by that source's configured producer; broader deployment or tenant reach was not established.

Trust Boundaries and Controls

  • observed — The derived-source exception is selected by a builder argument, not Arrow metadata. Its only in-repository caller supplies records from its origin. The argument does not independently authenticate provenance.

Resilience and Maintainability Implications

  • observed — Sync and async polling validate before entering the locked commit block. Rejection does not publish the batch or advance its cursor; successful callers still check that their cursor snapshot is current before committing.

Hardening Proposals

  • proposed — Keep rejection diagnostics useful by reporting the affected field and extension name while bounding or omitting raw extension metadata in the exception text.
Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title "fix(sources): reject stored logical Arrow columns (ITL-1333)" names the primary change. The changeset makes external sources refuse Arrow storage fields that carry logical-type annotations,…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title "fix(sources): reject stored logical Arrow columns (ITL-1333)" names the primary change. The changeset makes external sources refuse Arrow storage fields that carry logical-type annotations, including nested list, struct, and map fields. A shared require_live_logical_types check is added across source intake paths, and the changelog, docs, and tests match this behavior. The title is concise, uses a conventional commit prefix, and avoids vague terms.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Usage-based review receipt

Note

This review was completed with usage-based billing: files reviewed beyond your plan's included limits are billed at $0.25/file. View usage-based billing.

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between dc32d93 and 8bc5656.

Files selected for processing: 17

  • docs/concepts/sources.md
  • docs/dev/design_issues/ITL-1333-BL17.md
  • docs/reference/hashing.md
  • src/orcapod/core/sources/csv_source.py
  • src/orcapod/core/sources/data_frame_source.py
  • src/orcapod/core/sources/db_table_source.py
  • src/orcapod/core/sources/delta_table_source.py
  • src/orcapod/core/sources/derived_source.py
  • src/orcapod/core/sources/dict_source.py
  • src/orcapod/core/sources/polling_source.py
  • src/orcapod/core/sources/spiraldb_table_source.py
  • src/orcapod/core/sources/stream_builder.py
  • tests/test_core/sources/test_source_arrow_validation.py
  • tests/test_core/sources/test_spiraldb_table_source_float_equalities.py
  • tests/test_hashing/test_logical_type_forms.py
  • tests/test_hashing/test_schema_hash_storage_form.py
  • tests/test_pipeline/test_delta_refusals_in_jobs.py

Limit details: You’ve used the included review currently available. Your 100 included PR review attempts over the past 7 days set your current allowance at 1 review per hour.

Recent review details

Context from checks skipped due to timeout: 2

  • GitHub Check: CodeRabbit
  • GitHub Check: Tests (3.13)
Additional context used

Code guidelines: 1

CLAUDE.md — auto-discovered
Path-based instructions: 3

Source excerpt: Every fenced `python` block in `README.md`, `docs/index.md`, `docs/getting-started.md`, `docs/troubleshooting.md`, `docs/concepts/`, `docs/reference/` and `docs/tutorial/` is executed by `tests/test_docs/test_doc_samples.py`...

CodeRabbit inference engine (CLAUDE.md)

Files:

  • docs/concepts/sources.md
  • docs/reference/hashing.md
Source excerpt: An entry is the file `docs/dev/design_issues/-.md` (e.g.

CodeRabbit inference engine (CLAUDE.md)

Files:

  • docs/dev/design_issues/ITL-1333-BL17.md
Source excerpt: Use [Google style](https://google.github.io/styleguide/pyguide.html#38-comments-and-docstrings) Python docstrings everywhere.

CodeRabbit inference engine (CLAUDE.md)

Files:

  • src/orcapod/core/sources/csv_source.py
  • src/orcapod/core/sources/data_frame_source.py
  • src/orcapod/core/sources/db_table_source.py
  • src/orcapod/core/sources/delta_table_source.py
  • src/orcapod/core/sources/derived_source.py
  • src/orcapod/core/sources/dict_source.py
  • src/orcapod/core/sources/polling_source.py
  • src/orcapod/core/sources/spiraldb_table_source.py
  • src/orcapod/core/sources/stream_builder.py
  • tests/test_core/sources/test_source_arrow_validation.py
  • tests/test_core/sources/test_spiraldb_table_source_float_equalities.py
  • tests/test_hashing/test_logical_type_forms.py
  • tests/test_hashing/test_schema_hash_storage_form.py
  • tests/test_pipeline/test_delta_refusals_in_jobs.py
Additional comments: 1

src/orcapod/core/sources/data_frame_source.py: 1

127-128: Functional Correctness

The claim depends on two premises that the inspected evidence does not settle. First, the Path branch of python_dicts_to_arrow_table is not shown, so the generated Arrow field type is unknown. Second, the Polars to_arrow export of a registered orcapod.path extension is not established. The validator skips live pa.BaseExtensionType fields and flags only plain storage carrying extension metadata. The regression would therefore exist only if Polars exports this column as annotated storage. That behavior is not settled by the repository source, and no probe was run. The claim is neither confirmed nor refuted. A rewritten comment would need the Polars export result and the converter's Path branch first.

@eywalker

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

Posted by a Codex agent on behalf of @eywalker.

@coderabbitai

coderabbitai Bot commented Nov 29, 2026 •

Copy link
Copy Markdown
Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@eywalker

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

Posted by a Codex agent on behalf of @eywalker.

@coderabbitai

coderabbitai Bot commented Nov 29, 2026 •

Copy link
Copy Markdown
Action not completed

Already reviewed the last commit. Use @coderabbitai full review to rerun a review of the entire changeset.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@eywalker
eywalker merged commit 3c13a15 into main Nov 29, 2026
10 checks passed
@eywalker
eywalker deleted the eywalker/itl-1333-source-refuses-stored-form-logical-column branch November 29, 2026 06:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant