haive.core.schema.compatibility.field_mapping¶
Advanced field mapping with path resolution and transformations.
Classes¶
Manages field mappings between schemas. |
|
Represents a mapping between fields with transformation. |
Functions¶
|
Create a field mapper from simple mapping dict. |
Module Contents¶
- class haive.core.schema.compatibility.field_mapping.FieldMapper[source]¶
Manages field mappings between schemas.
Init .
- Returns:
Add return description]
- Return type:
[TODO
- add_aggregate_field(sources, target, aggregator, default=None)[source]¶
Add an aggregate field from multiple sources.
- Parameters:
target (str)
aggregator (collections.abc.Callable[[list[Any]], Any])
default (Any)
- Return type:
- add_computed_field(target, generator, condition=None)[source]¶
Add a computed field with no source.
- Parameters:
target (str)
generator (collections.abc.Callable[[], Any])
condition (collections.abc.Callable[[dict[str, Any]], bool] | None)
- Return type:
- add_mapping(source, target, transformer=None, condition=None, default=None, validator=None)[source]¶
Add a field mapping.
- Parameters:
target (str)
transformer (collections.abc.Callable[[Any], Any] | None)
condition (collections.abc.Callable[[dict[str, Any]], bool] | None)
default (Any)
validator (collections.abc.Callable[[Any], bool] | None)
- Return type:
- get_mapping_for_target(target_field)[source]¶
Get mapping for a target field.
- Parameters:
target_field (str)
- Return type:
FieldMapping | None
- class haive.core.schema.compatibility.field_mapping.FieldMapping[source]¶
Represents a mapping between fields with transformation.
- haive.core.schema.compatibility.field_mapping.create_mapping(mappings, computed_fields=None)[source]¶
Create a field mapper from simple mapping dict.
- Parameters:
mappings (dict[str, str | tuple[str, collections.abc.Callable]]) – Dict of target -> source or (source, transformer)
computed_fields (dict[str, collections.abc.Callable] | None) – Dict of target -> generator function
- Return type: