Skip to content

Commit

Permalink
[Fix] don't update databricks_metastore during creation if not requ…
Browse files Browse the repository at this point in the history
…ired (#3783)

## Changes
- don't update `databricks_metastore` during creation if not required.
This was previously done for account-level provider. Extend this to
workspace-level provider

## Tests
<!-- 
How is this tested? Please see the checklist below and also describe any
other relevant tests
-->

- [x] `make test` run locally
- [x] covered with integration tests in `internal/acceptance`
- [x] relevant acceptance tests are passing
- [x] using Go SDK
  • Loading branch information
nkvuong authored Jul 20, 2024
1 parent 0e32851 commit d58f89f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
11 changes: 7 additions & 4 deletions catalog/resource_metastore.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ func ResourceMetastore() common.Resource {
common.DataToStructPointer(d, s, &create)
common.DataToStructPointer(d, s, &update)
updateForceSendFields(&update)
emptyRequest, err := common.IsRequestEmpty(update)
if err != nil {
return err
}
return c.AccountOrWorkspaceRequest(func(acc *databricks.AccountClient) error {
mi, err := acc.Metastores.Create(ctx,
catalog.AccountsCreateMetastore{
Expand All @@ -75,10 +79,6 @@ func ResourceMetastore() common.Resource {
if err != nil {
return err
}
emptyRequest, err := common.IsRequestEmpty(update)
if err != nil {
return err
}
d.SetId(mi.MetastoreInfo.MetastoreId)
if emptyRequest {
return nil
Expand All @@ -97,6 +97,9 @@ func ResourceMetastore() common.Resource {
return err
}
d.SetId(mi.MetastoreId)
if emptyRequest {
return nil
}
update.Id = mi.MetastoreId
_, err = w.Metastores.Update(ctx, update)
if err != nil {
Expand Down
5 changes: 0 additions & 5 deletions catalog/resource_metastore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@ func TestCreateMetastore(t *testing.T) {
}).Return(&catalog.MetastoreInfo{
MetastoreId: "abc",
}, nil)
e.Update(mock.Anything, catalog.UpdateMetastore{
Id: "abc",
}).Return(&catalog.MetastoreInfo{
Name: "a",
}, nil)
e.GetById(mock.Anything, "abc").Return(&catalog.MetastoreInfo{
StorageRoot: "s3://b/abc",
Name: "a",
Expand Down

0 comments on commit d58f89f

Please sign in to comment.