From f1c6011dbbefc2645d42a1ce5a2b373196a9f3fe Mon Sep 17 00:00:00 2001 From: Allison Suarez Miranda <22477579+allisonsuarez@users.noreply.github.com> Date: Tue, 23 Feb 2021 14:46:08 -0800 Subject: [PATCH] feat: added lineage item and lineage entities (#90) * added lineage item and lineage entities Signed-off-by: Allison Suarez Miranda * lint fixes Signed-off-by: Allison Suarez Miranda * added BAdge for badge list Signed-off-by: Allison Suarez Miranda * small change to lineage schema Signed-off-by: Allison Suarez Miranda * whitespace Signed-off-by: Allison Suarez Miranda * rename Signed-off-by: Allison Suarez Miranda --- amundsen_common/models/lineage.py | 37 +++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 amundsen_common/models/lineage.py 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