Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ingest): ingest deleted looker dashboards #3158

Merged
merged 1 commit into from
Sep 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions metadata-ingestion/source_docs/looker.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ Note that a `.` is used to denote nested fields in the YAML recipe.
| `chart_pattern.allow` | | | List of regex patterns for charts to include in ingestion. |
| `chart_pattern.deny` | | | List of regex patterns for charts to exclude from ingestion. |
| `chart_pattern.ignoreCase` | | `True` | Whether to ignore case sensitivity during pattern matching. |
| `include_deleted` | | `False` | Whether to include deleted dashboards. |
| `env` | | `"PROD"` | Environment to use in namespace when constructing URNs. |

## Compatibility
Expand Down
11 changes: 7 additions & 4 deletions metadata-ingestion/src/datahub/ingestion/source/looker.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class LookerDashboardSourceConfig(ConfigModel):
actor: str = "urn:li:corpuser:etl"
dashboard_pattern: AllowDenyPattern = AllowDenyPattern.allow_all()
chart_pattern: AllowDenyPattern = AllowDenyPattern.allow_all()
include_deleted: bool = False
env: str = builder.DEFAULT_ENV


Expand Down Expand Up @@ -376,8 +377,8 @@ def _get_looker_dashboard(self, dashboard: Dashboard) -> LookerDashboard:
description=dashboard.description,
dashboard_elements=dashboard_elements,
created_at=dashboard.created_at,
is_deleted=dashboard.deleted if dashboard.deleted is not None else False,
is_hidden=dashboard.deleted if dashboard.deleted is not None else False,
is_deleted=dashboard.deleted,
is_hidden=dashboard.deleted,
)
return looker_dashboard

Expand All @@ -397,9 +398,11 @@ def _get_looker_client(self):

def get_workunits(self) -> Iterable[MetadataWorkUnit]:
client = self._get_looker_client()
dashboards = client.all_dashboards(fields="id")
deleted_dashboards = client.search_dashboards(fields="id", deleted="true") if self.source_config.include_deleted else []
dashboard_ids = [
dashboard_base.id
for dashboard_base in client.all_dashboards(fields="id")
for dashboard_base in dashboards + deleted_dashboards
if dashboard_base.id is not None
]

Expand All @@ -409,7 +412,7 @@ def get_workunits(self) -> Iterable[MetadataWorkUnit]:
self.reporter.report_dashboards_dropped(dashboard_id)
continue
try:
fields = ["id", "title", "dashboard_elements", "dashboard_filters"]
fields = ["id", "title", "dashboard_elements", "dashboard_filters", "deleted"]
dashboard_object = client.dashboard(
dashboard_id=dashboard_id, fields=",".join(fields)
)
Expand Down