Skip to content

Commit 67ab932

Browse files
authored
Added full_name attribute to databricks_system_schema resource (#3634)
This will simplify references to the system schemas from other resources, such as, grants.
1 parent a997ede commit 67ab932

File tree

3 files changed

+19
-7
lines changed

3 files changed

+19
-7
lines changed

catalog/resource_system_schema.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ func ResourceSystemSchema() common.Resource {
1717
Type: schema.TypeString,
1818
Computed: true,
1919
}
20+
m["full_name"] = &schema.Schema{
21+
Type: schema.TypeString,
22+
Computed: true,
23+
}
2024
m["state"].Computed = true
2125
return m
2226
})
@@ -85,7 +89,12 @@ func ResourceSystemSchema() common.Resource {
8589
}
8690
for _, schema := range systemSchemaInfo.Schemas {
8791
if schema.Schema == schemaName {
88-
return common.StructToData(schema, systemSchema, d)
92+
err = common.StructToData(schema, systemSchema, d)
93+
if err != nil {
94+
return err
95+
}
96+
d.Set("full_name", fmt.Sprintf("system.%s", schemaName))
97+
return nil
8998
}
9099
}
91100
return nil

catalog/resource_system_schema_test.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
)
1212

1313
func TestSystemSchemaCreate(t *testing.T) {
14-
d, err := qa.ResourceFixture{
14+
qa.ResourceFixture{
1515
Fixtures: []qa.HTTPFixture{
1616
{
1717
Method: http.MethodGet,
@@ -52,9 +52,11 @@ func TestSystemSchemaCreate(t *testing.T) {
5252
Resource: ResourceSystemSchema(),
5353
HCL: `schema = "access"`,
5454
Create: true,
55-
}.Apply(t)
56-
assert.NoError(t, err)
57-
assert.Equal(t, "abc|access", d.Id())
55+
}.ApplyAndExpectData(t, map[string]any{
56+
"schema": "access",
57+
"id": "abc|access",
58+
"full_name": "system.access",
59+
})
5860
}
5961

6062
func TestSystemSchemaCreate_Error(t *testing.T) {

docs/resources/system_schema.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,20 @@ resource "databricks_system_schema" "this" {
2323

2424
The following arguments are available:
2525

26-
* `schema` - (Required) Full name of the system schema.
26+
* `schema` - (Required) name of the system schema.
2727

2828
## Attribute Reference
2929

3030
In addition to all arguments above, the following attributes are exported:
3131

3232
* `id` - the ID of system schema in form of `metastore_id|schema_name`.
3333
* `state` - The current state of enablement for the system schema.
34+
* `full_name` - the full name of the system schema, in form of `system.<schema>`.
3435

3536
## Import
3637

3738
This resource can be imported by the metastore id and schema name
3839

3940
```bash
40-
terraform import databricks_system_schema.this <metastore_id>|<schema_name>
41+
terraform import databricks_system_schema.this '<metastore_id>|<schema_name>'
4142
```

0 commit comments

Comments
 (0)