Hi I want to get the downstream lineage of the dat...
# getting-started
l
Hi I want to get the downstream lineage of the dataset using python SDK. I tried below code to fetch upstream but dont find a way to get the downstream table / list ( a.ka. right side of dataset) .
Copy code
from datahub.ingestion.graph.client import DatahubClientConfig, DataHubGraph
from datahub.metadata.schema_classes import SchemaMetadataClass
from datahub.metadata.schema_classes import UpstreamLineageClass
table_urn = "urn:li:dataset:(urn:li:dataPlatform:looker,Revenue_SOX.explore.payments_promos_SOX,PROD)"
graph = DataHubGraph(DatahubClientConfig(server=gms_server , token= datahub_gms_api_token))
current_schema_metadata = graph.get_aspect(
    entity_urn=table_urn,
    aspect_type=UpstreamLineageClass)
l
Hey there 👋 I'm The DataHub Community Support bot. I'm here to help make sure the community can best support you with your request. Let's double check a few things first: 1️⃣ There's a lot of good information on our docs site: www.datahubproject.io/docs, Have you searched there for a solution? Yes button ✅ It's not uncommon that someone has run into your exact problem before in the community. Have you searched Slack for similar issues? ✅ button
m
Copy code
from datahub.ingestion.graph.client import get_default_graph, DataHubGraph
import sys

if __name__ == "__main__":
    dataset_urn = sys.argv[1]
    graph: DataHubGraph
    with get_default_graph() as graph:
        print("Downstream entities")
        for entity in graph.get_related_entities(dataset_urn, relationship_types=["DownstreamOf"], direction=DataHubGraph.RelationshipDirection.INCOMING):
            print(entity)
this should work
l
Thank you so much @mammoth-bear-12532