diff --git a/changelog.d/ITL-1550.md b/changelog.d/ITL-1550.md new file mode 100644 index 000000000..5630fcacc --- /dev/null +++ b/changelog.d/ITL-1550.md @@ -0,0 +1,4 @@ +### Changed + +- Documented which names form Orcapod's public interface and how provisional features may change. +- Documented how Arrow list item names, metadata and nullability affect column types and hashes. diff --git a/docs/api/index.md b/docs/api/index.md index 206afe787..a8a1612e2 100644 --- a/docs/api/index.md +++ b/docs/api/index.md @@ -3,6 +3,15 @@ This section contains the full API reference for Orcapod, auto-generated from source code docstrings. +## Public interface + +Orcapod's public interface consists of exactly the objects, methods, properties and +arguments shown in this API reference. A name absent from the reference is internal, +even if it has no leading underscore, and may change or disappear in any release. +Features marked provisional in the documentation are public and may change in a later +release, as described for [provisional operators](../concepts/operators.md#provisional-operators) +and [provisional sources](../concepts/sources.md#provisional-sources). + ## Package structure The top-level `orcapod` namespace exposes the most commonly used entry points diff --git a/docs/concepts/sources.md b/docs/concepts/sources.md index 6da884ab0..b5a8cfea7 100644 --- a/docs/concepts/sources.md +++ b/docs/concepts/sources.md @@ -226,6 +226,45 @@ For example, `pa.large_list(pa.field("item", pa.int64(), nullable=False))` decla required items. That field has a different Arrow schema identity from the default nullable item. Use matching nested flags when joining sources or binding a slot. +The inner field's `nullable` flag is part of a list column's type. Orcapod preserves the +inner field's name and metadata in the source's Arrow schema. When hashing the schema, +Orcapod ignores the item name and ordinary metadata. An Arrow extension identifier, +stored in `ARROW:extension:*` metadata, contributes to the hash. + +Streaming joins compare the types of incoming user columns without considering list item +names or metadata. They check source-info columns more strictly. When validating a +materialized operator result against its declared schema before caching it, Orcapod also +checks the item names and metadata of the fields it validates. + +This example compares the original source's pipeline hash with the hash after each schema +change. + +```python +import pyarrow as pa + +from orcapod.sources import ArrowTableSource + + +def list_source(field_name="item", *, nullable=True, metadata=None): + item = pa.field(field_name, pa.binary(16), nullable=nullable, metadata=metadata) + values = pa.array([[bytes(16)]], type=pa.large_list(item)) + return ArrowTableSource(pa.table({"values": values})) + + +original = list_source().pipeline_hash() +print("Renamed item:", original == list_source("element").pipeline_hash()) +# Renamed item: True +with_note = list_source(metadata={"note": "example"}).pipeline_hash() +print("Ordinary metadata:", original == with_note) +# Ordinary metadata: True +print("Required item:", original == list_source(nullable=False).pipeline_hash()) +# Required item: False + +uuid_metadata = {"ARROW:extension:name": "arrow.uuid", "ARROW:extension:metadata": ""} +print("UUID extension:", original == list_source(metadata=uuid_metadata).pipeline_hash()) +# UUID extension: False +``` + When `DictSource` or `ListSource` builds a source from Python values, it checks the first row for a Python `float` in a top-level column declared `numpy.float32` or `numpy.float32 | None` in the Python schema. If it finds one, Orcapod issues a