Skip to content
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
bundle:
name: deploy-lakebase-catalog-recreate-$UNIQUE_NAME

resources:
database_instances:
my_instance:
name: test-db-catalog-recreate-$UNIQUE_NAME
capacity: CU_1
database_catalogs:
my_catalog:
database_instance_name: ${resources.database_instances.my_instance.name}
database_name: DBNAME_PLACEHOLDER
name: my_catalog_$UNIQUE_NAME
create_database_if_not_exists: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"method": "DELETE",
"path": "/api/2.0/database/catalogs/my_catalog_[UNIQUE_NAME]"
}
{
"body": {
"create_database_if_not_exists": true,
"database_instance_name": "test-db-catalog-recreate-[UNIQUE_NAME]",
"database_name": "my_database_v2",
"name": "my_catalog_[UNIQUE_NAME]"
},
"method": "POST",
"path": "/api/2.0/database/catalogs"
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 32 additions & 0 deletions acceptance/bundle/resources/database_catalogs/recreate/output.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@

>>> [CLI] bundle deploy
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/deploy-lakebase-catalog-recreate-[UNIQUE_NAME]/default/files...
Deploying resources...
Updating deployment state...
Deployment complete!

=== Change an immutable catalog field: no update API, so the plan recreates it
>>> [CLI] bundle plan
recreate database_catalogs.my_catalog

Plan: 1 to add, 0 to change, 1 to delete, 1 unchanged

>>> [CLI] bundle deploy --auto-approve
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/deploy-lakebase-catalog-recreate-[UNIQUE_NAME]/default/files...
Deploying resources...
Updating deployment state...
Deployment complete!
Comment thread
pietern marked this conversation as resolved.

>>> [CLI] bundle destroy --auto-approve
The following resources will be deleted:
delete resources.database_catalogs.my_catalog
delete resources.database_instances.my_instance

This action will result in the deletion of the following Lakebase database instances.
All data stored in them will be permanently lost:
delete resources.database_instances.my_instance

All files and directories at the following location will be deleted: /Workspace/Users/[USERNAME]/.bundle/deploy-lakebase-catalog-recreate-[UNIQUE_NAME]/default

Deleting files...
Destroy complete!
22 changes: 22 additions & 0 deletions acceptance/bundle/resources/database_catalogs/recreate/script
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
cleanup() {
trace $CLI bundle destroy --auto-approve
rm -f out.requests.txt
}
trap cleanup EXIT

envsubst < databricks.yml.tmpl | sed "s/DBNAME_PLACEHOLDER/my_database/" > databricks.yml

trace $CLI bundle deploy
rm -f out.requests.txt

title "Change an immutable catalog field: no update API, so the plan recreates it"
sed "s/my_database/my_database_v2/" databricks.yml > databricks.yml.new
mv databricks.yml.new databricks.yml

trace $CLI bundle plan
trace $CLI bundle deploy --auto-approve

# The change must be a DELETE of the old catalog plus a POST creating the new
# one. A PATCH would return 501 (the bug this guards against).
jq --sort-keys 'select(.method != "GET" and (.path | contains("/database/catalogs")))' < out.requests.txt > out.requests.recreate.txt
rm -f out.requests.txt
10 changes: 10 additions & 0 deletions acceptance/bundle/resources/database_catalogs/recreate/test.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# The Database API has no UpdateDatabaseCatalog endpoint (PATCH returns 501), so
# any field change must go through delete + create. The direct engine handles
# this; the terraform path would need an upstream provider fix and is excluded.
EnvMatrix.DATABRICKS_BUNDLE_ENGINE = ["direct"]
RecordRequests = true

Ignore = [
"databricks.yml",
".databricks",
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
bundle:
name: deploy-lakebase-recreate-$UNIQUE_NAME

sync:
paths: []

resources:
database_instances:
my_database:
name: NAME_PLACEHOLDER
capacity: CU_1
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"method": "DELETE",
"path": "/api/2.0/database/instances/test-db-old-[UNIQUE_NAME]",
"q": {
"purge": "true"
}
}
{
"body": {
"capacity": "CU_1",
"name": "test-db-new-[UNIQUE_NAME]"
},
"method": "POST",
"path": "/api/2.0/database/instances"
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 35 additions & 0 deletions acceptance/bundle/resources/database_instances/recreate/output.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@

>>> [CLI] bundle deploy
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/deploy-lakebase-recreate-[UNIQUE_NAME]/default/files...
Deploying resources...
Updating deployment state...
Deployment complete!

=== Rename the instance: name is immutable, so the plan recreates it
>>> [CLI] bundle plan
recreate database_instances.my_database

Plan: 1 to add, 0 to change, 1 to delete, 0 unchanged

>>> [CLI] bundle deploy --auto-approve
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/deploy-lakebase-recreate-[UNIQUE_NAME]/default/files...

This action will result in the deletion or recreation of the following Lakebase database instances.
All data stored in them will be permanently lost:
recreate resources.database_instances.my_database
Deploying resources...
Updating deployment state...
Deployment complete!

>>> [CLI] bundle destroy --auto-approve
The following resources will be deleted:
delete resources.database_instances.my_database

This action will result in the deletion of the following Lakebase database instances.
All data stored in them will be permanently lost:
delete resources.database_instances.my_database

All files and directories at the following location will be deleted: /Workspace/Users/[USERNAME]/.bundle/deploy-lakebase-recreate-[UNIQUE_NAME]/default

Deleting files...
Destroy complete!
22 changes: 22 additions & 0 deletions acceptance/bundle/resources/database_instances/recreate/script
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
cleanup() {
trace $CLI bundle destroy --auto-approve
rm -f out.requests.txt
}
trap cleanup EXIT

envsubst < databricks.yml.tmpl | sed "s/NAME_PLACEHOLDER/test-db-old-${UNIQUE_NAME}/" > databricks.yml

trace $CLI bundle deploy
rm -f out.requests.txt

title "Rename the instance: name is immutable, so the plan recreates it"
sed "s/test-db-old-${UNIQUE_NAME}/test-db-new-${UNIQUE_NAME}/" databricks.yml > databricks.yml.new
mv databricks.yml.new databricks.yml

trace $CLI bundle plan
trace $CLI bundle deploy --auto-approve

# The rename must be a DELETE of the old instance plus a POST creating the new
# one. A PATCH to the renamed instance would 404 (the bug this guards against).
jq --sort-keys 'select(.method != "GET" and (.path | contains("/database/instances")))' < out.requests.txt > out.requests.rename.txt
rm -f out.requests.txt
11 changes: 11 additions & 0 deletions acceptance/bundle/resources/database_instances/recreate/test.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# A database instance name is immutable and the Database API has no rename
# endpoint, so changing it must go through delete + create. Only the direct
# engine handles this correctly; the terraform path needs an upstream provider
# fix (marking name immutable in the spec) and is excluded here.
EnvMatrix.DATABRICKS_BUNDLE_ENGINE = ["direct"]
RecordRequests = true

Ignore = [
"databricks.yml",
".databricks",
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
bundle:
name: deploy-lakebase-synced-recreate-$UNIQUE_NAME

resources:
database_instances:
my_instance:
name: test-db-synced-recreate-$UNIQUE_NAME
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
synced_database_tables:
my_synced_table:
name: ${resources.database_catalogs.my_catalog.name}.${resources.database_catalogs.my_catalog.database_name}.my_synced_table
database_instance_name: ${resources.database_instances.my_instance.name}
logical_database_name: ${resources.database_catalogs.my_catalog.database_name}
spec:
source_table_full_name: "main.test_schema.trips_source"
scheduling_policy: POLICY_PLACEHOLDER
primary_key_columns:
- id
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"method": "DELETE",
"path": "/api/2.0/database/synced_tables/my_catalog_[UNIQUE_NAME].my_database.my_synced_table"
}
{
"body": {
"database_instance_name": "test-db-synced-recreate-[UNIQUE_NAME]",
"logical_database_name": "my_database",
"name": "my_catalog_[UNIQUE_NAME].my_database.my_synced_table",
"spec": {
"primary_key_columns": [
"id"
],
"scheduling_policy": "TRIGGERED",
"source_table_full_name": "main.test_schema.trips_source"
}
},
"method": "POST",
"path": "/api/2.0/database/synced_tables"
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@

>>> [CLI] bundle deploy
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/deploy-lakebase-synced-recreate-[UNIQUE_NAME]/default/files...
Deploying resources...
Updating deployment state...
Deployment complete!

=== Change an immutable synced-table field: no update API, so the plan recreates it
>>> [CLI] bundle plan
recreate synced_database_tables.my_synced_table

Plan: 1 to add, 0 to change, 1 to delete, 2 unchanged

>>> [CLI] bundle deploy --auto-approve
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/deploy-lakebase-synced-recreate-[UNIQUE_NAME]/default/files...

This action will result in the deletion or recreation of the following synced database tables.
The synced data in the destination database will be lost (the source table is preserved):
recreate resources.synced_database_tables.my_synced_table
Deploying resources...
Updating deployment state...
Deployment complete!

>>> [CLI] bundle destroy --auto-approve
The following resources will be deleted:
delete resources.database_catalogs.my_catalog
delete resources.database_instances.my_instance
delete resources.synced_database_tables.my_synced_table

This action will result in the deletion of the following Lakebase database instances.
All data stored in them will be permanently lost:
delete resources.database_instances.my_instance

This action will result in the deletion of the following synced database tables.
The synced data in the destination database will be lost (the source table is preserved):
delete resources.synced_database_tables.my_synced_table

All files and directories at the following location will be deleted: /Workspace/Users/[USERNAME]/.bundle/deploy-lakebase-synced-recreate-[UNIQUE_NAME]/default

Deleting files...
Destroy complete!
22 changes: 22 additions & 0 deletions acceptance/bundle/resources/synced_database_tables/recreate/script
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
cleanup() {
trace $CLI bundle destroy --auto-approve
rm -f out.requests.txt
}
trap cleanup EXIT

envsubst < databricks.yml.tmpl | sed "s/POLICY_PLACEHOLDER/SNAPSHOT/" > databricks.yml

trace $CLI bundle deploy
rm -f out.requests.txt

title "Change an immutable synced-table field: no update API, so the plan recreates it"
sed "s/scheduling_policy: SNAPSHOT/scheduling_policy: TRIGGERED/" databricks.yml > databricks.yml.new
mv databricks.yml.new databricks.yml

trace $CLI bundle plan
trace $CLI bundle deploy --auto-approve

# The change must be a DELETE of the old synced table plus a POST creating the
# new one. A PATCH would return 501 (the bug this guards against).
jq --sort-keys 'select(.method != "GET" and (.path | contains("/database/synced_tables")))' < out.requests.txt > out.requests.recreate.txt
rm -f out.requests.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# The Database API has no UpdateSyncedDatabaseTable endpoint (PATCH returns 501),
# so any field change must go through delete + create. The direct engine handles
# this; the terraform path would need an upstream provider fix and is excluded.
EnvMatrix.DATABRICKS_BUNDLE_ENGINE = ["direct"]
RecordRequests = true

Ignore = [
"databricks.yml",
".databricks",
]
Loading
Loading