AI_GENERATE_TABLE_DESC¶
Generates and returns a description for a table or view. Optionally, the stored procedure can also generate descriptions for the columns of the table or view.
The stored procedure uses the Snowflake Cortex COMPLETE function to automatically generate descriptions.
Syntax¶
AI_GENERATE_TABLE_DESC(
<table_name>
[ , <config_object> ] )
Required arguments¶
table_nameSpecifies the table or view that you want to generate a description for.
Optional arguments¶
config_objectAn OBJECT that specifies whether you want to generate column descriptions and use sample data for those descriptions. You can use an OBJECT constant to specify this object.
The OBJECT value has the following structure:
{ 'describe_columns': <boolean>, 'use_table_data': <boolean> {
describe_columnsIf set to TRUE, the stored procedure generates descriptions for all columns of the table.
use_table_dataIf set to TRUE, the stored procedure uses sample data from the table to generate column descriptions, which can improve the accuracy of the descriptions. If FALSE, the stored procedure relies on metadata to generate the descriptions.
Returns¶
Returns a JSON string with the following fields:
COLUMNSContains an array of columns for which descriptions were generated. This field is only returned if descriptions were generated for columns.
The array contains the following fields for each column of the table:
database_nameDatabase that contains the column.
descriptionDescription of the column that was generated by the stored procedure.
nameName of the column.
schema_nameSchema that contains the column.
table_nameTable or view that contains the column.
TABLEContains an array that includes the description of the table along with general information about the table. The array consists of the following fields:
database_nameDatabase that contains the table.
descriptionDescription of the table that was generated by the stored procedure.
nameName of the table or view.
schema_nameSchema that contains the table.
Access control requirements¶
Users must have the following privileges and roles to call the AI_GENERATE_TABLE_DESCRIPTION stored procedure:
SELECT privilege on the table or view.
SNOWFLAKE.CORTEX_USER database role.
Usage notes¶
Your region must support the LLM used by Snowflake Cortex to generate the descriptions. Check the availability of the COMPLETE function. If the COMPLETE function is not supported in your region, you must enable cross-region inference to use the feature.
Examples¶
Generate a description for view v1.
CALL AI_GENERATE_TABLE_DESC( 'v1');
{
"TABLE": [
{
"database_name": "mydb",
"description": " The table contains records of customer addresses. Each record includes a name and zip code.",
"name": "v1",
"schema_name": "sch1"
}
]
}
Generate descriptions for the table hr_data and all of its columns. Use metadata only to generate the descriptions.
CALL AI_GENERATE_TABLE_DESC(
'mydb.sch1.hr_data',
{
'describe_columns': true,
'use_table_data': false
});
{
"COLUMNS": [
{
"database_name": "mydb",
"description": "A column holding data of type DecimalType representing age values.",
"name": "AGE",
"schema_name": "sch1",
"table_name": "hr_data"
},
{
"database_name": "mydb",
"description": "The first name of the employee.",
"name": "FNAME",
"schema_name": "sch1",
"table_name": "hr_data"
}
],
"TABLE": [
{
"database_name": "mydb",
"description": " The table contains records of employee data, specifically demographic information. Each record includes an employee's age and name.",
"name": "hr_data",
"schema_name": "sch1"
}
]
}