Area: Product
Sub-Area: CI/CD Integration
Applies to: OSS + Cloud
Issue
Development teams want to use DataHub's impact analysis in GitHub Actions workflows. They want to check the downstream impact of code changes, such as dbt model changes, before they merge a pull request.
You Might Be Asking
- Is there a GitHub Action for DataHub impact analysis?
- How can I query downstream impact from a CI job?
- Can I get downstream lineage from the GraphQL API?
Cause
DataHub lists a GitHub Action for dbt change impact analysis. For other sources, you query lineage through the GraphQL API from your own workflow step.
Solution
Option 1: dbt impact action
DataHub's ecosystem page lists acryldata/dbt-impact-action as the "GitHub Action for dbt change impact analysis": acryldata/dbt-impact-action.
Take the version ref and the with: inputs from that repository's README. Do not copy them from older examples.
Option 2: query lineage from the GraphQL API
Send requests to the /api/graphql endpoint. See the GraphQL API overview.
Authenticate with a DataHub personal access token. Send it in the header Authorization: Bearer <token>.
To create a token:
- Make sure Metadata Service Authentication is enabled in GMS.
- Make sure you have the
Generate Personal Access TokensorManage All Access Tokensprivilege through a DataHub Policy. - Go to Settings > Access Tokens and select Generate Personal Access Token.
Store the token as a secret in your CI system. See Using Personal Access Tokens.
For one hop of downstream lineage, use the lineage field. Dataset supports it.
query {
entity(urn: "<dataset urn>") {
... on Dataset {
lineage(input: { direction: DOWNSTREAM, start: 0, count: 100 }) {
total
relationships {
type
degree
entity {
urn
type
}
}
}
}
}
}
direction takes UPSTREAM or DOWNSTREAM. The result has start, count, total and relationships. Each relationship has type, entity and degree.
For more than one hop, use searchAcrossLineage or scrollAcrossLineage. Both are in the DataHub Cloud v2.4.4 GraphQL schema.
Your own script must define its dataset URN, URL and token values, parse the response relationships list, and post results to the pull request.
Additional Notes
- Impact analysis only reflects lineage that is already in DataHub. Keep lineage ingestion current.
- For dbt, DataHub links each dbt node to its warehouse table automatically when URNs match. See the dbt source docs.