Skip to content

Commit 0e9f804

Browse files
authored
work (#3497)
1 parent 3ad1c70 commit 0e9f804

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

catalog/data_current_metastore.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package catalog
22

33
import (
44
"context"
5+
"strings"
56

67
"github.com/databricks/databricks-sdk-go"
78
"github.com/databricks/databricks-sdk-go/service/catalog"
@@ -16,11 +17,16 @@ func DataSourceCurrentMetastore() common.Resource {
1617
return common.WorkspaceData(func(ctx context.Context, data *CurrentMetastore, wc *databricks.WorkspaceClient) error {
1718
summary, err := wc.Metastores.Summary(ctx)
1819
if err != nil {
20+
if strings.Contains(err.Error(), "No metastore assigned for the current workspace") {
21+
data.Metastore = nil
22+
data.Id = "no_metastore"
23+
return nil
24+
}
1925
return err
26+
} else {
27+
data.Metastore = summary
28+
data.Id = summary.MetastoreId
2029
}
21-
data.Metastore = summary
22-
data.Id = summary.MetastoreId
23-
2430
return nil
2531
})
2632
}

docs/data-sources/current_metastore.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ output "some_metastore" {
2626

2727
This data source exports the following attributes:
2828

29-
* `id` - metastore ID.
29+
* `id` - metastore ID. Will be `no_metastore` if there is no metastore assigned for the current workspace
3030
* `metastore_info` - summary about a metastore attached to the current workspace returned by [Get a metastore summary API](https://docs.databricks.com/api/workspace/metastores/summary). This contains the following attributes (check the API page for up-to-date details):
3131
* `name` - Name of metastore.
3232
* `metastore_id` - Metastore ID.

0 commit comments

Comments
 (0)