@@ -3,26 +3,26 @@ package catalog
33import (
44 "context"
55
6+ "github.com/databricks/databricks-sdk-go"
7+ "github.com/databricks/databricks-sdk-go/service/unitycatalog"
68 "github.com/databricks/terraform-provider-databricks/common"
79 "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
810)
911
1012func DataSourceViews () * schema.Resource {
11- type viewsData struct {
13+ return common . WorkspaceData ( func ( ctx context. Context , data * struct {
1214 CatalogName string `json:"catalog_name"`
1315 SchemaName string `json:"schema_name"`
1416 Ids []string `json:"ids,omitempty" tf:"computed,slice_set"`
15- }
16- return common .DataResource (viewsData {}, func (ctx context.Context , e any , c * common.DatabricksClient ) error {
17- data := e .(* viewsData )
18- tablesAPI := NewTablesAPI (ctx , c )
19- tables , err := tablesAPI .listTables (data .CatalogName , data .SchemaName )
17+ }, w * databricks.WorkspaceClient ) error {
18+
19+ tables , err := w .Tables .ListAll (ctx , unitycatalog.ListTablesRequest {CatalogName : data .CatalogName , SchemaName : data .SchemaName })
2020 if err != nil {
2121 return err
2222 }
23- for _ , v := range tables . Tables {
23+ for _ , v := range tables {
2424 if v .TableType == "VIEW" {
25- data .Ids = append (data .Ids , v .FullName () )
25+ data .Ids = append (data .Ids , v .FullName )
2626 }
2727 }
2828 return nil
0 commit comments