dbt Integration
dbt Integration
Section titled “dbt Integration”sup CLI can synchronize your dbt models with Superset datasets, keeping your analytics stack in sync.
Prerequisites
Section titled “Prerequisites”- dbt Core or dbt Cloud project
- Superset/Preset workspace with database connections
dbt Core Integration
Section titled “dbt Core Integration”Configure dbt paths:
sup config set dbt-project-dir /path/to/dbt/projectsup config set dbt-profiles-dir ~/.dbtSync Models to Datasets
Section titled “Sync Models to Datasets”# Sync all modelssup dataset sync-dbt
# Sync specific modelssup dataset sync-dbt --models staging.sales,marts.revenue
# With custom targetsup dataset sync-dbt --target productiondbt Cloud Integration
Section titled “dbt Cloud Integration”Configure dbt Cloud credentials:
sup config set dbt-cloud-account-id 12345sup config set dbt-cloud-project-id 67890sup config set dbt-cloud-job-id 11111sup config set dbt-cloud-api-token "your-token"Sync from dbt Cloud
Section titled “Sync from dbt Cloud”# Sync from latest runsup dataset sync-dbt-cloud
# Sync from specific runsup dataset sync-dbt-cloud --run-id 123456Mapping Configuration
Section titled “Mapping Configuration”Create a dbt_mapping.yml file:
models: staging.customers: superset_dataset: "STG_CUSTOMERS" metrics: - name: customer_count expression: COUNT(DISTINCT customer_id) - name: total_revenue expression: SUM(revenue)
marts.sales: superset_dataset: "SALES_FACT" time_column: order_date dimensions: - customer_id - product_id - regionExposures
Section titled “Exposures”Generate dbt exposures from Superset:
# Generate exposures YAMLsup chart export-exposures > models/exposures.yml
# Include in dbt projectsup chart export-exposures --output models/exposures/superset.ymlBest Practices
Section titled “Best Practices”- Use consistent naming between dbt models and Superset datasets
- Document metrics in dbt and sync to Superset
- Version control your mapping configurations
- Test in staging before syncing to production
- Use CI/CD to automate sync on dbt runs