Skip to content

fix(sources)!: DataFrameSource accepts data frames only; Python containers go to DictSource or ListSource (ITL-1330) - #624

Draft
eywalker wants to merge 132 commits into
mainfrom
eywalker/itl-1330-dataframesource-built-from-python-values
Draft

eywalker wants to merge 132 commits into
mainfrom
eywalker/itl-1330-dataframesource-built-from-python-values

Conversation

@eywalker

@eywalker eywalker commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Fixes ITL-1330

Includes main through 3e640fb5, including #607, #633, #634 and #645. This draft restricts DataFrameSource to data frames and retains the existing conversion for supported frames.

Data frame inputs

DataFrameSource accepts pandas and Polars data frames and Arrow C exporters of struct data, including Arrow tables, record batches and record batch readers. Python containers, NumPy arrays, pandas or Polars Series, Polars lazy frames, and non-struct Arrow exporters raise TypeError during construction. The message names the input type and gives a remedy. Use DictSource for row dictionaries and ListSource for lists of values. Convert mappings of Python columns to row dictionaries for DictSource. Use to_frame() for a Series and collect() for a lazy frame. For NumPy inputs, including lists, tuples and mappings that mix arrays with Python lists, or non-struct Arrow data, build a pyarrow.Table with named columns of supported types and pass it to ArrowTableSource. For an iterator of positional rows that Polars can infer as supported Arrow columns, use ArrowTableSource(pl.DataFrame(data).to_arrow()). For Polars Series with distinct names and supported Arrow types, use ArrowTableSource(pa.table({series.name: series for series in data})).

Column type declarations

Pandas object columns require an explicit schema= (D26). With a schema, the source uses native frame conversion, drops auxiliary system columns and casts the remaining Arrow table to the schema. Polars Object columns use the same conversion as on main, including for frames without a schema. The existing custom system tag checks still apply.

Column Construction behavior
pandas string, Arrow-backed dtypes and typed datetime columns Use the existing conversion path
pandas object Requires a schema and uses the existing conversion and cast
Polars Object Uses the existing conversion with or without a schema
pandas categorical Uses the existing conversion, including a schema cast that decodes dictionary-backed strings when declared as text

For a pandas object column supplied without a schema, the error names the column and points to schema=, a typed dtype or DictSource. To preserve timestamp nanoseconds, build a typed pandas datetime column with pd.to_datetime and use a timestamp[ns] field. Native frame conversion can truncate these timestamps when they are carried in object columns.

Verification

Public-interface tests cover input eligibility, typed frame values and identities, object declarations across column roles and layouts, categorical and Polars Object columns, and the existing cast's successful values and refusals. Golden hashes and the source ID pinned by the existing input tests match.

Review findings

No CodeRabbit review threads were present when this draft was updated.

  • REGRESSION (test fixture). The frame cases in test_in_memory_sources_register_by_object passed on main and raised TypeError on the merged draft because the fixture passed a list to DataFrameSource. The fixture now constructs a Polars frame and still checks source registration with both orchestrators.
  • REGRESSION (documentation sample). The pandas list-column tutorial passed on main and failed on the merged draft because the example constructed an object-typed counts column. The sample now uses Arrow-backed pandas dtypes and produces the four documented results.

Independent review

Compared the reviewed head with origin/main at 146fcbf before applying the fixes.

Finding Class Main and reviewed head Test or verification
NaN in a declared pandas object column REGRESSION Main stores a null for nullable float, integer, or string fields and refuses a non-nullable float field. The reviewed head kept the float NaN and refused the integer and string inputs. test_declared_pandas_object_columns_convert_missing_values_to_nulls, test_declared_pandas_missing_values_require_nullable_fields
pd.NA in a nullable list item REGRESSION A declared list<int64> column with [[1, pd.NA], []] stores [[1, None], []] on main and raised during construction on the reviewed head. test_declared_pandas_object_columns_convert_missing_values_to_nulls, including list items and struct fields
Non-struct Arrow array and stream exporters INCOMPLETE Both revisions raised Arrow's schema error for DataFrameSource(pa.array([1, 2])) and its chunked equivalent. The PR promises a refusal that names the input type and gives a remedy. Both routes now point to ArrowTableSource with a named table column. test_non_struct_arrow_exporters_are_refused_with_a_remedy
Several-item coverage of declared object columns INCOMPLETE (test coverage) The public sync and async results matched across revisions in the original comparison. The shipped test varied one declaration at a time and used one custom system tag and one key. test_several_declared_pandas_object_columns exercises multiple declared objects, two custom system tags, two keys, both key and tag orders, two layouts, and plain and data-tag roles. It checks column names, values, source and record IDs, hashes, and sync and async rows.
Changelog history for pandas Series and Polars LazyFrame INCOMPLETE (migration documentation) Both already failed to build on main. The reviewed head gives to_frame() and collect() remedies. The changelog now describes the current refusals and their remedies. Existing test_an_input_that_is_not_a_data_frame_is_refused checks both remedies.

After the fix, 420 accepted cases in the main comparison matched in values, source IDs, content hashes, and pipeline hashes. The comparison covered None, Python NaN, pd.NA, and pd.NaT in declared scalar fields, variable and fixed-size list items, and struct fields. Golden hashes and the source ID pinned by the existing input tests matched.

Independent review of f05a7ceb

Compared the reviewed draft with origin/main at a958449a. The draft had bypassed the native pandas-to-Polars conversion and Arrow schema cast for declared object columns. Restoring that path resolved the differences below.

Finding Class Main and reviewed head Test or verification
NumPy Float32 in declared Float16 REGRESSION Main accepts the values in scalar, list and struct fields, including NumPy Float32 NaN. The draft's direct scalar conversion rejected them. test_declared_pandas_object_columns_use_native_frame_conversion, test_declared_float16_keeps_numpy_float32_nan
Boolean in declared Int64 REGRESSION Main casts [True, False] to [1, 0]. The draft refused both values. test_declared_pandas_object_columns_use_native_frame_conversion
Numeric text, text and bytes, naive datetimes, struct projection, and NumPy NaN in a Boolean struct field REGRESSION Main accepts these casts and the draft refused them. test_declared_pandas_object_columns_use_native_frame_conversion
Declared objects accepted only by the draft INCOMPLETE Under D26, declared objects must follow the existing cast. Main refuses examples such as Python integers for decimal128(12, 2), a Boolean for Float16, and all-None object columns declared as time or duration. test_declared_pandas_object_columns_keep_native_cast_errors
Timestamp and duration precision in object columns INCOMPLETE The draft changed values and hashes relative to main by preserving sub-microsecond data. D26 restores main's stored values for declared objects. Typed pandas datetime columns retain nanoseconds in a nanosecond declaration. test_pandas_declared_object_timestamp_uses_native_precision, test_pandas_declared_object_duration_uses_native_precision, test_pandas_typed_timestamps_keep_nanoseconds
pandas categorical and declared Polars Object columns REGRESSION Main accepts a numeric pandas categorical and can decode a string categorical with a text declaration. Main also accepts a declared Polars Object data column. The draft refused all three. test_pandas_categorical_keeps_native_conversion, test_declared_pandas_string_categorical_cast_decodes_dictionary, test_declared_polars_object_column_keeps_native_conversion
Arrow non-struct arrays, pandas Series and Polars LazyFrame PRE-EXISTING Both revisions refused these inputs. The draft gives an actionable message. Existing input eligibility and remedy tests

The differential matrix crossed 31 Arrow types with 55 Python, NumPy and pandas value cases, seven field shapes (scalar, variable list, fixed list, struct, list of structs, struct containing a list, map), and top-level nullability. Values included bool, signed and unsigned integers, float, Decimal, text, bytes, temporal values, every NumPy integer and float width, missing values, lists and dicts. The 55 cells combining a required scalar null field with each value were excluded. Of 23,815 cells, the reviewed draft refused 2,990 that main accepted, accepted 52 that main refused, and changed the output in 36 accepted cases. After the fix, all 23,815 matched main for acceptance or refusal. All 7,294 accepted cells also matched the Arrow table bytes, default source ID, content hash and pipeline hash.

Independent review of eeea191b

Reproduced all three findings on origin/main at a958449a and the reviewed draft before applying the fixes.

Finding Class Main and reviewed head Test
An auxiliary object column with an explicit schema REGRESSION With schema=pa.schema([("x", pa.int64())]), main accepts a pandas or Polars frame with integer x and an object-typed _note. It drops _note and emits nullable Int64 x. The reviewed draft refused both frames. test_schema_ignores_auxiliary_object_column
A Polars Object column without a schema REGRESSION Main accepts pl.DataFrame({"x": pl.Series([1, 2], dtype=pl.Object)}) and emits non-nullable Int64 x. The reviewed draft required a schema. D26 applies to pandas. test_polars_object_column_without_schema_keeps_native_conversion
Missing NumPy row migration guidance INCOMPLETE Main builds from a 2-D NumPy array and a list of NumPy arrays. The reviewed draft refuses both as intended. Its matrix error only recommends building a frame, and its list error gives generic Python container advice. Both now recommend ArrowTableSource with named Arrow columns and retain the Polars frame option. test_numpy_inputs_are_refused_with_a_named_source

The five new test cases failed on the reviewed head and pass after the fix. The accepted frame reproductions match main in Arrow schema, values, default source ID, content hash and pipeline hash.

Independent review of cb6449b3

Reproduced both findings on origin/main at bf2582d4 and the reviewed head.

Finding Class Main and reviewed head Test
NumPy tuples and mappings omitted the Arrow migration INCOMPLETE Main accepts (np.array([1, 2]), np.array([3, 4])) and a mapping of names to those arrays as two-column tables. The reviewed head refuses both as intended and omits the promised Arrow migration. The refusal now names the container type and points to named table columns and ArrowTableSource. Mapping guidance also explains how to prepare rows for DictSource. test_numpy_inputs_are_refused_with_a_named_source, test_the_refusal_of_a_python_container_points_to_both_sources
Non-struct Arrow advice gave an invalid direct wrapping recipe INCOMPLETE DataFrameSource(pa.array(["a", "b"]).dictionary_encode()) and DataFrameSource(pa.nulls(2)) raise Arrow's schema error on main and give the recipe on the reviewed head. On both revisions, ArrowTableSource(pa.table({"column": data})) refuses those column types. The refusal now directs users to a named table with supported column types. test_non_struct_arrow_exporters_are_refused_with_a_remedy checks arrays and chunked arrays, and verifies migration after decoding a dictionary array or typing a null array.

The eight new or tightened diagnostic checks failed before the changes and pass with them.

Independent review of 7b658d2b

  • INCOMPLETE (mixed NumPy and Python columns). On origin/main at 3e640fb5, DataFrameSource((np.array([1, 2]), [3, 4])) builds two non-nullable Int64 columns with rows (1, 3) and (2, 4). I reproduced the same result with a list and with the array in either position. The reviewed head intentionally refuses all four inputs and omits the promised Arrow migration. One diagnostic builder now names the container and its item types and explains how to build a named pyarrow.Table for ArrowTableSource or Python row dictionaries for DictSource. The parametrized tests cover all four mixed variants and verify that Arrow tables and record batches still build.

Independent review of 39efb582

Reproduced both findings against origin/main at 08c048a7 and the reviewed draft.

Finding Class Main and reviewed head Migration verification
Mixed NumPy and Python rows in an iterator INCOMPLETE Main accepts the iterator as positional rows. The reviewed draft refused the iterator without consuming it and offered scalar and dictionary recipes that failed. The current diagnostic gives the positional-row Arrow migration without consuming the iterator. test_mixed_row_iterators_can_migrate_to_arrow_table_source applies ArrowTableSource(pl.DataFrame(data).to_arrow()) to the original iterator and compares the rows in both item orders, for generators and list iterators.
Lists and tuples of named Polars Series INCOMPLETE Main accepts the Series as named columns. The reviewed draft refused the sequences and suggested wrapping them in a frame. The current diagnostic also gives an ArrowTableSource migration that preserves the Series names. test_named_polars_series_can_migrate_to_arrow_table_source applies ArrowTableSource(pa.table({series.name: series for series in data})) to the original list, tuple, or generator and checks column names and rows. The test also verifies the frame option for lists and tuples.

The four mixed list and tuple cases also run each recipe from the diagnostic and verify the resulting rows.

Found in review, present on main, not addressed here

  • PRE-EXISTING (input eligibility). DataFrameSource(pd.Series([1, 2])) and DataFrameSource(pl.DataFrame({"x": [1, 2]}).lazy()) already failed on main. See the migration guidance above.

  • PRE-EXISTING (input eligibility). DataFrameSource(pa.array([1, 2])) and DataFrameSource(pa.chunked_array([[1], [2]])) already failed on main. The incomplete refusal message is addressed above.

  • PRE-EXISTING (NumPy NaN). An object column containing np.float32("nan") stores NaN in declared Float32 and Float64 fields on main, the reviewed draft and the updated draft.

  • PRE-EXISTING (timestamp precision). pd.Series([pd.Timestamp("2026-01-02T03:04:05.123456789Z")], dtype=object) loses 789 ns during main's frame conversion even with a declared timestamp[ns, UTC] field. The updated draft matches main.

  • PRE-EXISTING (custom system tags). A Polars Object column created with pl.Series(["left"], dtype=pl.Object) is refused as a custom system tag even with a non-nullable text field. Use a typed text column.

eywalker and others added 30 commits November 26, 2026 01:17
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…(ITL-1471)

core/row_ids.py holds the three nested row ids and their preimages. A data
datagram gives its source-info tokens as a one-row table (source_info_table),
and the EmptyData placeholder carries tokens built as a real output's are, with
the sentinel EPHEMERAL_RESULT_GONE in place of the result id.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…_v2, tdb_v2 (ITL-1471)

A function node looks a row up by its instance id and keys it by its record id;
the recomputation index and the query before every write are gone. Side effects
and functions that take the invocation context are keyed by the entry id, the
log column record_id_hash is entry_id, and PostRunPayload.record_id_hash is
result_id. The operator cache stores the entry id and its insertion time beside
its row key, outside the key. FunctionRun.entry_id is record_id.

BREAKING CHANGE: stored pipeline tables, operator caches and side-effect logs
move to new layouts; every invocation hash changes once; an operator cache on a
SQLite database is refused when it is attached.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…n changes (ITL-1471)

A pipeline table's record id holds the result id, a UUIDv7, so it cannot be
pinned: the golden cases pin the instance ids instead. The 18 changes the
developer approved on 2026-11-25 (golden-changes.md of ITL-1466): 6 record-id
pins removed, 6 instance-id pins added, 6 table paths moved from pdb_v1 to
pdb_v2, in pipeline-02.json (4 entries) and provisional/pipeline.json (8), and
the open revision of v1.json. No other value moves.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…TL-1471)

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…ut (ITL-1471)

On the async path the second copy of an identical input either computes its
own result (two records) or takes the first's (one record), by scheduling.
The first CI run showed the second outcome.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…described (ITL-1471)

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Failing on b556376: placeholders fed through async_execute, both jobs' traces
after a token-only rerun, and an inactive function node given rows whose token
column cannot be typed again from its values.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…input hash (ITL-1471)

async_execute sent a placeholder whose instance is not stored to the function
like any miss; the pipeline writer then read it as a table and raised
EmptyDataAccessError although the result was stored. It now goes to
_empty_data_cache_hit, as on the sync route: no call, no pipeline row.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
After a token-only rerun a function's table holds two records of one entry that
name one result. The trace matched on system tags and result alone, found both
and refused every row of the first job. It now keeps the entry whose stored
input tokens are the input row's.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…L-1471)

A row read from an Arrow table keeps that table's source-info columns, and
source_info_table() returns them with a row's own nullable fields. A token's
type is never worked out again from its value, so a lookup no longer fails on
rows with a nested token column that the function is never called for.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…races and placeholders (ITL-1471)

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…lumn types (ITL-1471)

Failing on 2d8a6a8: a token column whose Arrow type is not the type its values
would be given again (a list column holding a null; a nested list).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…as made from (ITL-1471)

_add_pipeline_record stored the columns of as_table(columns={'source': True}),
typed again from the token values, while the instance id read the row's typed
columns. One helper, source_info_table(), now gives both, so every stored row
gives its instance and record id again from its own columns. For ordinary rows
the two tables are equal, so no stored column type and no id moves.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…nested tokens are recorded (ITL-1471)

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
source_info_table() of a row with no token has no column and no row; the
pipeline record leaves it out, as before the change, and the row's ids are
recomputed from the stored row all the same.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…ference (ITL-1471)

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Failing on f3f6842 (18 cases): two nodes sharing a pipeline table, a trace over
the source after a rerun with other tokens, and a placeholder without a stored
result under the row failure policy on the async route.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…; placeholders under the row failure policy (ITL-1471)

One pipeline table holds the rows of every node with one pipeline hash. Keyed
by the record id alone, a second node that recorded a shared instance with the
cached result lost its row as a duplicate. The key is now the node's content
hash with the record id (row_ids.pipeline_row_key), and the record id is stored
in its own column; its recipe is unchanged.

On the async route a placeholder whose result is not stored is one failed row
under the row failure policy, with the sync route's events (the row starts
before the lookup), instead of aborting the run.

FunctionJobNode.held_instance_ids says which instance each held row is under.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…ry branch (ITL-1471)

The branch for a function over its source took the one entry before choosing an
instance, and the other branch compared token values. Both now keep the stored
records of the instance id the node holds the row under.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…e placeholder policy (ITL-1471)

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…ry (ITL-1471)

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Failing on 69d8ec1 (17 cases): sessions whose null tokens are typed
differently share a table; a null token's instance id does not follow its
column's type; differing token types in one table are refused naming the column.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…or two types in one column (ITL-1471)

A null token is a large_string null whatever type its column declares, for the
instance id's preimage and for the stored column alike; a non-null token keeps
its typed column. So sessions whose null token columns are declared differently
share a pipeline table again, and a null token's instance id is a function of
the row alone. A row whose token column has another type than the rows recorded
is refused naming the column and both types.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…ma read (ITL-1471)

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…e events on both routes (ITL-1471)

Failing on 4a916ec (4 cases): the async route reports the row's start only.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…fore a fatal error stops the run (ITL-1471)

A database error or an identity error in a placeholder's result lookup is never
a row failure. The async route raised it after the row's start event alone; it
now reports the row's crash first, as the sync route does.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
eywalker and others added 6 commits November 27, 2026 19:21
…thon into eywalker/itl-1557-re-evaluate-a-sources-source-info-token

# Conflicts:
#	tests/test_channels/test_native_async_operators.py
A dict, a list or any other container of Python values, a NumPy array, a
Series and a LazyFrame are refused when the source is built, with a
TypeError naming the type given and the remedy. Python values go to
DictSource or ListSource, which type them by Orcapod's rules; Polars no
longer types them around those rules (nanoseconds dropped, naive
datetimes stored unzoned).

BREAKING CHANGE: DataFrameSource no longer builds from Python containers.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 28, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

eywalker and others added 9 commits November 27, 2026 21:41
…thon into eywalker/itl-1557-re-evaluate-a-sources-source-info-token
Restate the PR 601 item-metadata channel test for the declared-type rule,
and document the held-type replacement rule and the first-batch rule (ITL-1557).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Result-cache validation now sees the Arrow token type on serialization even when its value is null. Enable the regression test and update the result-cache documentation.
…sources-source-info-token' into eywalker/itl-1330-dataframesource-built-from-python-values
Base automatically changed from eywalker/itl-1557-re-evaluate-a-sources-source-info-token to main November 28, 2026 21:45

This branch has not been deployed

No deployments
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