Skip to content

Commit

Permalink
Add replace catalog functionality to create-dashboard command
Browse files Browse the repository at this point in the history
  • Loading branch information
JCZuurmond committed Jul 10, 2024
1 parent 15a23a8 commit cba91fe
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 4 additions & 0 deletions labs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ commands:
flags:
- name: folder
description: The folder with dashboard files. By default, the current working directory.
- name: catalog
description: |
Overwrite the catalog in query with given value. Useful when developing with seperated catalogs, for
example, for production and development.
- name: database
description: |
Overwrite the database in query with given value. Useful when developing with seperated databases, for
Expand Down
7 changes: 4 additions & 3 deletions src/databricks/labs/lsql/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,17 @@ def create_dashboard(
w: WorkspaceClient,
folder: Path = Path.cwd(),
*,
catalog: str = "",
database: str = "",
no_open: bool = False,
):
"""Create a dashboard from queries"""
logger.debug("Creating dashboard ...")
lakeview_dashboards = Dashboards(w)
folder = Path(folder)
dashboard_metadata = DashboardMetadata.from_path(folder)
if database:
dashboard_metadata = dashboard_metadata.replace_database(database)
dashboard_metadata = DashboardMetadata.from_path(folder).replace_database(
catalog=catalog or None, database=database or None
)
lakeview_dashboard = lakeview_dashboards.create_dashboard(dashboard_metadata)
sdk_dashboard = lakeview_dashboards.deploy_dashboard(lakeview_dashboard)
dashboard_url = f"{w.config.host}/sql/dashboardsv3/{sdk_dashboard.dashboard_id}"
Expand Down

0 comments on commit cba91fe

Please sign in to comment.