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?

2 REPLIES 2

Kaniz_Fatma
Community Manager
Community Manager

Hi @wallfacer, Letโ€™s explore some options for programmatically updating table or column descriptions in Unity Catalog within Databricks:

  1. Databricks CLI and SDK:

    • You can leverage the Databricks Command-Line Interface (CLI) and the Databricks SDK to programmatically update table or column descriptions.
    • The Databricks CLI provides a set of commands that allow you to interact with Databricks workspaces, clusters, and other resources from the command line.
    • The Databricks SDK (Python-based) allows you to programmatically manage Databricks resources using Python scripts.
    • You can use these tools to update table or column descriptions without altering the table itself1.
  2. SQL Syntax:

  3. REST API:

  4. Product Roadmap:

    • As for whether this feature is on the product roadmap, I will get back to you.

Remember to choose the approach that best fits your requirements and workflow. If you have any further questions or need additional assistance, feel free to ask! ๐Ÿ˜Š431

 

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