-
Notifications
You must be signed in to change notification settings - Fork 216
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
Changes from 1 commit
42c93b6
f2d740b
9f68a6f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| {% 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 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 %} | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -150,7 +150,7 @@ models: | |
| columns: | ||
| - name: "missing_column" | ||
| tests: | ||
| - uniques: | ||
| - unique: | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You're right — |
||
| tags: ["error_test", "regular_tests"] | ||
|
|
||
| - name: backfill_days_column_anomalies | ||
|
|
||
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.