This file instructs AI coding agents on how to navigate, build, test, and contribute to this repository.
dbt-adapters/
├── dbt-adapters/ # Base framework (BaseAdapter, SQLAdapter, contracts, catalogs)
├── dbt-tests-adapter/ # Shared test suite for all adapters
├── dbt-postgres/ # PostgreSQL adapter
├── dbt-redshift/ # Redshift adapter (extends dbt-postgres)
├── dbt-snowflake/ # Snowflake adapter
├── dbt-bigquery/ # BigQuery adapter
├── dbt-spark/ # Spark / Databricks adapter
└── dbt-athena/ # AWS Athena adapter
Each adapter is an independent Python package with its own pyproject.toml, hatch.toml, and test suite.
All commands are run from within the specific adapter's directory, not the repo root.
cd dbt-{adapter} # e.g., cd dbt-redshift
pip install hatch changie # if not already installed; changie is needed for changelog entries
hatch run setup # installs adapter + deps in editable mode (includes pre-commit)Note:
pre-commitis managed as a hatch environment dependency — you do not need to install it globally.hatch run setupinstalls it inside the hatch virtualenv and registers the git hooks.changieis a standalone tool used outside of hatch for changelog management and must be installed separately as shown above.
To configure the virtual environment for IDE use:
hatch config set dirs.env.virtual .hatchhatch run code-quality # runs Black (format), Flake8 (lint), MyPy (types)Always run this before submitting changes. Fix all errors before committing.
hatch run unit-tests
# Run a specific test
hatch run unit-tests -- tests/unit/test_file.py::ClassName::test_method -vUnit tests live in tests/unit/. They test Python logic without a live database.
hatch run integration-testsIntegration tests live in tests/functional/. They require a test.env file with credentials (never commit this file). See test.env.example for required variables.
For dbt-redshift only, flaky tests can be run sequentially:
hatch run integration-tests-flakyTests inherit from dbt-tests-adapter base classes:
from dbt.tests.adapter.basic import BaseSimpleMaterializations
class TestSimpleMaterializations(BaseSimpleMaterializations):
pass- SQL behavior changes: edit macros in
src/dbt/include/{adapter}/macros/ - Python behavior changes: edit
src/dbt/adapters/{adapter}/impl.py - Connection/credential changes: edit
src/dbt/adapters/{adapter}/connections.py - Relation config changes: edit
src/dbt/adapters/{adapter}/relation.pyorrelation_configs/ - Base framework changes: make changes in
dbt-adapters/and check impact on all adapters
Override default macros by prefixing with the adapter name:
-- src/dbt/include/{adapter}/macros/adapters.sql
{% macro {adapter}__list_relations_without_caching(schema_relation) %}
-- adapter-specific SQL
{% endmacro %}Use the @available decorator:
from dbt.adapters.base.meta import available
class MyAdapter(SQLAdapter):
@available
def my_method(self):
"""Callable in Jinja as adapter.my_method()"""
passfrom dbt.adapters.capability import Capability, CapabilitySupport, CapabilityDict, Support
class MyAdapter(SQLAdapter):
_capabilities = CapabilityDict({
Capability.SchemaMetadataByRelations: CapabilitySupport(support=Support.Full),
})Every user-facing change requires a changelog entry:
changie newCategories: Breaking Changes, Features, Fixes, Under the Hood, Dependencies, Security
When modifying base packages, check downstream impact:
- Changes to
dbt-adaptersaffect all adapters - Changes to
dbt-postgresaffect dbt-redshift - Changes to
dbt-tests-adapteraffect all adapter test suites
The dbt-adapters/src/dbt/adapters/catalogs/ package provides a plugin system for external table formats (Apache Iceberg, etc.):
CatalogIntegration— abstract base; implementbuild_relation(model)CatalogIntegrationClient— registry; passSUPPORTED_CATALOGSlist in adapter__init__- Validate required config in
__init__and raiseInvalidCatalogIntegrationConfigError
Existing implementations: Snowflake iceberg_rest, Snowflake built_in, BigQuery biglake.
- Never commit
test.envor any file containing credentials - Never hardcode credentials, tokens, or access keys in source files
- Treat
test.env.exampleas the authoritative list of required env vars (no values)
- Code quality passes:
hatch run code-quality - Unit tests pass:
hatch run unit-tests - Integration tests pass against a real database (if changing SQL or connection logic)
- Changelog entry added via
changie new -
test.envnot committed - New adapter methods decorated with
@availableif needed in macros - Capabilities updated if new features are added