Skip to content

fix: restore missing test macros in e2e dbt project#2138

Merged
haritamar merged 3 commits intomasterfrom
devin/1772541834-fix-e2e-dbt-test-failures
Mar 3, 2026
Merged

fix: restore missing test macros in e2e dbt project#2138
haritamar merged 3 commits intomasterfrom
devin/1772541834-fix-e2e-dbt-test-failures

Conversation

@devin-ai-integration
Copy link
Contributor

@devin-ai-integration devin-ai-integration bot commented Mar 3, 2026

Summary

Fixes two dbt test compilation errors in the e2e project that were introduced when dbt-data-reliability#947 removed the deprecated integration tests directory. The e2e project's schema.yml still references macros/tests that lived there.

Changes:

  1. Restore test_config_levels generic test macro — copied verbatim from the removed integration_tests/deprecated_tests/macros/e2e_tests/test_config_levels.sql. This macro validates that elementary's anomaly detection config resolution (project/model/test level) works correctly. It's referenced by 5 tests in schema.yml.
  2. Fix uniquesunique — typo in error_model.missing_column test. uniques is not a valid dbt generic test; the built-in is unique.

Note: These compilation errors don't currently break CI on master because the dbt test step uses continue-on-error: true (many e2e tests are intentionally designed to fail). This PR cleans up the spurious compilation errors so they don't mask real issues.

Review & Testing Checklist for Human

  • Verify the test_config_levels macro is still compatible with the current elementary.get_anomalies_test_configuration() API — it was copied from code removed ~recently but the macro signature may have drifted
  • Check that mandatory_params (referenced on line 8 of the macro but not passed as an argument) resolves correctly at runtime — it appears to be an implicit dbt context variable, not a bug, but worth confirming
  • Confirm unique (not uniques) is the intended test for error_model.missing_column — this test is tagged error_test so it's expected to fail at runtime regardless

Notes

Summary by CodeRabbit

  • Tests
    • Added configuration validation test for dbt models to ensure proper parameter alignment
    • Validates timing configurations, filtering expressions, anomaly sensitivity parameters, and model training settings
    • Includes diagnostic reporting to identify configuration mismatches and help resolve discrepancies

… e2e project

- Add test_config_levels generic test macro that was removed from
  dbt-data-reliability in PR #947 but still referenced by the e2e project
- Fix 'uniques' -> 'unique' (standard dbt generic test) on error_model

Co-Authored-By: Itamar Hartstein <haritamar@gmail.com>
@devin-ai-integration
Copy link
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@github-actions
Copy link
Contributor

github-actions bot commented Mar 3, 2026

👋 @devin-ai-integration[bot]
Thank you for raising your pull request.
Please make sure to add tests and document all user-facing changes.
You can do this by editing the docs files in this pull request.

@coderabbitai
Copy link

coderabbitai bot commented Mar 3, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 42c93b6 and 9f68a6f.

📒 Files selected for processing (1)
  • tests/e2e_dbt_project/macros/generic_tests/test_config_levels.sql

📝 Walkthrough

Walkthrough

This pull request adds a new dbt test called config_levels and a supporting macro compare_configs to validate anomaly test configurations. The test loads a model relation, retrieves its test configurations, and iterates through specified configuration fields to verify they match expected values, raising compiler errors for any mismatches.

Changes

Cohort / File(s) Summary
Configuration Validation Test
tests/e2e_dbt_project/macros/generic_tests/test_config_levels.sql
Added new config_levels test that validates anomaly test configurations (timestamp_column, where_expression, time_bucket, anomaly_sensitivity, anomaly_direction, min_training_set_size, days_back, backfill_days, seasonality) against expected values. Includes supporting compare_configs macro to generate descriptive error messages for mismatches.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

A test for configs, so neat and so keen,
Comparing the values in each dbt scene,
With anomalies checked from top to the floor,
Our validation ensures all is in store! 🐰✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: restoring missing test macros (test_config_levels) in the e2e dbt project that were removed in a prior refactoring.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch devin/1772541834-fix-e2e-dbt-test-failures

Comment @coderabbitai help to get the list of available commands and usage tips.

- name: "missing_column"
tests:
- uniques:
- unique:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this typo may have been intentional originally, to have an error case for tests
Double check me though

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right — uniques is intentional. The error_model with missing_column is tagged error_test, and the non-existent uniques test creates a compilation error case that gets validated by the edr monitoring steps. Reverted in f2d740b.

The 'uniques' test (non-existent) on error_model.missing_column was
intentionally creating a compilation error case, tagged as error_test.

Co-Authored-By: Itamar Hartstein <haritamar@gmail.com>
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@tests/e2e_dbt_project/macros/generic_tests/test_config_levels.sql`:
- Around line 6-17: The code calls
elementary.get_anomalies_test_configuration(...) with mandatory_params which is
undefined; fix by adding mandatory_params as a parameter to the surrounding
macro's signature (or define it locally before the call) and provide a sensible
default (e.g., empty dict) so the call uses a defined value; update the macro
signature where it is declared and ensure the variable name mandatory_params is
passed through to the elementary.get_anomalies_test_configuration(...) call so
that the function receives a defined argument.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 96a4170 and 42c93b6.

📒 Files selected for processing (2)
  • tests/e2e_dbt_project/macros/generic_tests/test_config_levels.sql
  • tests/e2e_dbt_project/models/schema.yml

Comment on lines +6 to +17
{% set configuration_dict, metric_properties_dict =
elementary.get_anomalies_test_configuration(model_relation,
mandatory_params,
timestamp_column,
where_expression,
anomaly_sensitivity,
anomaly_direction,
min_training_set_size,
time_bucket,
days_back,
backfill_days,
seasonality) %}
Copy link

@coderabbitai coderabbitai bot Mar 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== Find current get_anomalies_test_configuration definitions/call sites =="
rg -n -C3 'get_anomalies_test_configuration\s*\(' -g '*.sql' | head -60

echo
echo "== Find where mandatory_params is defined or set =="
rg -n -C3 '\bmandatory_params\b' -g '*.sql' | head -80

echo
echo "== Inspect the full test_config_levels.sql file =="
cat -n tests/e2e_dbt_project/macros/generic_tests/test_config_levels.sql

Repository: elementary-data/elementary

Length of output: 6115


mandatory_params is undefined and will cause a runtime error.

The macro parameter list does not include mandatory_params (line 1), yet it is passed to elementary.get_anomalies_test_configuration() at line 8. This variable is not defined locally or available in the macro scope, which will cause a compilation/runtime failure when the test executes. Either add mandatory_params to the macro parameters, define it locally before use, or remove it from the function call if it's no longer needed.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/e2e_dbt_project/macros/generic_tests/test_config_levels.sql` around
lines 6 - 17, The code calls elementary.get_anomalies_test_configuration(...)
with mandatory_params which is undefined; fix by adding mandatory_params as a
parameter to the surrounding macro's signature (or define it locally before the
call) and provide a sensible default (e.g., empty dict) so the call uses a
defined value; update the macro signature where it is declared and ensure the
variable name mandatory_params is passed through to the
elementary.get_anomalies_test_configuration(...) call so that the function
receives a defined argument.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch — mandatory_params was available in the original calling context (e.g., test_table_anomalies has mandatory_params=none as a parameter). Since test_config_levels doesn't need mandatory param validation, I've defined it locally as none before the call. Fixed in 9f68a6f.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Skipped: comment is from another GitHub bot.

The macro calls elementary.get_anomalies_test_configuration() with
mandatory_params but it was never defined in scope. In the original
dbt-data-reliability code, this was a parameter on the calling test
macros. Since test_config_levels doesn't need mandatory param validation,
define it locally as none.

Co-Authored-By: Itamar Hartstein <haritamar@gmail.com>
@haritamar haritamar merged commit 58a1d3a into master Mar 3, 2026
11 of 16 checks passed
@haritamar haritamar deleted the devin/1772541834-fix-e2e-dbt-test-failures branch March 3, 2026 17:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant