dbt-vertica
dbt-vertica is the official adapter plugin for dbt (data build tool) that enables dbt to connect and transform data in Vertica databases. It leverages `vertica-python` for database connectivity and supports various dbt materializations and features. The library is actively maintained by Vertica, with the current version being 1.8.5, and follows the release cadence of dbt Core.
Warnings
- breaking Beginning in dbt Core v1.8, adapter installations no longer automatically include `dbt-core`. Users must explicitly install `dbt-core` alongside `dbt-vertica` to ensure a working environment.
- breaking For incremental models using 'delete+insert' or 'merge' strategies, the `merge_columns` config parameter was refactored to `unique_key` and is now a required parameter. Existing models using `merge_columns` will cause errors.
- gotcha The `on_schema_change` parameter for incremental models in dbt-vertica does not support the `sync_all_columns` value. Only `ignore`, `fail`, and `append_new_columns` are currently supported.
- deprecated In dbt Core v1.8, custom defaults for global config flags in `profiles.yml` have been deprecated. These flags should now be set in the `flags` dictionary within your `dbt_project.yml`.
Install
-
pip install dbt-core dbt-vertica -
pip install dbt-vertica
Imports
- dbt-vertica
dbt-vertica is a dbt adapter and is not typically imported directly into user Python code. Its functionality is exposed via dbt CLI commands and YAML configurations (e.g., profiles.yml, dbt_project.yml).
Quickstart
# 1. Install dbt-vertica and dbt-core (recommended for dbt Core >= 1.8)
pip install dbt-core dbt-vertica
# 2. Initialize a new dbt project
dbt init my_vertica_project
cd my_vertica_project
# 3. Configure your profiles.yml (usually located at ~/.dbt/profiles.yml)
# Ensure you replace placeholders or set environment variables.
# Example profiles.yml entry (use your actual values or env vars):
# my_vertica_profile:
# target: dev
# outputs:
# dev:
# type: vertica
# host: "{{ env_var('DBT_VERTICA_HOST') }}"
# port: "{{ env_var('DBT_VERTICA_PORT', 5433) | as_number }}"
# username: "{{ env_var('DBT_VERTICA_USERNAME') }}"
# password: "{{ env_var('DBT_VERTICA_PASSWORD') }}"
# database: "{{ env_var('DBT_VERTICA_DATABASE') }}"
# schema: "{{ env_var('DBT_VERTICA_SCHEMA') }}"
# 4. Set environment variables (replace with your Vertica connection details)
import os
os.environ['DBT_VERTICA_HOST'] = os.environ.get('DBT_VERTICA_HOST', 'your_vertica_host')
os.environ['DBT_VERTICA_PORT'] = os.environ.get('DBT_VERTICA_PORT', '5433')
os.environ['DBT_VERTICA_USERNAME'] = os.environ.get('DBT_VERTICA_USERNAME', 'your_username')
os.environ['DBT_VERTICA_PASSWORD'] = os.environ.get('DBT_VERTICA_PASSWORD', 'your_password')
os.environ['DBT_VERTICA_DATABASE'] = os.environ.get('DBT_VERTICA_DATABASE', 'your_database')
os.environ['DBT_VERTICA_SCHEMA'] = os.environ.get('DBT_VERTICA_SCHEMA', 'your_schema')
# 5. Test the connection
dbt debug --target dev --profile my_vertica_project
# 6. Create your first model (e.g., models/my_first_model.sql)
# SELECT 1 as id, 'Hello dbt!' as message
# 7. Run your dbt models
dbt run --profile my_vertica_project