-
Notifications
You must be signed in to change notification settings - Fork 121
Ele 5191 fix for the logic updating test result rows #908
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
base: master
Are you sure you want to change the base?
Ele 5191 fix for the logic updating test result rows #908
Conversation
|
👋 @haritamar |
📝 WalkthroughWalkthroughThe changes introduce Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
Pre-merge checks✅ Passed checks (3 passed)
Comment |
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.
Actionable comments posted: 1
🧹 Nitpick comments (1)
models/edr/run_results/test_result_rows.sql (1)
23-24: Address NULL values for new columns in incremental table.The
row_indexandtest_typecolumns are being added to an incremental model withon_schema_change = 'append_new_columns', causing existing rows to have NULL values for these fields.Verification confirms:
- The insert logic in
pop_test_result_rows(handle_tests_results.sql) always populates both columns for new rows- However, historical records will retain NULL values
Ensure existing data handling is appropriate:
- Determine if backfill is needed for existing records
- Verify any internal queries or tools consuming this table handle NULL values correctly
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (3)
dbt-data-reliabilitymacros/edr/tests/on_run_end/handle_tests_results.sqlmodels/edr/run_results/test_result_rows.sql
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-09-15T06:06:05.601Z
Learnt from: arbiv
Repo: elementary-data/dbt-data-reliability PR: 861
File: macros/edr/tests/test_utils/clean_elementary_test_tables.sql:45-50
Timestamp: 2025-09-15T06:06:05.601Z
Learning: In the Elementary dbt-data-reliability codebase, the team prefers simpler, direct approaches over creating helper macros for centralized quoting logic, even when it might provide better maintainability across multiple use cases. They value code simplicity and readability over abstraction.
Applied to files:
dbt-data-reliability
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (14)
- GitHub Check: test (latest_official, bigquery) / test
- GitHub Check: test (latest_official, databricks_catalog) / test
- GitHub Check: test (latest_official, athena) / test
- GitHub Check: test (latest_official, clickhouse) / test
- GitHub Check: test (fusion, bigquery) / test
- GitHub Check: test (latest_official, trino) / test
- GitHub Check: test (fusion, databricks_catalog) / test
- GitHub Check: test (fusion, snowflake) / test
- GitHub Check: test (latest_official, redshift) / test
- GitHub Check: test (fusion, redshift) / test
- GitHub Check: test (latest_pre, postgres) / test
- GitHub Check: test (latest_official, postgres) / test
- GitHub Check: test (latest_official, snowflake) / test
- GitHub Check: test (latest_official, dremio) / test
🔇 Additional comments (3)
macros/edr/tests/on_run_end/handle_tests_results.sql (2)
205-207: Schema alignment looks good.The new fields
row_indexandtest_typeadded to the result rows dictionary correctly match the schema defined intest_result_rows.sql(int and string types respectively). The use ofloop.indexprovides a 1-based sequential index for each result row, which is appropriate for tracking row order.
197-213: No action required. Verification confirms thattest_typeis always present intest_resultdictionaries. Theget_dbt_test_result_rowmacro, which is the sole source of test result creation, explicitly includes'test_type': elementary.get_test_type(flattened_test). Theget_test_typemacro always returns a value—either an elementary test type or the fallback value"dbt_test"—ensuring the field is never missing or NULL.models/edr/run_results/test_result_rows.sql (1)
3-14: The removal ofunique_keyconstraint requires proper deduplication logic in the insert strategy.The
unique_key = 'elementary_test_results_id'has been removed, but theinsert_rows()macro performs direct SQL INSERTs without deduplication. On subsequent dbt runs, the same(elementary_test_results_id, row_index)pairs will be re-inserted, creating duplicates.The
incremental_strategyconfiguration (merge for some adapters) cannot prevent this since rows are inserted directly viainsert_rows()rather than through dbt's incremental merge logic. Without either:
- Restoring
unique_key+merge_update_columns, or- Adding deduplication logic in
insert_rows()to skip existing rowsIncremental runs risk accumulating duplicate rows. Verify that this multi-row-per-test pattern is intentional and that duplicate prevention is handled elsewhere (e.g., in the test execution layer or row generation logic).
| "result_row": result_row | ||
| "result_row": result_row, | ||
| "row_index": loop.index, | ||
| "test_type": test_result.test_type |
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.
this is not for the unique key, just it's really annoying to understand if a certain row is a sample or not as it needs a join, so wanted to have it at least going forward
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.