Skip to content

Instantly share code, notes, and snippets.

import dataclasses
@dataclasses.dataclass
class MyClass:
a: dataclasses.InitVar[int]
_a: int = dataclasses.field(init=False)
def __post_init__(self, a: int) -> None:
self._a = a

When you dbt compile, dbt at a very high level does this:

  1. read your dbt_project.yml in, rendering most fields with jinja (hooks and query comments are deferred until later, when they can have more information available). Any projects in your modules directory are also read in and rendered - consider them part of "your project" when reading.
  2. read your profiles.yml in, rendering everything with jinja
  3. find all the relevant files (.sql, .yml) and read them in, as defined in your dbt_project.yml
  4. dbt renders each sql file with jinja, primarily collecting calls to ref, source, and config. The string result of the actual rendering is then discarded. The model's materialization type is finalized here, as are any other relevant model-level configuration items (database/schema/alias are easy examples here!).
  5. build a dependency graph using the ref information and use the command-line arguments to decide which nodes to iterate over
  6. for each selected node, in "graph order":
@beckjake
beckjake / rpc.py
Created March 8, 2019 18:03
rpc cli client
#!/usr/bin/env python
import argparse
import base64
import code
import json
import pprint
import requests
%YAML 1.2
---
name: dbt SQL
file_extensions:
- sql
scope: source.dbt
contexts:
main:
# the default context is SQL

Keybase proof

I hereby claim:

  • I am beckjake on github.
  • I am beckjake (https://keybase.io/beckjake) on keybase.
  • I have a public key whose fingerprint is F979 644F 03B3 276D 5D60 6C92 D0BC F949 5593 59B8

To claim this, I am signing this object:

### Keybase proof
I hereby claim:
* I am beckjake on github.
* I am beckjake (https://keybase.io/beckjake) on keybase.
* I have a public key whose fingerprint is 749E 3A52 3347 E1A3 9971 03CE 9F5D CD08 29F2 6899
To claim this, I am signing this object: