cancel
Showing results forย 
Search instead forย 
Did you mean:ย 
Data Governance
Join discussions on data governance practices, compliance, and security within the Databricks Community. Exchange strategies and insights to ensure data integrity and regulatory compliance.
cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Programmatically Update Table / Columns Descriptions in Unity Catalog Without Altering Table

wallfacer
New Contributor II

Currently, we must re-run our DLT pipelines anytime we want to add/modify a table or column description to unity catalog.

  • Is this the only way to add/modify unity catalog descriptions?
  • Is there functionality within databricks cli / sdk that we can leverage to programmatically update table or column descriptions?
  • Is there an api like StatementExecutionAPI?

Is this feature on the product roadmap?

1 REPLY 1

MichaelP
New Contributor II

Comments for schemas and tables may be updated using SQL DDL statement  COMMENT ON.

Comments for columns are updated using:

 

ALTER TABLE <table-name> ALTER COLUMN <column-name> COMMENT '<comment-text>';

 

The <column-name> for nested STRUCTS follows simple dotted notation. For example, a STRUCT for a person's physical address:

 

ALTER TABLE person ALTER COLUMN physical_address.postal_code
COMMENT 'Postal code for the person\'s physical address.';

 

Less obvious, the <column-name> for fields in ARRAY<STRUCT<>> requires additional keyword ".element". For example, an array of address STRUCTs that includes an "address use code" field:

 

ALTER TABLE person ALTER COLUMN address.element.use_code
COMMENT 'The address use code indicates either \'physical\' or \'mailing\' address.';

 

As of this writing, each ALTER COLUMN ... COMMENT requires an individual ALTER TABLE statement. The column comments cannot be chained together as a list of as clauses within ALTER TABLE.

Connect with Databricks Users in Your Area

Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you wonโ€™t want to miss the chance to attend and share knowledge.

If there isnโ€™t a group near you, start one and help create a community that brings people together.

Request a New Group