Skip to content

Commit b6349a4

Browse files
Add support for configurable catalog/schema for dashboards (#4130)
## Changes Support passing the `dataset_catalog` and `dataset_schema` fields for dashboards. Example: ``` resources: dashboards: my_dashboard: display_name: NYC Taxi warehouse_id: ${var.sql_warehouse_id} file_path: "sample-dashboard.lvdash.json" embed_credentials: true # Sets the default catalog/schema for all datasets in this dashboard. # Does not impact table references that use fully qualified catalog names (ex: samples.nyctaxi.trips). # Leave blank to keep each dataset’s existing configuration. dataset_catalog: main dataset_schema: default ``` ## Tests New acceptance tests. --------- Co-authored-by: Pieter Noordhuis <[email protected]>
1 parent 2141440 commit b6349a4

File tree

19 files changed

+348
-19
lines changed

19 files changed

+348
-19
lines changed

NEXT_CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
### CLI
88

99
### Bundles
10+
* Add support for configurable catalog/schema for dashboards ([#4130](https://github.com/databricks/cli/pull/4130))
1011
* engine/direct: Fix dependency-ordered deletion by persisting depends_on in state ([#4105](https://github.com/databricks/cli/pull/4105))
1112
* Pass SYSTEM_ACCESSTOKEN from env to the Terraform provider ([#4135](https://github.com/databricks/cli/pull/4135)
1213

acceptance/bundle/refschema/out.fields.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,8 @@ resources.clusters.*.permissions.permissions[*].service_principal_name string AL
424424
resources.clusters.*.permissions.permissions[*].user_name string ALL
425425
resources.dashboards.*.create_time string ALL
426426
resources.dashboards.*.dashboard_id string ALL
427+
resources.dashboards.*.dataset_catalog string ALL
428+
resources.dashboards.*.dataset_schema string ALL
427429
resources.dashboards.*.display_name string ALL
428430
resources.dashboards.*.embed_credentials bool ALL
429431
resources.dashboards.*.etag string ALL
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#
2+
# Acceptance test for deploying dashboards with dataset_catalog and dataset_schema.
3+
# These fields override the catalog/schema for all datasets in the dashboard.
4+
#
5+
bundle:
6+
name: deploy-dashboard-dataset-test-$UNIQUE_NAME
7+
8+
resources:
9+
dashboards:
10+
dashboard1:
11+
display_name: $DASHBOARD_DISPLAY_NAME
12+
warehouse_id: $TEST_DEFAULT_WAREHOUSE_ID
13+
embed_credentials: true
14+
dataset_catalog: main
15+
dataset_schema: default
16+
file_path: "sample-dashboard.lvdash.json"
17+
parent_path: /Users/$CURRENT_USER_NAME
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
{
2+
"plan_version": 1,
3+
"cli_version": "[DEV_VERSION]",
4+
"plan": {
5+
"resources.dashboards.dashboard1": {
6+
"action": "skip",
7+
"remote_state": {
8+
"create_time": "[TIMESTAMP]",
9+
"dashboard_id": "[DASHBOARD_ID]",
10+
"display_name": "test bundle-deploy-dashboard-dataset [UUID]",
11+
"embed_credentials": true,
12+
"etag": [ETAG],
13+
"lifecycle_state": "ACTIVE",
14+
"parent_path": "/Workspace/Users/[USERNAME]",
15+
"path": "/Users/[USERNAME]/test bundle-deploy-dashboard-dataset [UUID].lvdash.json",
16+
"serialized_dashboard": "[SERIALIZED_FIXTURE]",
17+
"update_time": "[TIMESTAMP]",
18+
"warehouse_id": "[TEST_DEFAULT_WAREHOUSE_ID]"
19+
},
20+
"changes": {
21+
"local": {
22+
"etag": {
23+
"action": "skip",
24+
"old": [ETAG]
25+
}
26+
},
27+
"remote": {
28+
"dataset_catalog": {
29+
"action": "skip",
30+
"old": "main"
31+
},
32+
"dataset_schema": {
33+
"action": "skip",
34+
"old": "default"
35+
},
36+
"serialized_dashboard": {
37+
"action": "skip",
38+
"old": "[SERIALIZED_FIXTURE_OLD]",
39+
"new": "[SERIALIZED_FIXTURE_NEW]"
40+
}
41+
}
42+
}
43+
}
44+
}
45+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"plan_version": 1,
3+
"cli_version": "[DEV_VERSION]",
4+
"plan": {
5+
"resources.dashboards.dashboard1": {
6+
"action": "skip"
7+
}
8+
}
9+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"method": "POST",
3+
"path": "/api/2.0/lakeview/dashboards",
4+
"q": {
5+
"dataset_catalog": "main",
6+
"dataset_schema": "default"
7+
},
8+
"body": {
9+
"display_name": "test bundle-deploy-dashboard-dataset [UUID]",
10+
"parent_path": "/Workspace/Users/[USERNAME]",
11+
"serialized_dashboard": "{\n \"pages\": [\n {\n \"name\": \"test_page\",\n \"displayName\": \"Test Page\",\n \"pageType\": \"PAGE_TYPE_CANVAS\"\n }\n ],\n \"datasets\": [\n {\n \"name\": \"bf8f76f4\",\n \"displayName\": \"Test Dataset\",\n \"queryLines\": [\n \"SELECT 1\\n\"\n ],\n \"catalog\": \"foobar\",\n \"schema\": \"foobar\"\n }\n ]\n}\n",
12+
"warehouse_id": "[TEST_DEFAULT_WAREHOUSE_ID]"
13+
}
14+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"method": "POST",
3+
"path": "/api/2.0/lakeview/dashboards",
4+
"q": {
5+
"dataset_catalog": "main",
6+
"dataset_schema": "default"
7+
},
8+
"body": {
9+
"display_name": "test bundle-deploy-dashboard-dataset [UUID]",
10+
"parent_path": "/Workspace/Users/[USERNAME]",
11+
"serialized_dashboard": "{\n \"pages\": [\n {\n \"name\": \"test_page\",\n \"displayName\": \"Test Page\",\n \"pageType\": \"PAGE_TYPE_CANVAS\"\n }\n ],\n \"datasets\": [\n {\n \"name\": \"bf8f76f4\",\n \"displayName\": \"Test Dataset\",\n \"queryLines\": [\n \"SELECT 1\\n\"\n ],\n \"catalog\": \"foobar\",\n \"schema\": \"foobar\"\n }\n ]\n}\n",
12+
"warehouse_id": "[TEST_DEFAULT_WAREHOUSE_ID]"
13+
}
14+
}

acceptance/bundle/resources/dashboards/dataset-catalog-schema/out.test.toml

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
2+
>>> [CLI] bundle deploy
3+
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/deploy-dashboard-dataset-test-[UNIQUE_NAME]/default/files...
4+
Deploying resources...
5+
Updating deployment state...
6+
Deployment complete!
7+
8+
>>> [CLI] lakeview get [DASHBOARD_ID]
9+
{
10+
"lifecycle_state": "ACTIVE",
11+
"parent_path": "/Users/[USERNAME]",
12+
"path": "/Users/[USERNAME]/test bundle-deploy-dashboard-dataset [UUID].lvdash.json"
13+
}
14+
15+
>>> [CLI] lakeview get [DASHBOARD_ID]
16+
{
17+
"catalog": "main",
18+
"schema": "default"
19+
}
20+
21+
>>> [CLI] bundle plan -o json
22+
23+
>>> [CLI] bundle destroy --auto-approve
24+
The following resources will be deleted:
25+
delete resources.dashboards.dashboard1
26+
27+
All files and directories at the following location will be deleted: /Workspace/Users/[USERNAME]/.bundle/deploy-dashboard-dataset-test-[UNIQUE_NAME]/default
28+
29+
Deleting files...
30+
Destroy complete!
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"pages": [
3+
{
4+
"name": "test_page",
5+
"displayName": "Test Page",
6+
"pageType": "PAGE_TYPE_CANVAS"
7+
}
8+
],
9+
"datasets": [
10+
{
11+
"name": "bf8f76f4",
12+
"displayName": "Test Dataset",
13+
"queryLines": [
14+
"SELECT 1\n"
15+
],
16+
"catalog": "foobar",
17+
"schema": "foobar"
18+
}
19+
]
20+
}

0 commit comments

Comments
 (0)