Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vibe-claudeing a duckdbt CLI #520

Merged
merged 2 commits into from
Mar 14, 2025
Merged

Vibe-claudeing a duckdbt CLI #520

merged 2 commits into from
Mar 14, 2025

Conversation

jwills
Copy link
Collaborator

@jwills jwills commented Mar 14, 2025

Been playing with the new DuckDB UI stuff and Claude Code a lot this week and cooked up something simple that does what I've always wanted to be able to do with dbt and DuckDB: run the dbt-duckdb process in a shell process where I could simultaneously query the DuckDB instance via a UI and run my dbt-duckdb models in a high-fidelity way, with all of the python model execution and all of the other great stuff we've built in this project over the last few years.

The idea is to create a cli.py and a new duckdbt shell command that uses the dbtRunner construct to load up dbt, parse all of the models in a project using a given profile, and let you run command invocations in the CLI while simultaneously launching the DuckDB UI via a CALL start_ui() call against the instance of DuckDB that gets loaded and configured when dbt debug is called.

Copy link
Collaborator

@guenp guenp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

This is pretty cool

@jwills jwills merged commit d26ae6f into master Mar 14, 2025
33 checks passed
@jwills jwills deleted the jwills_duckdbt_cli branch March 14, 2025 18:27
@b-per
Copy link
Contributor

b-per commented Mar 19, 2025

It worked super well, thanks!
The only thing is that we then lose the shell completion capabilities for models and integrations like https://github.com/Infused-Insight/fzf-dbt

@jwills
Copy link
Collaborator Author

jwills commented Mar 19, 2025

@b-per ah, interesting-- let me see if I can get Claude to add something like that back in...

@dbeatty10
Copy link
Contributor

For anyone that wants to try this out, I did the following steps within a Python virtual environment.

First, cd to a directory on your filesystem that has a dbt project that has a dbt-duckdb connection profile.

If you don't already have one, here's an easy and fast way to get one:

git clone https://github.com/dbt-labs/jaffle_shop_duckdb.git
cd jaffle_shop_duckdb

Then install dbt-duckdb (and dependencies) from source:

python -m pip install git+https://github.com/duckdb/dbt-duckdb.git@master

Note

Once the duckdbt CLI is included in the latest release of dbt-duckdb, then it will be just this instead of installing from source:

python -m pip install --upgrade dbt-duckdb

Then start using this CLI (which will open a window in your default web browser containing the DuckDB UI):

duckdbt

You'll probably need to rearrange your windows so that browser window is stacked on top of your terminal window (or however else you like it).

Then in the terminal you can run your typical dbt sub commands (just drop the dbt prefix):

build
list
build -s stg_customers

And in the DuckDB UI window you can run queries:

select * from stg_customers

@jwills
Copy link
Collaborator Author

jwills commented Mar 22, 2025

Ah @dbeatty10 , nice to see you! Checkout #524 !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants