dbt Documentation

repository·main·Indexed 41 days ago

https://github.com/dbt-labs/dbt-docs

Tools and source code for generating a visual, searchable documentation website for dbt projects. Includes functionality to visualize models, tests, and data lineage via a web interface, with commands like `dbt docs generate` and `dbt docs serve` to create and host project metadata.

Tokens
646
Snippets
4
Records
5
Agent score
1%

What's inside dbt

  1. What is dbt-docs?

    main
    dbt-docs is the codebase responsible for generating the documentation website for dbt projects. It transforms dbt project metadata into a visual, searchable documentation site that helps analysts understand their models, tests, and data lineage.
  2. Generate and serve dbt documentation

    main

    To view the documentation site for your dbt project, you must first generate the documentation artifacts and then start a local web server to host them. Run these commands from within your dbt project directory:

    1. dbt docs generate: This command parses your project and generates the necessary JSON files containing your project's metadata, models, tests, and lineage.
    2. dbt docs serve: This command starts a local web server to view the generated documentation in your browser.
    dbt docs generate
    dbt docs serve
  3. Retrieve descendant nodes with descendentNodes()

    main

    The descendentNodes(dag, node, max_hops, hop_index) function traverses the DAG downwards from a given node to find its successors.

    • dag: The graph object (must support .successors(node)).
    • node: The starting node.
    • max_hops (optional): The maximum number of levels to traverse downwards.
    • hop_index (optional): Internal tracker for recursion depth.

    Returns an array of unique descendant nodes.

    // Get all descendants up to 2 hops away
    const descendants = descendentNodes(dag, node, 2);
  4. Select a node and its related lineage with selectAt()

    main

    The selectAt(dag, node) function returns a collection of nodes representing a specific lineage pattern: it includes the target node, all of its descendants, and all ancestors of those descendants. This is useful for highlighting a node and its entire upstream/downstream impact area within a Directed Acyclic Graph (DAG).

    // Returns all parents of all children of the node
    const selectedNodes = selectAt(dag, node);
  5. Retrieve ancestor nodes with ancestorNodes()

    main

    The ancestorNodes(dag, node, max_hops, hop_index) function traverses the DAG upwards from a given node to find its predecessors.

    • dag: The graph object (must support .predecessors(node)).
    • node: The starting node.
    • max_hops (optional): The maximum number of levels to traverse upwards.
    • hop_index (optional): Internal tracker for recursion depth.

    Returns an array of unique ancestor nodes.

    // Get all ancestors up to 3 hops away
    const ancestors = ancestorNodes(dag, node, 3);