This PR adds the AttributeMapping dataclass and functions for creating and deleting, as well as getting all attribute mappings from a project.
Important note: This implementation memo-izes fetched Attributes when making the get_all call. This should probably be inspected closely.
Open questions:
Should this dataclass live in tamr_client._types.project? (currently here)
Should this module live at tamr_client.schema_mapping.attribute_mapping? (currently here)
If so, should it be hoisted to be accessible at tamr_client.attribute_mapping? (currently not happening)
Closes #479
💻 Examples
import tamr_client as tc
my_project = Project(...) # my Tamr project
my_input_attr = Attribute(...) # an existing attribute of an input dataset of `project`
my_unified_attr = Attribute(...) # an existing attribute of the unified dataset of `project`
# Create a new attribute mapping
new_attr_mapping = tc.schema_mapping.attribute_mapping.create(my_project, input_attribute=my_input_attr, unified_attribute=my_unified_attr)
# Get all attribute mappings of my project
all_attr_mappings = tc.schema_mapping.attribute_mapping.get_all(my_project) # this is a list
print(new_attr_mapping in all_attr_mappings) # my new mapping should be in there
# Delete my attribute mapping
tc.schema_mapping.attribute_mapping.delete(new_attr_mapping)
# Extension: I want to completely unmap `my_input_attr`
for mapping in tc.schema_mapping.attribute_mapping.get_all(my_project):
if mapping.input_attribute_url == my_input_attr.url:
tc.schema_mapping.attribute_mapping.delete(mapping)
↪️ Pull Request
This PR adds the
AttributeMapping
dataclass and functions for creating and deleting, as well as getting all attribute mappings from a project.Important note: This implementation memo-izes fetched
Attributes
when making theget_all
call. This should probably be inspected closely.Open questions:
tamr_client._types.project
? (currently here)tamr_client.schema_mapping.attribute_mapping
? (currently here)tamr_client.attribute_mapping
? (currently not happening)Closes #479
💻 Examples
✔️ PR Todo