Skip to content

feat: dlt.Schema.to_mermaid() #3316

@zilto

Description

@zilto

Add a mechanism to export the dlt.Schema as a Mermaid diagram string

Image

Motivation

Mermaid is a diagram format supported in many places:

  • GitHub markdown (great for README, PR comments)
  • marimo (dlt Dashboard, interactive notebook)
  • IDE chat windows (e.g., Copilot, Cursor, Continue)

The key usecase is visualizing the dlt.Schema directly inside the AI chat window. This is not possible with the existing DBML and DOT exports.

Implementation

The implementation should match the .to_dot() (graphviz) and .to_dbml() PRs.

  • Create a module dlt/helpers/mermaid.py
  • Build the diagram by manipulating strings without additional Python dependencies
  • Write modular functions and tests for generating columns, tables, etc.
  • Add dlt.Schema.to_mermaid() method
  • Add to the CLI dlt schema --format mermaid FILE and dlt pipeline NAME schema --format mermaid
  • Update CLI docs
  • Add example export to the docs

Key consideration: Try to support converting the schema dlt -> mermaid AND mermaid -> dlt when possible. This makes testing easier. But it's likely impossible. For example, the DBML export doesn't support all possible column attributes

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    Status

    In Progress

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions