To start using Elementary, you need to add our dbt package to your dbt project.
A dbt package is additional Jinja and SQL code that is added to your project, for additional functionality. In fact, each package is a dbt project. By adding a package to your project, you are adding the package code to be part of your project, you can reference its macros, execute its models, and so on.
Add packages to your project by creating a packages.yml file under the main project directory (where your dbt_project.yml is), and adding the relevant package. After you add a new package, run dbt deps to actually pull its code to your project. This is also how you update packages.
Some packages we recommend you check out: dbt_utils, dbt_date, codegen.
This means Elementary models will have their own schema.
Depending on your project custom schema macro, the schema will be named elementary or <target_schema>_elementary.
Make sure your user has permissions to create schemas.
For elementary to work, it needs to create some of the models as incremental tables.
Make sure that there are no global materialization configurations that affect elementary, such as:
dbt_project.yml
materialized:"{{ 'table' if target.name == 'prod-cloud' else 'view' }}"
Make sure to place the 'elementary' configuration under the models key, and other configs under your project name.
If you change materialization settings, make sure to run dbt run -s elementary --full-refresh.
Starting from dbt 1.8 and above, 3rd party dbt packages cannot override dbt materializations without an explicit configuration from users.
Elementary utilizes this dbt mechanism to add reporting functionality to non-Elementary tests (such as native dbt tests and expectations):
Collection of the total number of failed rows.
Collection of failed row samples.
In order for these features to work, it is required to add the following flag to your dbt_project.yml file:
Please note that after setting this flag you may see a deprecation warning from dbt.
This is a temporary measure and we are working with the dbt team on a longer term solution.
dbt_project.yml
models:## see docs: https://docs.elementary-data.com/ elementary:## elementary models will be created in the schema '<your_schema>_elementary'+schema:"elementary"## To disable elementary for dev, uncomment this:# enabled: "{{ target.name in ['prod','analytics'] }}"# Required from dbt 1.8 and above for certain Elementary featuresflags:require_explicit_package_overrides_for_builtin_materializations:Falsesource_freshness_run_project_hooks:True
3
Import the package and build Elementary models
Terminal
dbt depsdbt run --select elementary
This will mostly create empty tables, that will be updated with artifacts, metrics and test results in your future dbt executions.
4
Run tests
Validate the installation by running some tests:
Terminal
dbt test
After you ran your tests, we recommend that you ensure that the results were loaded to elementary_test_results table.
Once the elementary dbt package has been installed and configured, your test results, run results and dbt artifacts will be loaded to elementary schema tables.
If you see data in these models you completed the package deployment (Congrats! ๐).