Skip to content

Commit 3d94565

Browse files
authored
[Fix] Remove incorrect customization for databricks_catalog (#5021)
## Changes - foreign catalog can have both `connection_name` and `storage_root` ## 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] using Go SDK - [x] has entry in `NEXT_CHANGELOG.md` file
1 parent 79322bb commit 3d94565

File tree

3 files changed

+64
-9
lines changed

3 files changed

+64
-9
lines changed

NEXT_CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
### Bug Fixes
1212

13+
* Remove incorrect customization for `databricks_catalog`
14+
1315
### Documentation
1416

1517
### Exporter

catalog/resource_catalog.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ func ResourceCatalog() common.Resource {
4444
for _, v := range []string{"name", "connection_name", "share_name", "provider_name"} {
4545
common.CustomizeSchemaPath(s, v).SetCustomSuppressDiff(common.EqualFoldDiffSuppress)
4646
}
47-
// can only have one of provider_name + share_name, connection_name or storage_root
48-
common.CustomizeSchemaPath(s, "connection_name").SetConflictsWith([]string{"storage_root", "provider_name", "share_name"}).SetForceNew()
47+
// can only have one of provider_name + share_name, connection_name
48+
common.CustomizeSchemaPath(s, "connection_name").SetConflictsWith([]string{"provider_name", "share_name"}).SetForceNew()
4949
for _, v := range []string{"provider_name", "share_name"} {
5050
common.CustomizeSchemaPath(s, v).SetConflictsWith([]string{"connection_name", "storage_root"}).SetForceNew()
5151
}

catalog/resource_catalog_test.go

Lines changed: 60 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,7 @@ func TestCatalogCreateDeltaSharing(t *testing.T) {
630630
}
631631

632632
func TestCatalogCreateForeign(t *testing.T) {
633-
d, err := qa.ResourceFixture{
633+
qa.ResourceFixture{
634634
MockWorkspaceClientFunc: func(w *mocks.MockWorkspaceClient) {
635635
e := w.GetMockCatalogsAPI().EXPECT()
636636
e.Create(mock.Anything, catalog.CreateCatalog{
@@ -665,12 +665,65 @@ func TestCatalogCreateForeign(t *testing.T) {
665665
}
666666
connection_name = "foo"
667667
`,
668-
}.Apply(t)
669-
assert.NoError(t, err)
670-
assert.Equal(t, "foreign_catalog", d.Get("name"))
671-
assert.Equal(t, "foo", d.Get("connection_name"))
672-
assert.Equal(t, "b", d.Get("comment"))
673-
assert.Equal(t, map[string]interface{}{"database": "abcd"}, d.Get("options"))
668+
}.ApplyAndExpectData(t, map[string]any{
669+
"name": "foreign_catalog",
670+
"comment": "b",
671+
"connection_name": "foo",
672+
"options": map[string]any{
673+
"database": "abcd",
674+
},
675+
})
676+
}
677+
678+
func TestCatalogCreateForeignIceberg(t *testing.T) {
679+
qa.ResourceFixture{
680+
MockWorkspaceClientFunc: func(w *mocks.MockWorkspaceClient) {
681+
e := w.GetMockCatalogsAPI().EXPECT()
682+
e.Create(mock.Anything, catalog.CreateCatalog{
683+
Name: "foreign_catalog",
684+
Comment: "b",
685+
Options: map[string]string{"database": "abcd"},
686+
ConnectionName: "foo",
687+
StorageRoot: "s3://my-bucket/warehouse",
688+
}).Return(&catalog.CatalogInfo{
689+
Name: "foreign_catalog",
690+
Comment: "b",
691+
Options: map[string]string{"database": "abcd"},
692+
ConnectionName: "foo",
693+
MetastoreId: "e",
694+
StorageRoot: "s3://my-bucket/warehouse",
695+
Owner: "f",
696+
}, nil)
697+
e.GetByName(mock.Anything, "foreign_catalog").Return(&catalog.CatalogInfo{
698+
Name: "foreign_catalog",
699+
Comment: "b",
700+
Options: map[string]string{"database": "abcd"},
701+
ConnectionName: "foo",
702+
MetastoreId: "e",
703+
StorageRoot: "s3://my-bucket/warehouse",
704+
Owner: "f",
705+
}, nil)
706+
},
707+
Resource: ResourceCatalog(),
708+
Create: true,
709+
HCL: `
710+
name = "foreign_catalog"
711+
comment = "b"
712+
options = {
713+
database = "abcd"
714+
}
715+
connection_name = "foo"
716+
storage_root = "s3://my-bucket/warehouse"
717+
`,
718+
}.ApplyAndExpectData(t, map[string]any{
719+
"name": "foreign_catalog",
720+
"comment": "b",
721+
"connection_name": "foo",
722+
"options": map[string]any{
723+
"database": "abcd",
724+
},
725+
"storage_root": "s3://my-bucket/warehouse",
726+
})
674727
}
675728

676729
func TestCatalogCreateIsolated(t *testing.T) {

0 commit comments

Comments
 (0)