18:52:38 1 of 1 ERROR creating sql incremental mo...
# ask-elementary-ai
n
185238 1 of 1 ERROR creating sql incremental model
elementary
.
alerts_v2
........... [ERROR in 0.93s] 185238 Compilation Error in model alerts_v2 (models/alerts/alerts_v2.sql) 'elementary_test_results_id' > in macro run_hooks (macros/materializations/hooks.sql) > called by macro materialization_incremental_clickhouse (macros/materializations/incremental/incremental.sql) > called by model alerts_v2 (models/alerts/alerts_v2.sql) elementary.exceptions.exceptions.DbtCommandError: Failed to run dbt command.
k
A message from kapa.ai
The error message you are seeing:
Copy code
Compilation Error in model alerts_v2 (models/alerts/alerts_v2.sql)   'elementary_test_results_id'
indicates a compilation issue in the
alerts_v2
model, specifically related to the reference
'elementary_test_results_id'
. This typically means that the column or variable
elementary_test_results_id
is being referenced in the model or macro, but it does not exist or is not defined in your environment. Based on the knowledge sources, similar errors often occur when: - The required Elementary tables or columns are missing or not up-to-date in your data warehouse. - There is a mismatch between the versions of the Elementary dbt package and the
edr
CLI. - The dbt project or warehouse is not fully initialized with the necessary Elementary models and schema. Recommended steps: 1. Ensure All Elementary Models Are Built: Run the following command to build all Elementary models, which should create the necessary tables and columns:
Copy code
dbt run -s elementary
or, for some environments:
Copy code
dbt build -s elementary
This step is often required after upgrading the Elementary package or setting up a new environment, as missing tables or columns (like
elementary_test_results_id
) can cause compilation errors in downstream models like
alerts_v2
[see similar issues in this Slack thread](https://slack.com/archives/C02CTC89LAX/p1715774234468019). 2. Check Version Compatibility: Make sure that the versions of the
edr
CLI and the Elementary dbt package are compatible. Incompatibilities can lead to schema mismatches and missing columns [as seen here](https://slack.com/archives/C02CTC89LAX/p1680794180638689). 3. Verify Schema and Table Structure: Double-check that the
elementary_test_results
table exists in your target schema and that it contains all expected columns, including any referenced by the
alerts_v2
model. 4. Review Macros and Materializations: If you have customized macros or are using a non-standard warehouse (e.g., ClickHouse, Trino), ensure that all required macros and materializations are compatible and up-to-date. If after these steps the error persists, please provide the full error log and confirm that all Elementary models have been built successfully. This will help further diagnose if the issue is with the dbt project setup, the warehouse schema, or a version mismatch. If you need more targeted help, sharing your
edr.log
file and the output of
dbt run -s elementary
can help the community or support team pinpoint the issue more precisely. Let me know if you need more specific troubleshooting steps!