-
Notifications
You must be signed in to change notification settings - Fork 188
Trigger recreate for immutable Lakebase database fields #5473
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+452
−84
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
14 changes: 14 additions & 0 deletions
14
acceptance/bundle/resources/database_catalogs/recreate/databricks.yml.tmpl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
14 changes: 14 additions & 0 deletions
14
acceptance/bundle/resources/database_catalogs/recreate/out.requests.recreate.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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" | ||
| } |
5 changes: 5 additions & 0 deletions
5
acceptance/bundle/resources/database_catalogs/recreate/out.test.toml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
32 changes: 32 additions & 0 deletions
32
acceptance/bundle/resources/database_catalogs/recreate/output.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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! | ||
|
|
||
| >>> [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
22
acceptance/bundle/resources/database_catalogs/recreate/script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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
10
acceptance/bundle/resources/database_catalogs/recreate/test.toml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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", | ||
| ] |
11 changes: 11 additions & 0 deletions
11
acceptance/bundle/resources/database_instances/recreate/databricks.yml.tmpl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
15 changes: 15 additions & 0 deletions
15
acceptance/bundle/resources/database_instances/recreate/out.requests.rename.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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" | ||
| } |
5 changes: 5 additions & 0 deletions
5
acceptance/bundle/resources/database_instances/recreate/out.test.toml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
35 changes: 35 additions & 0 deletions
35
acceptance/bundle/resources/database_instances/recreate/output.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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
22
acceptance/bundle/resources/database_instances/recreate/script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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
11
acceptance/bundle/resources/database_instances/recreate/test.toml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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", | ||
| ] |
24 changes: 24 additions & 0 deletions
24
acceptance/bundle/resources/synced_database_tables/recreate/databricks.yml.tmpl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
20 changes: 20 additions & 0 deletions
20
acceptance/bundle/resources/synced_database_tables/recreate/out.requests.recreate.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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" | ||
| } |
5 changes: 5 additions & 0 deletions
5
acceptance/bundle/resources/synced_database_tables/recreate/out.test.toml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
41 changes: 41 additions & 0 deletions
41
acceptance/bundle/resources/synced_database_tables/recreate/output.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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
22
acceptance/bundle/resources/synced_database_tables/recreate/script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
10 changes: 10 additions & 0 deletions
10
acceptance/bundle/resources/synced_database_tables/recreate/test.toml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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", | ||
| ] |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.