Skip to content

Commit d58f89f

Browse files
authored
[Fix] don't update databricks_metastore during creation if not required (#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
1 parent 0e32851 commit d58f89f

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

catalog/resource_metastore.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ func ResourceMetastore() common.Resource {
6767
common.DataToStructPointer(d, s, &create)
6868
common.DataToStructPointer(d, s, &update)
6969
updateForceSendFields(&update)
70+
emptyRequest, err := common.IsRequestEmpty(update)
71+
if err != nil {
72+
return err
73+
}
7074
return c.AccountOrWorkspaceRequest(func(acc *databricks.AccountClient) error {
7175
mi, err := acc.Metastores.Create(ctx,
7276
catalog.AccountsCreateMetastore{
@@ -75,10 +79,6 @@ func ResourceMetastore() common.Resource {
7579
if err != nil {
7680
return err
7781
}
78-
emptyRequest, err := common.IsRequestEmpty(update)
79-
if err != nil {
80-
return err
81-
}
8282
d.SetId(mi.MetastoreInfo.MetastoreId)
8383
if emptyRequest {
8484
return nil
@@ -97,6 +97,9 @@ func ResourceMetastore() common.Resource {
9797
return err
9898
}
9999
d.SetId(mi.MetastoreId)
100+
if emptyRequest {
101+
return nil
102+
}
100103
update.Id = mi.MetastoreId
101104
_, err = w.Metastores.Update(ctx, update)
102105
if err != nil {

catalog/resource_metastore_test.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,6 @@ func TestCreateMetastore(t *testing.T) {
2626
}).Return(&catalog.MetastoreInfo{
2727
MetastoreId: "abc",
2828
}, nil)
29-
e.Update(mock.Anything, catalog.UpdateMetastore{
30-
Id: "abc",
31-
}).Return(&catalog.MetastoreInfo{
32-
Name: "a",
33-
}, nil)
3429
e.GetById(mock.Anything, "abc").Return(&catalog.MetastoreInfo{
3530
StorageRoot: "s3://b/abc",
3631
Name: "a",

0 commit comments

Comments
 (0)