1. Packages
  2. Databricks Provider
  3. API Docs
  4. Schema
Databricks v1.65.0 published on Wednesday, Apr 9, 2025 by Pulumi

databricks.Schema

Explore with Pulumi AI

This resource can only be used with a workspace-level provider!

Within a metastore, Unity Catalog provides a 3-level namespace for organizing data: Catalogs, Databases (also called Schemas), and Tables / Views.

A databricks.Schema is contained within databricks.Catalog and can contain tables & views.

Example Usage

import * as pulumi from "@pulumi/pulumi";
import * as databricks from "@pulumi/databricks";

const sandbox = new databricks.Catalog("sandbox", {
    name: "sandbox",
    comment: "this catalog is managed by terraform",
    properties: {
        purpose: "testing",
    },
});
const things = new databricks.Schema("things", {
    catalogName: sandbox.id,
    name: "things",
    comment: "this database is managed by terraform",
    properties: {
        kind: "various",
    },
});
Copy
import pulumi
import pulumi_databricks as databricks

sandbox = databricks.Catalog("sandbox",
    name="sandbox",
    comment="this catalog is managed by terraform",
    properties={
        "purpose": "testing",
    })
things = databricks.Schema("things",
    catalog_name=sandbox.id,
    name="things",
    comment="this database is managed by terraform",
    properties={
        "kind": "various",
    })
Copy
package main

import (
	"github.com/pulumi/pulumi-databricks/sdk/go/databricks"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		sandbox, err := databricks.NewCatalog(ctx, "sandbox", &databricks.CatalogArgs{
			Name:    pulumi.String("sandbox"),
			Comment: pulumi.String("this catalog is managed by terraform"),
			Properties: pulumi.StringMap{
				"purpose": pulumi.String("testing"),
			},
		})
		if err != nil {
			return err
		}
		_, err = databricks.NewSchema(ctx, "things", &databricks.SchemaArgs{
			CatalogName: sandbox.ID(),
			Name:        pulumi.String("things"),
			Comment:     pulumi.String("this database is managed by terraform"),
			Properties: pulumi.StringMap{
				"kind": pulumi.String("various"),
			},
		})
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Databricks = Pulumi.Databricks;

return await Deployment.RunAsync(() => 
{
    var sandbox = new Databricks.Catalog("sandbox", new()
    {
        Name = "sandbox",
        Comment = "this catalog is managed by terraform",
        Properties = 
        {
            { "purpose", "testing" },
        },
    });

    var things = new Databricks.Schema("things", new()
    {
        CatalogName = sandbox.Id,
        Name = "things",
        Comment = "this database is managed by terraform",
        Properties = 
        {
            { "kind", "various" },
        },
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.databricks.Catalog;
import com.pulumi.databricks.CatalogArgs;
import com.pulumi.databricks.Schema;
import com.pulumi.databricks.SchemaArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        var sandbox = new Catalog("sandbox", CatalogArgs.builder()
            .name("sandbox")
            .comment("this catalog is managed by terraform")
            .properties(Map.of("purpose", "testing"))
            .build());

        var things = new Schema("things", SchemaArgs.builder()
            .catalogName(sandbox.id())
            .name("things")
            .comment("this database is managed by terraform")
            .properties(Map.of("kind", "various"))
            .build());

    }
}
Copy
resources:
  sandbox:
    type: databricks:Catalog
    properties:
      name: sandbox
      comment: this catalog is managed by terraform
      properties:
        purpose: testing
  things:
    type: databricks:Schema
    properties:
      catalogName: ${sandbox.id}
      name: things
      comment: this database is managed by terraform
      properties:
        kind: various
Copy

The following resources are used in the same context:

  • databricks.getTables data to list tables within Unity Catalog.
  • databricks.getSchemas data to list schemas within Unity Catalog.
  • databricks.getCatalogs data to list catalogs within Unity Catalog.

Create Schema Resource

Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

Constructor syntax

new Schema(name: string, args: SchemaArgs, opts?: CustomResourceOptions);
@overload
def Schema(resource_name: str,
           args: SchemaArgs,
           opts: Optional[ResourceOptions] = None)

@overload
def Schema(resource_name: str,
           opts: Optional[ResourceOptions] = None,
           catalog_name: Optional[str] = None,
           comment: Optional[str] = None,
           enable_predictive_optimization: Optional[str] = None,
           force_destroy: Optional[bool] = None,
           metastore_id: Optional[str] = None,
           name: Optional[str] = None,
           owner: Optional[str] = None,
           properties: Optional[Mapping[str, str]] = None,
           storage_root: Optional[str] = None)
func NewSchema(ctx *Context, name string, args SchemaArgs, opts ...ResourceOption) (*Schema, error)
public Schema(string name, SchemaArgs args, CustomResourceOptions? opts = null)
public Schema(String name, SchemaArgs args)
public Schema(String name, SchemaArgs args, CustomResourceOptions options)
type: databricks:Schema
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

Parameters

name This property is required. string
The unique name of the resource.
args This property is required. SchemaArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name This property is required. str
The unique name of the resource.
args This property is required. SchemaArgs
The arguments to resource properties.
opts ResourceOptions
Bag of options to control resource's behavior.
ctx Context
Context object for the current deployment.
name This property is required. string
The unique name of the resource.
args This property is required. SchemaArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name This property is required. string
The unique name of the resource.
args This property is required. SchemaArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name This property is required. String
The unique name of the resource.
args This property is required. SchemaArgs
The arguments to resource properties.
options CustomResourceOptions
Bag of options to control resource's behavior.

Constructor example

The following reference example uses placeholder values for all input properties.

var schemaResource = new Databricks.Schema("schemaResource", new()
{
    CatalogName = "string",
    Comment = "string",
    EnablePredictiveOptimization = "string",
    ForceDestroy = false,
    MetastoreId = "string",
    Name = "string",
    Owner = "string",
    Properties = 
    {
        { "string", "string" },
    },
    StorageRoot = "string",
});
Copy
example, err := databricks.NewSchema(ctx, "schemaResource", &databricks.SchemaArgs{
	CatalogName:                  pulumi.String("string"),
	Comment:                      pulumi.String("string"),
	EnablePredictiveOptimization: pulumi.String("string"),
	ForceDestroy:                 pulumi.Bool(false),
	MetastoreId:                  pulumi.String("string"),
	Name:                         pulumi.String("string"),
	Owner:                        pulumi.String("string"),
	Properties: pulumi.StringMap{
		"string": pulumi.String("string"),
	},
	StorageRoot: pulumi.String("string"),
})
Copy
var schemaResource = new Schema("schemaResource", SchemaArgs.builder()
    .catalogName("string")
    .comment("string")
    .enablePredictiveOptimization("string")
    .forceDestroy(false)
    .metastoreId("string")
    .name("string")
    .owner("string")
    .properties(Map.of("string", "string"))
    .storageRoot("string")
    .build());
Copy
schema_resource = databricks.Schema("schemaResource",
    catalog_name="string",
    comment="string",
    enable_predictive_optimization="string",
    force_destroy=False,
    metastore_id="string",
    name="string",
    owner="string",
    properties={
        "string": "string",
    },
    storage_root="string")
Copy
const schemaResource = new databricks.Schema("schemaResource", {
    catalogName: "string",
    comment: "string",
    enablePredictiveOptimization: "string",
    forceDestroy: false,
    metastoreId: "string",
    name: "string",
    owner: "string",
    properties: {
        string: "string",
    },
    storageRoot: "string",
});
Copy
type: databricks:Schema
properties:
    catalogName: string
    comment: string
    enablePredictiveOptimization: string
    forceDestroy: false
    metastoreId: string
    name: string
    owner: string
    properties:
        string: string
    storageRoot: string
Copy

Schema Resource Properties

To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

Inputs

In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.

The Schema resource accepts the following input properties:

CatalogName
This property is required.
Changes to this property will trigger replacement.
string
Name of parent catalog. Change forces creation of a new resource.
Comment string
User-supplied free-form text.
EnablePredictiveOptimization string
Whether predictive optimization should be enabled for this object and objects under it. Can be ENABLE, DISABLE or INHERIT
ForceDestroy bool
Delete schema regardless of its contents.
MetastoreId string
Name Changes to this property will trigger replacement. string
Name of Schema relative to parent catalog. Change forces creation of a new resource.
Owner string
Username/groupname/sp application_id of the schema owner.
Properties Dictionary<string, string>
Extensible Schema properties.
StorageRoot Changes to this property will trigger replacement. string
Managed location of the schema. Location in cloud storage where data for managed tables will be stored. If not specified, the location will default to the catalog root location. Change forces creation of a new resource.
CatalogName
This property is required.
Changes to this property will trigger replacement.
string
Name of parent catalog. Change forces creation of a new resource.
Comment string
User-supplied free-form text.
EnablePredictiveOptimization string
Whether predictive optimization should be enabled for this object and objects under it. Can be ENABLE, DISABLE or INHERIT
ForceDestroy bool
Delete schema regardless of its contents.
MetastoreId string
Name Changes to this property will trigger replacement. string
Name of Schema relative to parent catalog. Change forces creation of a new resource.
Owner string
Username/groupname/sp application_id of the schema owner.
Properties map[string]string
Extensible Schema properties.
StorageRoot Changes to this property will trigger replacement. string
Managed location of the schema. Location in cloud storage where data for managed tables will be stored. If not specified, the location will default to the catalog root location. Change forces creation of a new resource.
catalogName
This property is required.
Changes to this property will trigger replacement.
String
Name of parent catalog. Change forces creation of a new resource.
comment String
User-supplied free-form text.
enablePredictiveOptimization String
Whether predictive optimization should be enabled for this object and objects under it. Can be ENABLE, DISABLE or INHERIT
forceDestroy Boolean
Delete schema regardless of its contents.
metastoreId String
name Changes to this property will trigger replacement. String
Name of Schema relative to parent catalog. Change forces creation of a new resource.
owner String
Username/groupname/sp application_id of the schema owner.
properties Map<String,String>
Extensible Schema properties.
storageRoot Changes to this property will trigger replacement. String
Managed location of the schema. Location in cloud storage where data for managed tables will be stored. If not specified, the location will default to the catalog root location. Change forces creation of a new resource.
catalogName
This property is required.
Changes to this property will trigger replacement.
string
Name of parent catalog. Change forces creation of a new resource.
comment string
User-supplied free-form text.
enablePredictiveOptimization string
Whether predictive optimization should be enabled for this object and objects under it. Can be ENABLE, DISABLE or INHERIT
forceDestroy boolean
Delete schema regardless of its contents.
metastoreId string
name Changes to this property will trigger replacement. string
Name of Schema relative to parent catalog. Change forces creation of a new resource.
owner string
Username/groupname/sp application_id of the schema owner.
properties {[key: string]: string}
Extensible Schema properties.
storageRoot Changes to this property will trigger replacement. string
Managed location of the schema. Location in cloud storage where data for managed tables will be stored. If not specified, the location will default to the catalog root location. Change forces creation of a new resource.
catalog_name
This property is required.
Changes to this property will trigger replacement.
str
Name of parent catalog. Change forces creation of a new resource.
comment str
User-supplied free-form text.
enable_predictive_optimization str
Whether predictive optimization should be enabled for this object and objects under it. Can be ENABLE, DISABLE or INHERIT
force_destroy bool
Delete schema regardless of its contents.
metastore_id str
name Changes to this property will trigger replacement. str
Name of Schema relative to parent catalog. Change forces creation of a new resource.
owner str
Username/groupname/sp application_id of the schema owner.
properties Mapping[str, str]
Extensible Schema properties.
storage_root Changes to this property will trigger replacement. str
Managed location of the schema. Location in cloud storage where data for managed tables will be stored. If not specified, the location will default to the catalog root location. Change forces creation of a new resource.
catalogName
This property is required.
Changes to this property will trigger replacement.
String
Name of parent catalog. Change forces creation of a new resource.
comment String
User-supplied free-form text.
enablePredictiveOptimization String
Whether predictive optimization should be enabled for this object and objects under it. Can be ENABLE, DISABLE or INHERIT
forceDestroy Boolean
Delete schema regardless of its contents.
metastoreId String
name Changes to this property will trigger replacement. String
Name of Schema relative to parent catalog. Change forces creation of a new resource.
owner String
Username/groupname/sp application_id of the schema owner.
properties Map<String>
Extensible Schema properties.
storageRoot Changes to this property will trigger replacement. String
Managed location of the schema. Location in cloud storage where data for managed tables will be stored. If not specified, the location will default to the catalog root location. Change forces creation of a new resource.

Outputs

All input properties are implicitly available as output properties. Additionally, the Schema resource produces the following output properties:

Id string
The provider-assigned unique ID for this managed resource.
Id string
The provider-assigned unique ID for this managed resource.
id String
The provider-assigned unique ID for this managed resource.
id string
The provider-assigned unique ID for this managed resource.
id str
The provider-assigned unique ID for this managed resource.
id String
The provider-assigned unique ID for this managed resource.

Look up Existing Schema Resource

Get an existing Schema resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

public static get(name: string, id: Input<ID>, state?: SchemaState, opts?: CustomResourceOptions): Schema
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        catalog_name: Optional[str] = None,
        comment: Optional[str] = None,
        enable_predictive_optimization: Optional[str] = None,
        force_destroy: Optional[bool] = None,
        metastore_id: Optional[str] = None,
        name: Optional[str] = None,
        owner: Optional[str] = None,
        properties: Optional[Mapping[str, str]] = None,
        storage_root: Optional[str] = None) -> Schema
func GetSchema(ctx *Context, name string, id IDInput, state *SchemaState, opts ...ResourceOption) (*Schema, error)
public static Schema Get(string name, Input<string> id, SchemaState? state, CustomResourceOptions? opts = null)
public static Schema get(String name, Output<String> id, SchemaState state, CustomResourceOptions options)
resources:  _:    type: databricks:Schema    get:      id: ${id}
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
resource_name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
The following state arguments are supported:
CatalogName Changes to this property will trigger replacement. string
Name of parent catalog. Change forces creation of a new resource.
Comment string
User-supplied free-form text.
EnablePredictiveOptimization string
Whether predictive optimization should be enabled for this object and objects under it. Can be ENABLE, DISABLE or INHERIT
ForceDestroy bool
Delete schema regardless of its contents.
MetastoreId string
Name Changes to this property will trigger replacement. string
Name of Schema relative to parent catalog. Change forces creation of a new resource.
Owner string
Username/groupname/sp application_id of the schema owner.
Properties Dictionary<string, string>
Extensible Schema properties.
StorageRoot Changes to this property will trigger replacement. string
Managed location of the schema. Location in cloud storage where data for managed tables will be stored. If not specified, the location will default to the catalog root location. Change forces creation of a new resource.
CatalogName Changes to this property will trigger replacement. string
Name of parent catalog. Change forces creation of a new resource.
Comment string
User-supplied free-form text.
EnablePredictiveOptimization string
Whether predictive optimization should be enabled for this object and objects under it. Can be ENABLE, DISABLE or INHERIT
ForceDestroy bool
Delete schema regardless of its contents.
MetastoreId string
Name Changes to this property will trigger replacement. string
Name of Schema relative to parent catalog. Change forces creation of a new resource.
Owner string
Username/groupname/sp application_id of the schema owner.
Properties map[string]string
Extensible Schema properties.
StorageRoot Changes to this property will trigger replacement. string
Managed location of the schema. Location in cloud storage where data for managed tables will be stored. If not specified, the location will default to the catalog root location. Change forces creation of a new resource.
catalogName Changes to this property will trigger replacement. String
Name of parent catalog. Change forces creation of a new resource.
comment String
User-supplied free-form text.
enablePredictiveOptimization String
Whether predictive optimization should be enabled for this object and objects under it. Can be ENABLE, DISABLE or INHERIT
forceDestroy Boolean
Delete schema regardless of its contents.
metastoreId String
name Changes to this property will trigger replacement. String
Name of Schema relative to parent catalog. Change forces creation of a new resource.
owner String
Username/groupname/sp application_id of the schema owner.
properties Map<String,String>
Extensible Schema properties.
storageRoot Changes to this property will trigger replacement. String
Managed location of the schema. Location in cloud storage where data for managed tables will be stored. If not specified, the location will default to the catalog root location. Change forces creation of a new resource.
catalogName Changes to this property will trigger replacement. string
Name of parent catalog. Change forces creation of a new resource.
comment string
User-supplied free-form text.
enablePredictiveOptimization string
Whether predictive optimization should be enabled for this object and objects under it. Can be ENABLE, DISABLE or INHERIT
forceDestroy boolean
Delete schema regardless of its contents.
metastoreId string
name Changes to this property will trigger replacement. string
Name of Schema relative to parent catalog. Change forces creation of a new resource.
owner string
Username/groupname/sp application_id of the schema owner.
properties {[key: string]: string}
Extensible Schema properties.
storageRoot Changes to this property will trigger replacement. string
Managed location of the schema. Location in cloud storage where data for managed tables will be stored. If not specified, the location will default to the catalog root location. Change forces creation of a new resource.
catalog_name Changes to this property will trigger replacement. str
Name of parent catalog. Change forces creation of a new resource.
comment str
User-supplied free-form text.
enable_predictive_optimization str
Whether predictive optimization should be enabled for this object and objects under it. Can be ENABLE, DISABLE or INHERIT
force_destroy bool
Delete schema regardless of its contents.
metastore_id str
name Changes to this property will trigger replacement. str
Name of Schema relative to parent catalog. Change forces creation of a new resource.
owner str
Username/groupname/sp application_id of the schema owner.
properties Mapping[str, str]
Extensible Schema properties.
storage_root Changes to this property will trigger replacement. str
Managed location of the schema. Location in cloud storage where data for managed tables will be stored. If not specified, the location will default to the catalog root location. Change forces creation of a new resource.
catalogName Changes to this property will trigger replacement. String
Name of parent catalog. Change forces creation of a new resource.
comment String
User-supplied free-form text.
enablePredictiveOptimization String
Whether predictive optimization should be enabled for this object and objects under it. Can be ENABLE, DISABLE or INHERIT
forceDestroy Boolean
Delete schema regardless of its contents.
metastoreId String
name Changes to this property will trigger replacement. String
Name of Schema relative to parent catalog. Change forces creation of a new resource.
owner String
Username/groupname/sp application_id of the schema owner.
properties Map<String>
Extensible Schema properties.
storageRoot Changes to this property will trigger replacement. String
Managed location of the schema. Location in cloud storage where data for managed tables will be stored. If not specified, the location will default to the catalog root location. Change forces creation of a new resource.

Import

This resource can be imported by its full name:

bash

$ pulumi import databricks:index/schema:Schema this <catalog_name>.<name>
Copy

To learn more about importing existing cloud resources, see Importing resources.

Package Details

Repository
databricks pulumi/pulumi-databricks
License
Apache-2.0
Notes
This Pulumi package is based on the databricks Terraform Provider.