-
Notifications
You must be signed in to change notification settings - Fork 214
fix: restore missing test macros in e2e dbt project #2138
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
42c93b6
fix: restore missing test_config_levels macro and fix uniques typo in…
devin-ai-integration[bot] f2d740b
fix: revert uniques change - intentional error case for error_model
devin-ai-integration[bot] 9f68a6f
fix: define mandatory_params as none in test_config_levels macro
devin-ai-integration[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
54 changes: 54 additions & 0 deletions
54
tests/e2e_dbt_project/macros/generic_tests/test_config_levels.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| {% test config_levels(model, expected_config, timestamp_column, time_bucket, where_expression, anomaly_sensitivity, anomaly_direction, days_back, backfill_days, seasonality, min_training_set_size) %} | ||
| {%- if execute and elementary.is_test_command() %} | ||
| {%- set unexpected_config = [] %} | ||
| {%- set model_relation = dbt.load_relation(model) %} | ||
| {%- set mandatory_params = none %} | ||
|
|
||
| {% 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) %} | ||
|
|
||
| {%- set configs_to_test = [('timestamp_column', metric_properties_dict.timestamp_column), | ||
| ('where_expression', metric_properties_dict.where_expression), | ||
| ('time_bucket', configuration_dict.time_bucket), | ||
| ('anomaly_sensitivity', configuration_dict.anomaly_sensitivity), | ||
| ('anomaly_direction', configuration_dict.anomaly_direction), | ||
| ('min_training_set_size', configuration_dict.min_training_set_size), | ||
| ('days_back', configuration_dict.days_back), | ||
| ('backfill_days', configuration_dict.backfill_days), | ||
| ('seasonality', configuration_dict.seasonality) | ||
| ] %} | ||
|
|
||
| {%- for config in configs_to_test %} | ||
| {%- set config_name, config_value = config %} | ||
| {%- set config_check = compare_configs(config_name, config_value, expected_config) %} | ||
| {%- if config_check %} | ||
| {%- do unexpected_config.append(config_check) -%} | ||
| {%- endif %} | ||
| {%- endfor %} | ||
|
|
||
| {%- if unexpected_config | length > 0 %} | ||
| {%- do exceptions.raise_compiler_error('Failure config_levels: ' ~ unexpected_config) -%} | ||
| {%- else %} | ||
| {#- test must run an sql query -#} | ||
| {{ elementary.no_results_query() }} | ||
| {%- endif %} | ||
| {%- endif %} | ||
| {%- endtest %} | ||
|
|
||
| {% macro compare_configs(config_name, config, expected_config) %} | ||
| {%- if config != expected_config.get(config_name) %} | ||
| {%- set unexpected_message = ('For {0} - got config: {1}, expected config: {2}').format(config_name, config, expected_config.get(config_name) ) %} | ||
| {{ return(unexpected_message) }} | ||
| {%- endif %} | ||
| {{ return(none) }} | ||
| {% endmacro %} | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: elementary-data/elementary
Length of output: 6115
mandatory_paramsis undefined and will cause a runtime error.The macro parameter list does not include
mandatory_params(line 1), yet it is passed toelementary.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 addmandatory_paramsto 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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch —
mandatory_paramswas available in the original calling context (e.g.,test_table_anomalieshasmandatory_params=noneas a parameter). Sincetest_config_levelsdoesn't need mandatory param validation, I've defined it locally asnonebefore the call. Fixed in 9f68a6f.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.