Skip to content

Commit 48f5ff6

Browse files
authored
Merge pull request #2 from duneanalytics/update-docs
update docs
2 parents 86f35b3 + 6d9734c commit 48f5ff6

File tree

4 files changed

+566
-71
lines changed

4 files changed

+566
-71
lines changed

QUICKSTART.md

Lines changed: 127 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,28 @@
11
# Quick Start Guide
22

3+
Get up and running with the Dune DBT Template in minutes.
4+
35
## Setup Checklist
46

57
- [x] ✅ uv project initialized
68
- [x] ✅ dbt-core and dbt-trino installed
7-
- [x] ✅ dbt project created
8-
- [ ] ⏳ Activate virtual environment with `source .venv/bin/activate`
9-
- [ ] ⏳ Configure your Trino connection in `~/.dbt/profiles.yml`
9+
- [x] ✅ dbt project created with example models
10+
- [x] ✅ Custom Dune macros configured
11+
- [x] ✅ GitHub Actions workflow ready
12+
- [ ] ⏳ Install dependencies with `uv sync`
13+
- [ ] ⏳ Install dbt packages with `dbt deps`
14+
- [ ] ⏳ Configure your Dune connection in `~/.dbt/profiles.yml`
1015
- [ ] ⏳ Test connection with `dbt debug`
1116

1217
## Next Steps
1318

14-
### 1. Activate Virtual Environment (Recommended)
19+
### 1. Install Dependencies
1520

1621
```bash
17-
# Activate the virtual environment
22+
# Install Python dependencies
23+
uv sync
24+
25+
# Activate the virtual environment (recommended)
1826
source .venv/bin/activate
1927

2028
# Your prompt should now show (.venv) prefix
@@ -23,28 +31,40 @@ source .venv/bin/activate
2331

2432
> **Alternative:** Skip activation and prefix all commands with `uv run` (e.g., `uv run dbt debug`)
2533
26-
### 2. Configure Your Connection
34+
### 2. Install dbt Packages
35+
36+
```bash
37+
# Install dbt_utils and other packages
38+
dbt deps
39+
```
40+
41+
### 3. Configure Your Dune Connection
2742

2843
```bash
2944
# Create dbt config directory
3045
mkdir -p ~/.dbt
3146

3247
# Copy example profile
33-
cp profiles.yml.example ~/.dbt/profiles.yml
48+
cp profiles_example_file.yml ~/.dbt/profiles.yml
3449

35-
# Edit with your Trino connection details
50+
# Edit with your Dune connection details
3651
nano ~/.dbt/profiles.yml # or use your preferred editor
3752
```
3853

3954
**Required settings in `profiles.yml`:**
40-
- `host`: Your Trino/Starburst server hostname
41-
- `port`: Usually 443 for TLS-enabled clusters
42-
- `database`: Catalog name in Trino
43-
- `schema`: Schema within the catalog
44-
- `user`: Your username
45-
- `password`: Your password (for LDAP auth)
4655

47-
### 3. Test Your Connection
56+
For the `dbt_template_api` profile:
57+
- `host`: `dune-api-trino.dune.com` (prod) or `dune-api-trino.dev.dune.com` (dev)
58+
- `port`: `443`
59+
- `method`: `ldap`
60+
- `catalog`: `delta_prod`
61+
- `schema`: Your team name (e.g., `dune`)
62+
- `user`: Your team name
63+
- `password`: Your Dune API key
64+
- `session_properties.transformations`: `true` (required!)
65+
- `http_scheme`: `https`
66+
67+
### 4. Test Your Connection
4868

4969
```bash
5070
# With activated venv (recommended):
@@ -59,37 +79,81 @@ You should see:
5979
All checks passed!
6080
```
6181

62-
### 4. Run Your First Models
82+
### 5. Run the Example Models
6383

6484
```bash
65-
# Run the example models (venv activated)
85+
# Run all models (venv activated)
6686
dbt run
6787

6888
# Expected output:
69-
# - 2 models will be created as views in your Trino schema
89+
# - dbt_template_view_model (view)
90+
# - dbt_template_table_model (table)
91+
# - dbt_template_incremental_model (incremental)
92+
```
93+
94+
### 6. Run Tests
95+
96+
```bash
97+
# Run all tests
98+
dbt test
99+
100+
# You should see the unique_combination_of_columns test pass
70101
```
71102

72-
### 5. Explore the Example Models
103+
### 7. Explore the Example Models
104+
105+
The template includes three example models that demonstrate different materializations:
106+
107+
**View Model** (`models/dbt_template_view_model.sql`):
108+
- Lightweight, always fresh
109+
- Counts transactions per block for last day
110+
- Good for fast-changing data
111+
112+
**Table Model** (`models/dbt_template_table_model.sql`):
113+
- Static snapshot
114+
- Uses `on_table_exists='replace'` for Dune compatibility
115+
- Good for static or slowly changing data
73116

74-
Look at these files to understand the structure:
75-
- `models/example/my_first_dbt_model.sql`
76-
- `models/example/my_second_dbt_model.sql`
77-
- `models/example/schema.yml`
117+
**Incremental Model** (`models/dbt_template_incremental_model.sql`):
118+
- Efficient updates with merge strategy
119+
- Processes last 1 day incrementally, last 7 days on full refresh
120+
- Includes `dbt_utils` test for uniqueness
121+
- Good for large, append-only datasets
78122

79-
### 6. Create Your Own Models
123+
### 8. Test Incremental Updates
124+
125+
```bash
126+
# Run with full refresh
127+
dbt run --full-refresh
128+
129+
# Run incrementally (only processes last day)
130+
dbt run
131+
132+
# The incremental model should update efficiently
133+
```
134+
135+
### 9. Create Your Own Models
80136

81137
```bash
82138
# Create a new model file
83-
cat > models/my_model.sql << 'EOF'
84-
{{ config(materialized='table') }}
139+
cat > models/my_ethereum_model.sql << 'EOF'
140+
{{ config(
141+
schema='test_schema',
142+
alias='my_ethereum_model',
143+
materialized='table'
144+
) }}
85145
86146
select
87-
1 as id,
88-
'example' as name
147+
block_date,
148+
count(distinct "from") as unique_senders,
149+
count(*) as tx_count
150+
from {{ source('ethereum', 'transactions') }}
151+
where block_date >= now() - interval '7' day
152+
group by block_date
89153
EOF
90154

91155
# Run just your new model (venv activated)
92-
dbt run --select my_model
156+
dbt run --select my_ethereum_model
93157
```
94158

95159
## Common Commands
@@ -127,22 +191,46 @@ deactivate
127191
uv run dbt <command>
128192
```
129193

194+
## Understanding the CI/CD Pipeline
195+
196+
When you open a pull request, the GitHub Actions workflow automatically:
197+
198+
1. ✅ Checks out your code
199+
2. ✅ Installs dependencies
200+
3. ✅ Waits for Trino cluster (up to 10 minutes)
201+
4. ✅ Compiles all models
202+
5. ✅ Runs full refresh
203+
6. ✅ Tests all models
204+
7. ✅ Runs incremental update
205+
8. ✅ Tests again to verify incremental logic
206+
207+
All models in CI use the `test_schema` (configured in `generate_schema_name` macro).
208+
130209
## Troubleshooting
131210

132211
### "Profile not found" error
133212
- Make sure `~/.dbt/profiles.yml` exists
134-
- Verify the profile name matches `dbt_template` (as set in `dbt_project.yml`)
213+
- Verify the profile name is `dbt_template_api` (as set in `dbt_project.yml`)
214+
- Check that you copied from `profiles_example_file.yml`
135215

136216
### Connection errors
137-
- Check your Trino host, port, and credentials
138-
- Test connectivity: `curl https://your-trino-host:443`
139-
- Verify catalog and schema exist and you have access
140-
141-
### "keyring module not found" warning
142-
This is just a warning. OAuth tokens won't be cached, but LDAP/JWT/other auth methods work fine. To fix:
143-
```bash
144-
uv add 'trino[external-authentication-token-cache]'
145-
```
217+
- Check your Dune API key and team name
218+
- Verify `transformations: true` in session properties
219+
- Test with: `dbt debug`
220+
- Check host: `dune-api-trino.dune.com` (not `.dev.dune.com` for prod)
221+
222+
### "dbt_utils not found" error
223+
- Run `dbt deps` to install packages
224+
- Check that `packages.yml` exists
225+
226+
### Incremental model not updating
227+
- Verify `unique_key` is set correctly
228+
- Check incremental logic with: `dbt compile --select dbt_template_incremental_model`
229+
- Use `--full-refresh` to rebuild: `dbt run --full-refresh`
230+
231+
### CI/CD workflow stuck on "Waiting for runner"
232+
- Ensure your repo has access to the `spellbook-trino-ci` self-hosted runner
233+
- Check with your GitHub org admin to enable runner access
146234

147235
## Documentation
148236

0 commit comments

Comments
 (0)