Replies: 3 comments 2 replies
-
|
hot fire flame 🔥 right here |
Beta Was this translation helpful? Give feedback.
-
|
This is so cool!
|
Beta Was this translation helpful? Give feedback.
-
|
Nice! To follow up on Pat's notes, a similar (but slightly different) approach would be to consume the dbt manifest and catalog files directly instead of querying the DW. This repo is a python script that creates a The advantage of this approach is that it is compatible across Warehouses. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Background
What is an ERD?
An ERD, or entity-relationship diagram, is a graphical representation of data - showing entities, their attributes, and how they can relate to other entities.
Setup
Docs (source code)
Create a docs block containing a link to your soon-to-be-created ERD:
{% docs tpch_source %} Check out the TPCH ERD!  {% enddocs %}You'll notice that I created an
assetsfolder to store my ERDs - the location is up to you!Then, add your block to a yml file:
Python (source code)
The python script should do the following:
Identify the schemas you'd like to generate an ERD for:
Run a job specifically created for a merge to main. Think of this as a good time to run those newly merged models and anything downstream (or simply a
dbt compileanddbt docs generatewill suffice)Create a database URL. I'm using the snowflake-sqlalchemy package and the
URLutility to create my database URL. Other dialects can be found here.Finally, create an ERD using the eralchemy package.
Github Action (source code)
The action will be triggered when a pull request is merged to our main branch:
An important callout here is that we need to install
graphvizand its dependencies in order forpygraphvizto work properly.Then, our python dependencies are installed via
requirements.txtand our python script from above is run. Ensure that you have the appropriate environment variables set via secrets stored within your repo.The python script will create
.pngfiles and the last step will add those newly created files directly to yourmainbranch.Caveats
I'm using the dbt_constraints package to automatically create foreign keys via an
on-run-endhook. Currently, this package is only compatible with Snowflake and PostgreSQL.Output
Beta Was this translation helpful? Give feedback.
All reactions