fix: remove USING joins from health score copy tree (CM-XXXX) - #4429
fix: remove USING joins from health score copy tree (CM-XXXX)#4429epipav wants to merge 1 commit into
Conversation
Signed-off-by: anilb <epipav@gmail.com>
PR SummaryLow Risk Overview
Join types, keys, column names/order, and downstream Reviewed by Cursor Bugbot for commit 349d233. Bugbot is set up for automated code reviews on this repo. Configure here. |
|
Your PR title doesn't contain a Jira issue key. Consider adding it for better traceability. Example:
Projects:
Please add a Jira issue key to your PR title. |
There was a problem hiding this comment.
Pull request overview
Replaces incompatible Tinybird USING joins with explicit ON conditions in the health-score COPY dependency tree.
Changes:
- Rewrites 13 health-score aggregation joins.
- Updates retention and security joins while preserving output columns.
- Required: Replace
CM-XXXXin the PR title with a numeric JIRA key.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
health_score_copy.pipe |
Rewrites metric joins. |
health_score_retention.pipe |
Rewrites the quarter join. |
health_score_security.pipe |
Rewrites and qualifies the repository join. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Problem
The nightly
health_score_copyCOPY pipe (00:50 UTC) fails with:ClickHouse 25.3+ is stricter about
JOIN ... USINGwhen the joined sides are subqueries with aliased columns — which everyhealth_score_*metric pipe is (aggregatedGROUP BYsubqueries). Since Tinybird inlines all referenced pipes into one query at copy time, the whole query tree is affected, not just the top-level pipe.Change
Convert every
USING (key)join in thehealth_score_copyquery tree to an explicitON left.key = right.key, preserving join type and keys:health_score_copy.pipe— 13 joins inhealth_score_copy_data(11×segmentId, 2×id)health_score_retention.pipe— 1 join (ON cur.segmentId = prev.segmentId)health_score_security.pipe— 1 inner join onrepo; the select-listrepois qualified assecurity_deduplicated_merged_ds.repo AS reposince both sides keep the column after anONjoinOutput columns (names, order), join semantics, and the
health_score_copy_dstarget schema are unchanged.Validation
insightsProjectsfixtures: the rewritten 13-join node returns byte-identical results to the original (38 rows, matching hash), and the fixed retention/security pipes push and execute cleanly.BAD_ARGUMENTSoriginates in Tinybird cloud's copy-job execution path and does not reproduce through the local classic image; the rewrite follows Tinybird's recommended remediation.tb fmt --diffclean on all three files (tinybird-cli 5.x, matching CI).Deferred (follow-ups)
9 other pipes still contain the same
USINGconstruct and will likely need the same conversion as they hit the stricter path:repo_health_score_copy,repo_health_score_retention,project_insights_copy,insights_projects_populated_copy,org_dash_metric_copy_pipe,collections_oss_index,categories_oss_index,category_groups_oss_index,activity_heatmap_by_weekday_and_2hours_blocks. Deliberately excluded here to keep this fix minimal.