Skip to content

Commit

Permalink
feat: dbt lineage command can find all non-localized dashboards
Browse files Browse the repository at this point in the history
  • Loading branch information
bmtcril committed Jun 14, 2024
1 parent ea7b48f commit 1a98712
Showing 1 changed file with 17 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
"""
Parse all Superset datasets for SQL, find links back to dbt assets.
This is used in aspects-dbt to update the exposures.
This is used in aspects-dbt to update the exposures. Significant parts of this
are from the dbt_superset_lineage package at:
https://github.com/slidoapp/dbt-superset-lineage/
"""

# Necessary to access Superset
Expand Down Expand Up @@ -173,19 +175,27 @@ def collect_dbt_lineage():
dbt_tables = get_tables_from_dbt()

target_dashboards = {{SUPERSET_EMBEDDABLE_DASHBOARDS}}
locale_suffixes = [
f"-{loc}"
for loc in {{SUPERSET_DASHBOARD_LOCALES}}
]

dashboards = (
db.session.query(Dashboard)
.filter(Dashboard.slug.in_(target_dashboards))
.all()
)
dashboards = (db.session.query(Dashboard).all())

if not dashboards:
logger.warning(f"No dashboard found!")

exposure_dashboards = []
for dashboard in dashboards:
exposure_dashboards.append(get_dashboard_dict(dashboard, dbt_tables))
localized = False
for locale_suffix in locale_suffixes:
if dashboard.slug.endswith(locale_suffix):
print(f"{dashboard.slug} is localized, skipping")
localized = True
break

if not localized:
exposure_dashboards.append(get_dashboard_dict(dashboard, dbt_tables))

write_exposures_yaml(exposure_dashboards)

Expand Down

0 comments on commit 1a98712

Please sign in to comment.