haive.core.schema.compatibility.field_mapping

Advanced field mapping with path resolution and transformations.

Classes

FieldMapper

Manages field mappings between schemas.

FieldMapping

Represents a mapping between fields with transformation.

Functions

create_mapping(mappings[, computed_fields])

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:
Return type:

FieldMapping

add_computed_field(target, generator, condition=None)[source]

Add a computed field with no source.

Parameters:
Return type:

FieldMapping

add_mapping(source, target, transformer=None, condition=None, default=None, validator=None)[source]

Add a field mapping.

Parameters:
Return type:

FieldMapping

get_mapping_for_target(target_field)[source]

Get mapping for a target field.

Parameters:

target_field (str)

Return type:

FieldMapping | None

get_targets_for_source(source_field)[source]

Get all target fields that use a source field.

Parameters:

source_field (str)

Return type:

set[str]

map_data(source_data, target_fields=None, include_unmapped=False, context=None)[source]

Map source data to target schema.

Parameters:
Returns:

Mapped data dictionary

Return type:

dict[str, Any]

to_dict()[source]

Export mappings as dictionary.

Return type:

dict[str, dict[str, Any]]

validate_mappings(source_fields, target_fields)[source]

Validate that mappings are complete and valid.

Returns:

Tuple of (is_valid, issues)

Parameters:
Return type:

tuple[bool, list[str]]

class haive.core.schema.compatibility.field_mapping.FieldMapping[source]

Represents a mapping between fields with transformation.

apply(source_data)[source]

Apply mapping to source data.

Returns:

Tuple of (success, value)

Parameters:

source_data (dict[str, Any])

Return type:

tuple[bool, Any]

haive.core.schema.compatibility.field_mapping.create_mapping(mappings, computed_fields=None)[source]

Create a field mapper from simple mapping dict.

Parameters:
Return type:

FieldMapper