cancel
Showing results forย 
Search instead forย 
Did you mean:ย 
Generative AI
Explore discussions on generative artificial intelligence techniques and applications within the Databricks Community. Share ideas, challenges, and breakthroughs in this cutting-edge field.
cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Automate AI comment generation for columns

25Tabs
New Contributor

Hello, 

I have a question regarding the new AI Comment generation feature. Is it possbile to use this feature without using the UI. Currently i have to accept every suggested comment one-by-one. Is there a feature / SQL or Phython Statement that i can use to auto update multiple tables and their collumns with the AI generated comments feature?

 

2 REPLIES 2

DoTA
Valued Contributor II

Short answer: no, there's no REST API or SQL statement that bulk-accepts the AI-generated comment suggestions you see in Catalog Explorer - that Accept/checkmark flow is UI-only, there's no endpoint behind it.

 

The workaround people actually use is to skip the "suggest then accept" UI feature entirely and generate + apply the comments yourself with ai_query(), which is a regular SQL function so it's fully scriptable:

 

1. Loop over information_schema.columns for the tables/schemas you care about.

2. For each column, call ai_query() against a serving endpoint (a pay-per-token FM like databricks-meta-llama-3-3-70b-instruct works fine for this) with a prompt that includes the table name, column name, data type, and maybe a few sample values.

3. Apply the result with ALTER TABLE catalog.schema.table ALTER COLUMN col COMMENT '<generated text>' (or COMMENT ON COLUMN ... IS '...').

 

That whole loop can be a single notebook/Python script driven off the catalog metadata, so you comment hundreds of columns without touching the UI. A couple of things worth building in:

- Batch it per-table and commit as you go, so a bad generation on one column doesn't block the rest.

- Sanity-check the AI output before applying (strip quotes/newlines, length-cap it) since ALTER COLUMN COMMENT will happily accept garbage.

- If you want a human-in-the-loop step without the UI, write the generated comments to a staging table first and review/approve there before the ALTER pass.

 

This is a known gap, not something you're missing - the Catalog Explorer feature and the ai_query()-based approach are two separate things under the hood.

ThiamLee
Contributor

Great question! It would be really useful to have an API or SQL/Python way to generate and apply AI comments in bulk instead of accepting them one by one. Hopefully Databricks can support this workflow. ๐Ÿš€