diff --git a/amundsen_common/models/lineage.py b/amundsen_common/models/lineage.py new file mode 100644 index 0000000..1f0e24d --- /dev/null +++ b/amundsen_common/models/lineage.py @@ -0,0 +1,37 @@ +# Copyright Contributors to the Amundsen project. +# SPDX-License-Identifier: Apache-2.0 + +from typing import Optional, List + +from amundsen_common.models.table import Badge + +import attr +from marshmallow_annotations.ext.attrs import AttrsSchema + + +@attr.s(auto_attribs=True, kw_only=True) +class LineageItem: + key: str # down/upstream table/col/task key + level: int # upstream/downstream distance from current resource + source: str # database this resource is from + badges: Optional[List[Badge]] = None + usage: Optional[int] = None # statistic to sort lineage items by + + +class LineageItemSchema(AttrsSchema): + target = LineageItem + register_as_scheme = True + + +@attr.s(auto_attribs=True, kw_only=True) +class Lineage: + key: str # current table/col/task key + direction: str # upstream/downstream/both + depth: int # how many levels up/down 0 == all + upstream_entities: List[LineageItem] # list of upstream entities + downstream_entities: List[LineageItem] # list of downstream entities + + +class LineageSchema(AttrsSchema): + target = Lineage + register_as_scheme = True