Add job_run_id and job_run_url fields into DbtInvocationSchema#2195
Add job_run_id and job_run_url fields into DbtInvocationSchema#2195vyagubov wants to merge 2 commits intoelementary-data:masterfrom
Conversation
|
👋 @vyagubov |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughReplaced a single Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
elementary/monitor/dbt_project/macros/get_models_latest_invocations_data.sql (1)
2-28:⚠️ Potential issue | 🟠 MajorUse column-existence guards for optional invocation fields.
This newly created macro selects
job_url(line 24),job_run_id, andjob_run_url(lines 27-28) unconditionally. The Python schema defines these as optional fields; existingdbt_invocationsrelations without these newer columns will cause the macro to fail. Add guards usingelementary.column_exists_in_relation()to ensure backward compatibility, following the pattern used inget_models.sql,get_exposures.sql, and other macros.Suggested compatibility guard
{% macro get_models_latest_invocations_data() %} {% set invocations_relation = ref("dbt_invocations", package="elementary") %} + {% set has_job_url = elementary.column_exists_in_relation(invocations_relation, 'job_url') %} + {% set has_job_run_id = elementary.column_exists_in_relation(invocations_relation, 'job_run_id') %} + {% set has_job_run_url = elementary.column_exists_in_relation(invocations_relation, 'job_run_url') %} {% set query %} @@ invocations.command, invocations.selected, invocations.full_refresh, - invocations.job_url, + {% if has_job_url %}invocations.job_url{% else %}NULL as job_url{% endif %}, invocations.job_name, invocations.job_id, - invocations.job_run_id, - invocations.job_run_url, + {% if has_job_run_id %}invocations.job_run_id{% else %}NULL as job_run_id{% endif %}, + {% if has_job_run_url %}invocations.job_run_url{% else %}NULL as job_run_url{% endif %}, invocations.orchestrator🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@elementary/monitor/dbt_project/macros/get_models_latest_invocations_data.sql` around lines 2 - 28, The macro currently selects optional invocation columns unconditionally (invocations.job_url, invocations.job_run_id, invocations.job_run_url) which breaks on older relations; update the select list to include each optional column only when elementary.column_exists_in_relation(invocations_relation, '<column_name>') is true (for invocations_relation variable used at top), mirroring the guards used in get_models.sql/get_exposures.sql: build conditional snippets for 'job_url', 'job_run_id', and 'job_run_url' and include them in the final SELECT only when the corresponding column_exists_in_relation check passes.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@elementary/monitor/dbt_project/macros/get_test_last_invocation.sql`:
- Around line 22-41: The join selects invocations.job_run_id and
invocations.job_run_url unguarded, which breaks when the dbt_invocations
relation exists but lacks those columns; update the select in the invocations
branch of get_test_last_invocation.sql to use column_exists_in_relation() guards
for 'job_run_id' and 'job_run_url' (e.g., return invocations.job_run_id when
column_exists_in_relation(...) is true else NULL, and likewise for job_run_url)
so missing columns fall back to NULL, and apply the same guarded pattern to
get_models_latest_invocations_data.sql.
---
Outside diff comments:
In
`@elementary/monitor/dbt_project/macros/get_models_latest_invocations_data.sql`:
- Around line 2-28: The macro currently selects optional invocation columns
unconditionally (invocations.job_url, invocations.job_run_id,
invocations.job_run_url) which breaks on older relations; update the select list
to include each optional column only when
elementary.column_exists_in_relation(invocations_relation, '<column_name>') is
true (for invocations_relation variable used at top), mirroring the guards used
in get_models.sql/get_exposures.sql: build conditional snippets for 'job_url',
'job_run_id', and 'job_run_url' and include them in the final SELECT only when
the corresponding column_exists_in_relation check passes.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 397d95c0-f3d0-4ae3-a485-d70883e20645
📒 Files selected for processing (3)
elementary/monitor/dbt_project/macros/get_models_latest_invocations_data.sqlelementary/monitor/dbt_project/macros/get_test_last_invocation.sqlelementary/monitor/fetchers/invocations/schema.py
I needed those values in
NODE INFOtab. We have them in UI and in Database, but don't have in the schema.I have tested the solution locally.
Summary by CodeRabbit