fix: add explicit AS aliases to all columns in get_tests & populate_test_alerts_query to support ClickHouse < 24.3#2231
Conversation
…est_alerts_query to support ClickHouse < 24.3
|
👋 @maanh96 |
|
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)
📝 WalkthroughWalkthroughThis PR adds explicit column aliases to SQL macros in Elementary's dbt project to resolve a ClickHouse 23.4 compatibility issue. Two macros ( ChangesSQL Column Aliasing for ClickHouse Compatibility
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 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)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. 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 |
Fixes #2228
Description
On ClickHouse versions < 24.3, the old query analyzer prefixes all joined/CTE columns with their source table name (e.g.,
failed_tests.alert_id,invocations.job_id) instead of plain column names. This causes two separate failures:edr monitorcrashes withObject of type Undefined is not JSON serializableinpopulate_test_alertsmacroedr reportcrashes withValidationError: field required schema_name / test_paramsfromget_testsmacroBoth have the same root cause — ClickHouse < 24.3 prefixing all joined/CTE column names with their source table name.
Changes
elementary/monitor/dbt_project/macros/alerts/population/test_alerts.sql— added explicitASaliases to alltable.columnreferences in the finalSELECTofpopulate_test_alerts_queryelementary/monitor/dbt_project/macros/get_tests.sql— added explicitASaliases to alltable.columnreferences for the same reasonRoot Cause
ClickHouse's old analyzer (default in versions < 24.3) prefixes all joined/CTE columns with their source table name. The new analyzer (default from 24.3+) handles this correctly. This change is fully backwards compatible — redundant
ASaliases are valid SQL on all warehouses and all ClickHouse versions.Testing
Verified on ClickHouse 23.4:
edr monitornow runs successfully and sends alerts without erroredr reportnow generates the report without validation errorsSummary by CodeRabbit