This document is a guide for anyone interested in contributing to dbt-adapters
.
It outlines how to install dbt-adapters
for development,
run tests locally, update documentation, and submit pull requests.
This guide assumes users are developing on a Linux or MacOS system.
The following utilities are needed or will be installed in this guide:
pip
hatch
git
changie
In addition to this guide, users are highly encouraged to read the dbt-core
CONTRIBUTING.md.
Almost all information there is applicable here.
git
is required to download, modify, and sync the dbt-adapters
code.
There are several ways to install Git. For MacOS:
- Install Xcode
- Install Xcode Command Line Tools
Contributors external to the dbt-labs
GitHub organization can contribute to dbt-adapters
by forking the dbt-adapters
repository. For more on forking, check out the
GitHub docs on forking. To contribute:
- Fork the
dbt-labs/dbt-adapters
repository (e.g.{forked-org}/dbt-adapters
) - Clone
{forked-org}/dbt-adapters
locally - Check out a new branch locally
- Make changes in the new branch
- Push the new branch to
{forked-org}/dbt-adapters
- Open a pull request in
dbt-labs/dbt-adapters
to merge{forked-org}/dbt-adapters/{new-branch}
intomain
Contributors in the dbt Labs
GitHub organization have push access to the dbt-adapters
repo.
Rather than forking dbt-labs/dbt-adapters
, use dbt-labs/dbt-adapters
directly. To contribute:
- Clone
dbt-labs/dbt-adapters
locally - Check out a new branch locally
- Make changes in the new branch
- Push the new branch to
dbt-labs/dbt-adapters
- Open a pull request in
dbt-labs/dbt-adapters
to merge{new-branch}
intomain
- Ensure the latest versions of
pip
andhatch
are installed:pip install --user --upgrade pip hatch
- This step is optional, but it's recommended. Configure
hatch
to create its virtual environments in the project. Add this block to yourhatch
config.toml
file:This makes# MacOS: ~/Library/Application Support/hatch/config.toml [dirs.env] virtual = ".hatch"
hatch
create all virtual environments in the project root inside of the directory/.hatch
, similar to/.tox
fortox
. It also makes it easier to add this environment as a runner in common IDEs like VSCode and PyCharm. - Create a
hatch
environment with all of the development dependencies and activate it:hatch run setup hatch shell
- Run any commands within the virtual environment by prefixing the command with
hatch run
:hatch run <command>
dbt-adapters
contains code quality checks and unit tests.
While dbt-tests-adapter
is also hosted in this repo, it requires a concrete adapter to run.
Code quality checks can run with a single command:
hatch run code-quality
Unit tests can be run locally without setting up a database connection:
# Note: replace $strings with valid names
# run all unit tests
hatch run unit-test
# run all unit tests in a module
hatch run unit-test tests/unit/$test_file_name.py
# run a specific unit test
hatch run unit-test tests/unit/$test_file_name.py::$test_class_name::$test_method_name
Some changes require a change in dbt-common
and dbt-adapters
.
In that case, the dependency on dbt-common
must be updated to point to the development branch. For example:
[tool.hatch.envs.default]
dependencies = [
"dbt-common @ git+https://github.com/dbt-labs/dbt-common.git@my-dev-branch",
...,
]
This will install dbt-common
as a snapshot. In other words, if my-dev-branch
is updated on GitHub, those updates will not be reflected locally.
In order to pick up those updates, the hatch
environment(s) will need to be rebuilt:
exit
hatch env prune
hatch shell
Many changes will require an update to dbt-adapters
user documentation.
All contributors, whether internal or external, are encouraged to open an issue or PR
in the docs repo when submitting user-facing changes. Here are some relevant links:
dbt-adapters
uses changie to generate CHANGELOG
entries.
Follow the steps to install changie
.
Once changie is installed and the PR is created, run:
changie new
changie
will walk through the process of creating a changelog entry.
Remember to commit and push the file that's created.
NOTE: Do not edit the
CHANGELOG.md
directly. Any modifications will be lost by the consolidation process.
NOTE: All contributors to
dbt-adapters
must sign the Contributor License Agreement(CLA).
Maintainers will be unable to merge contributions until the contributor signs the CLA. This is a one time requirement, not a per-PR requirement. Even without a CLA, anyone is welcome to open issues and comment on existing issues or PRs.
A dbt-adapters
maintainer will be assigned to review each PR based on priority and capacity.
They may suggest code revisions for style and clarity or they may request additional tests.
These are good things! dbt Labs believes that contributing high-quality code is a collaborative effort.
The same process is followed whether the contributor is external or another dbt-adapters
maintainer.
Once all tests are passing and the PR has been approved by the appropriate code owners,
a dbt-adapters
maintainer will merge the changes into main
.
And that's it! Happy developing 🎉