I want to automate the data classification in Snowflake.
So, first I created a list of tables along with their schemas and databases:
CREATE OR REPLACE TABLE "MY_CLASSIFICATION"."PUBLIC"."ALL_DATABASES_TABLE_LIST"
AS (
select table_schema,
table_name,
created as create_date,
last_altered as modify_date,
'SNOWFLAKE' as database_name
from "SNOWFLAKE".information_schema.tables
where table_type = 'BASE TABLE'
UNION ALL
select table_schema,
table_name,
created as create_date,
last_altered as modify_date,
'SNOWFLAKE_SAMPLE_DATA' as database_name
from "SNOWFLAKE_SAMPLE_DATA".information_schema.tables
where table_type = 'BASE TABLE'
order by table_schema,
table_name
);
Then I want to run the EXTRACT_SEMANTIC_CATEGORIES function to classify data by dynamically passing fully qualified name of the table, passing one record at a time from the table I’ve created above.
Like this:
select extract_semantic_categories('"SNOWFLAKE_SAMPLE_DATA"."TPCH_SF1"."CUSTOMER"');
Then I also need to pass dynamically the same to the stored procedure:
call associate_semantic_category_tags
('"SNOWFLAKE_SAMPLE_DATA"."TPCH_SF1"."CUSTOMER"' , (select * from MY_CLASSIFICATION."PUBLIC"."ALL_DATABASES_TABLE_LIST") );
Ho do i do it?
Thanks in advance for any help.