Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] Add support for Primary and Foreign Key Constraints in databricks_sql_table #4157

Open
hshahconsulting opened this issue Oct 25, 2024 · 0 comments · May be fixed by #4155
Open

[FEATURE] Add support for Primary and Foreign Key Constraints in databricks_sql_table #4157

hshahconsulting opened this issue Oct 25, 2024 · 0 comments · May be fixed by #4155
Labels
feature New feature or request

Comments

@hshahconsulting
Copy link

Use-cases

I would like to use the Primary Key and Foreign Key feature that is generally available in Databricks to view relations between keys in columns when browsing tables in the Unity Catalog.

https://www.databricks.com/blog/primary-key-and-foreign-key-constraints-are-ga-and-now-enable-faster-queries

Proposal

resource "databricks_sql_table" "my_table" {
	name               = "bar"
	catalog_name       = "main"
	schema_name        = databricks_schema.this.name
	table_type         = "MANAGED"
	properties         =  {
		this      = "that"
		something = "else"
	}

	column {
		name      = "id"
		type      = "bigint"
	}
	column {
		name      = "name"
		type      = "string"
	}
	column {
		name      = "externalId"
		type      = "string"
	}
	key_constraint {
		primary_key = "id"
	}
	key_constraint {
		referenced_key = "external_id"
		referenced_catalog = "bronze"
		referenced_schema = "biz"
		referenced_table = "transactions"
		referenced_foreign_key = "transactionId"
	}
	comment = "this table is managed by terraform"
	owner = "account users"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
1 participant