Skip to content

Commit 6430e79

Browse files
authored
Add support for lakebase catalog (#3436)
## Changes <!-- Brief summary of your changes that is easy to understand --> Added support for creating Lakebase database catalogs in DABs ## Why <!-- Why are these changes needed? Provide the context that the reviewer might be missing. For example, were there any decisions behind the change that are not reflected in the code itself? --> This change allows users to define database catalogs as part of their assets bundle: ``` ... resources: ... database_instances: my_database_instance: name: my_database_instance capacity: CU_1 database_catalogs: my_catalog: database_instance_name: ${resources.database_instances.my_instance.name} database_name: "my_database" name: my_catalog_$UNIQUE_NAME create_database_if_not_exists: true ``` ## Tests <!-- How have you tested the changes? --> Added acceptance tests for database instances deployments <!-- If your PR needs to be included in the release notes for next release, add a separate entry in NEXT_CHANGELOG.md as part of your PR. -->
1 parent 3d64cc0 commit 6430e79

File tree

22 files changed

+379
-6
lines changed

22 files changed

+379
-6
lines changed

NEXT_CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
### Bundles
1414
* Add support for Lakebase database instances in DABs ([#3283](https://github.com/databricks/cli/pull/3283))
15+
* Add support for Lakebase database catalogs in DABs ([#3436](https://github.com/databricks/cli/pull/3436))
1516
* Improve error message for SDK/API errors ([#3379](https://github.com/databricks/cli/pull/3379))
1617

1718
### API Changes
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
bundle:
2+
name: deploy-lakebase-catalog-$UNIQUE_NAME
3+
4+
resources:
5+
database_instances:
6+
my_instance:
7+
name: test-database-instance-$UNIQUE_NAME
8+
capacity: CU_1
9+
database_catalogs:
10+
my_catalog:
11+
database_instance_name: ${resources.database_instances.my_instance.name}
12+
database_name: "my_database"
13+
name: my_catalog_$UNIQUE_NAME
14+
create_database_if_not_exists: true
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Local = true
2+
Cloud = true
3+
RequiresUnityCatalog = true
4+
5+
[CloudEnvs]
6+
gcp = false
7+
8+
[EnvMatrix]
9+
DATABRICKS_CLI_DEPLOYMENT = ["terraform"]
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
2+
>>> [CLI] bundle validate
3+
Name: deploy-lakebase-catalog-[UNIQUE_NAME]
4+
Target: default
5+
Workspace:
6+
User: [USERNAME]
7+
Path: /Workspace/Users/[USERNAME]/.bundle/deploy-lakebase-catalog-[UNIQUE_NAME]/default
8+
9+
Validation OK!
10+
11+
>>> [CLI] bundle summary
12+
Name: deploy-lakebase-catalog-[UNIQUE_NAME]
13+
Target: default
14+
Workspace:
15+
User: [USERNAME]
16+
Path: /Workspace/Users/[USERNAME]/.bundle/deploy-lakebase-catalog-[UNIQUE_NAME]/default
17+
Resources:
18+
Database catalogs:
19+
my_catalog:
20+
Name: my_catalog_[UNIQUE_NAME]
21+
Database instances:
22+
my_instance:
23+
Name: test-database-instance-[UNIQUE_NAME]
24+
25+
>>> [CLI] bundle deploy
26+
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/deploy-lakebase-catalog-[UNIQUE_NAME]/default/files...
27+
Deploying resources...
28+
Updating deployment state...
29+
Deployment complete!
30+
31+
>>> [CLI] database get-database-instance test-database-instance-[UNIQUE_NAME]
32+
{
33+
"capacity": "CU_1",
34+
"creation_time": "[TIMESTAMP]Z",
35+
"creator": "[USERNAME]",
36+
"effective_enable_readable_secondaries": false,
37+
"effective_node_count": 1,
38+
"effective_retention_window_in_days": 7,
39+
"effective_stopped": false,
40+
"name": "test-database-instance-[UNIQUE_NAME]",
41+
"pg_version": "PG_VERSION_16",
42+
"state": "AVAILABLE",
43+
"uid": "[UUID]"
44+
}
45+
46+
>>> [CLI] bundle summary
47+
Name: deploy-lakebase-catalog-[UNIQUE_NAME]
48+
Target: default
49+
Workspace:
50+
User: [USERNAME]
51+
Path: /Workspace/Users/[USERNAME]/.bundle/deploy-lakebase-catalog-[UNIQUE_NAME]/default
52+
Resources:
53+
Database catalogs:
54+
my_catalog:
55+
Name: my_catalog_[UNIQUE_NAME]
56+
Database instances:
57+
my_instance:
58+
Name: test-database-instance-[UNIQUE_NAME]
59+
60+
>>> [CLI] bundle destroy --auto-approve
61+
The following resources will be deleted:
62+
delete database_catalog my_catalog
63+
delete database_instance my_instance
64+
65+
All files and directories at the following location will be deleted: /Workspace/Users/[USERNAME]/.bundle/deploy-lakebase-catalog-[UNIQUE_NAME]/default
66+
67+
Deleting files...
68+
Destroy complete!
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
envsubst < databricks.yml.tmpl > databricks.yml
2+
3+
cleanup() {
4+
trace $CLI bundle destroy --auto-approve
5+
}
6+
trap cleanup EXIT
7+
8+
trace $CLI bundle validate
9+
10+
# URL is excluded because some cloud envs add an ?0= query param and some don't
11+
trace $CLI bundle summary | grep -v "URL"
12+
trace $CLI bundle deploy
13+
# _dns fields are excluded since they differ between cloud envs
14+
trace $CLI database get-database-instance "test-database-instance-${UNIQUE_NAME}" | jq 'del(.read_only_dns, .read_write_dns)'
15+
trace $CLI bundle summary | grep -v "URL"
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Local = true
2+
Cloud = true
3+
4+
RecordRequests = false
5+
6+
[EnvMatrix]
7+
DATABRICKS_CLI_DEPLOYMENT = ["terraform"]

acceptance/bundle/deploy/lakebase/database-instance/single-instance/test.toml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
Local = true
22
Cloud = true
33

4-
RecordRequests = false
5-
RequiresUnityCatalog = true
6-
CloudEnvs.gcp = false # lakebase is not available in GCP as of August 2025
7-
84
Ignore = [
95
"databricks.yml",
106
]
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
RequiresUnityCatalog = true
2+
CloudEnvs.gcp = false # lakebase is not available in GCP as of August 2025

acceptance/internal/handlers.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -514,4 +514,16 @@ func addDefaultHandlers(server *testserver.Server) {
514514
server.Handle("DELETE", "/api/2.0/database/instances/{name}", func(req testserver.Request) any {
515515
return testserver.DatabaseInstanceMapDelete(req)
516516
})
517+
518+
server.Handle("POST", "/api/2.0/database/catalogs", func(req testserver.Request) any {
519+
return req.Workspace.DatabaseCatalogCreate(req)
520+
})
521+
522+
server.Handle("GET", "/api/2.0/database/catalogs/{name}", func(req testserver.Request) any {
523+
return testserver.MapGet(req.Workspace, req.Workspace.DatabaseCatalogs, req.Vars["name"])
524+
})
525+
526+
server.Handle("DELETE", "/api/2.0/database/catalogs/{name}", func(req testserver.Request) any {
527+
return testserver.MapDelete(req.Workspace, req.Workspace.DatabaseCatalogs, req.Vars["name"])
528+
})
517529
}

bundle/config/mutator/resourcemutator/apply_bundle_permissions.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import (
1515
"github.com/databricks/cli/libs/dyn/convert"
1616
)
1717

18-
var unsupportedResources = []string{"clusters", "volumes", "schemas", "quality_monitors", "registered_models"}
18+
var unsupportedResources = []string{"clusters", "volumes", "schemas", "quality_monitors", "registered_models", "database_catalogs"}
1919

2020
var (
2121
allowedLevels = []string{permissions.CAN_MANAGE, permissions.CAN_VIEW, permissions.CAN_RUN}

0 commit comments

Comments
 (0)