helix_ir.schema¶
helix_ir.schema — schema representation.
- class helix_ir.schema.Schema(name: str, fields: tuple[tuple[str, ~helix_ir.types.core.HelixType], ...] = <factory>)[source]¶
Bases:
objectImmutable schema descriptor.
Fields are stored as a tuple of (name, HelixType) pairs to preserve order while remaining hashable.
- get_field(name: str) HelixType | None[source]¶
Return the HelixType for a top-level field, or None if not found.
- path(path: str) HelixType[source]¶
Return the HelixType at the given dotted path.
Example: schema.path(“customer.address.city”)
- walk() Iterable[tuple[Path, HelixType]][source]¶
Yield (path, HelixType) for every leaf field in the schema.
- walk_arrays() Iterable[tuple[Path, HelixType]][source]¶
Yield (path, HelixType) for every array field in the schema.
- classmethod from_arrow(name: str, schema: Schema) Schema[source]¶
Create a Schema from a PyArrow Schema.
- classmethod from_json(data: dict[str, Any]) Schema[source]¶
Deserialize a Schema from a JSON-compatible dict.
- class helix_ir.schema.Path(segments: tuple[PathSegment, ...])[source]¶
Bases:
objectImmutable dotted path into a nested schema.
Examples
Path.parse(“customer.address.city”) Path.parse(“items[].sku”)
- segments: tuple[PathSegment, ...]¶
- classmethod parse(path: str) Path[source]¶
Parse a dotted path string into a Path.
- Supports:
“customer.address.city” “items[].sku” “items[].tags[]”
- is_descendant_of(other: Path) bool[source]¶
Return True if self is a descendant (longer) path of other.
- ROOT = Path(segments=())¶
- class helix_ir.schema.PathSegment(kind: str, name: str | None = None)[source]¶
Bases:
objectA single segment of a schema path.
kind=’field’ with name=’foo’ represents a struct field named ‘foo’. kind=’array_element’ represents descending into an array’s element type.