Skip to content

Commit

Permalink
feat(ingest/dbt): support "Explore" page in dbt cloud
Browse files Browse the repository at this point in the history
  • Loading branch information
hsheth2 committed Dec 24, 2024
1 parent 756b199 commit 931e080
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions metadata-ingestion/src/datahub/ingestion/source/dbt/dbt_cloud.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import logging
from datetime import datetime
from json import JSONDecodeError
from typing import Dict, List, Optional, Tuple
from typing import Dict, List, Literal, Optional, Tuple
from urllib.parse import urlparse

import dateutil.parser
Expand Down Expand Up @@ -62,6 +62,11 @@ class DBTCloudConfig(DBTCommonConfig):
description="The ID of the run to ingest metadata from. If not specified, we'll default to the latest run.",
)

external_url_mode: Literal["explore", "develop"] = Field(
default="explore",
description='Where should the "View in dbt" link point to - either the "Explore" UI or the dbt Cloud IDE',
)

@root_validator(pre=True)
def set_metadata_endpoint(cls, values: dict) -> dict:
if values.get("access_url") and not values.get("metadata_endpoint"):
Expand Down Expand Up @@ -527,5 +532,7 @@ def _parse_into_dbt_column(
)

def get_external_url(self, node: DBTNode) -> Optional[str]:
# TODO: Once dbt Cloud supports deep linking to specific files, we can use that.
return f"{self.config.access_url}/develop/{self.config.account_id}/projects/{self.config.project_id}"
if self.config.external_url_mode == "explore":
return f"{self.config.access_url}/explore/{self.config.account_id}/projects/{self.config.project_id}/environments/production/details/{node.dbt_name}"
else:
return f"{self.config.access_url}/develop/{self.config.account_id}/projects/{self.config.project_id}"

0 comments on commit 931e080

Please sign in to comment.