0

Is there a way to export schema(s), table(s), columns and their dependencies as a diagram in Snowflake? It'd be great to achieve initial sorts of an ERD, such as this one in the picture: https://www.snowflake.com/blog/using-snowflake-information-schema/ Best wishes, I

enter image description here

I looked for features/functionalities in the cloud and desktop clients. However, I found nothing similar.

I wonder if I could wrap a script in DBT to solve problems like these.

2
  • some solutions here: community.snowflake.com/s/article/…
    – tconbeer
    Jan 26 at 17:46
  • Just about every data modelling tool can reverse engineer an existing database. However recommending specific products is not part of the scope of this forum
    – NickW
    Feb 10 at 17:50

1 Answer 1

0

I've had some success on this with through LucidCharts' ERD tool (can't remember right now if it requires the paid version or not) but generally you'd run something like the snowflake converted version of their postgres script:

use database my_database;

use warehouse snowflake_wh;

SELECT
    'postgresql' AS dbms,
    t.table_catalog,
    t.table_schema,
    t.table_name,
    c.column_name,
    c.ordinal_position,
    c.data_type,
    c.character_maximum_length,
    null as constraint_type,
    null as "k2.table_schema",
    null as "k2.table_name",
    null as "k2.column_name"
FROM
    information_schema.COLUMNS c
    left join information_schema.TABLES t on t.TABLE_CATALOG = c.TABLE_CATALOG
    AND t.TABLE_SCHEMA = c.TABLE_SCHEMA
    AND t.TABLE_NAME = c.TABLE_NAME
WHERE
    t.table_type = 'BASE TABLE'
    AND t.table_schema NOT IN('information_schema');

And then upload back into the tool as a csv export.

enter image description here

Result:

enter image description here

Which, I have not experimented heavily with making it play nicely with views & references, so far just base tables and then doing the column references myself.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.