Hi everyone
iam trying to fetch the metadata of every columns from an table and every tables from the database under an catalogue for that iam trying to use the samples catalogue that provided by databricks and get details for tpch database that provided by databricks with sample data in it
as iam prettymuch new to extract informations from unity catalogue iam unable to make an query that can be used to fetch the required information in databricks sql ui so DBRX LLM suggested me to use this code to make use of it in query editor but unfortunately iam unable to identify the mistakes or iam not even sure how to improvise the code ill share the code below please someone suggest me if this approach or if there is anyother approach that can be used to generate an metadata
USE samples;
DECLARE @table_name STRING;
DECLARE @column_name STRING;
DECLARE @SQL STRING;
DECLARE table_cursor CURSOR FOR
SELECT table_name FROM information_schema.tables WHERE table_schema = 'tpch';
OPEN table_cursor;
FETCH NEXT FROM table_cursor INTO @table_name;
WHILE @@FETCH_STATUS = 0
BEGIN
DECLARE column_cursor CURSOR FOR
SELECT column_name FROM information_schema.columns WHERE table_name = @table_name;
OPEN column_cursor;
FETCH NEXT FROM column_cursor INTO @column_name;
WHILE @@FETCH_STATUS = 0
BEGIN
SET @SQL = 'DESCRIBE TABLE EXTENDED tpch.`' + @table_name + '`.`' + @column_name + '`';
EXECUTE IMMEDIATE @SQL;
FETCH NEXT FROM column_cursor INTO @column_name;
END;
CLOSE column_cursor;
FETCH NEXT FROM table_cursor INTO @table_name;
END;
CLOSE table_cursor;
DEALLOCATE table_cursor;