fix: aggregate enrollment stage CTE projection#23868
Merged
luciano-fiandesio merged 3 commits intoMay 12, 2026
Merged
Conversation
|
Surefire reports for analytics API tests against Doris have been pushed to the repository. View reports |
2 similar comments
|
Surefire reports for analytics API tests against Doris have been pushed to the repository. View reports |
|
Surefire reports for analytics API tests against Doris have been pushed to the repository. View reports |
|
|
Surefire reports for analytics API tests against Doris have been pushed to the repository. View reports |
maikelarabori
approved these changes
May 12, 2026
luciano-fiandesio
enabled auto-merge (squash)
May 12, 2026 15:33
vietnguyen
approved these changes
May 12, 2026
luciano-fiandesio
added a commit
that referenced
this pull request
May 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Summary
When requesting an aggregated enrollment analytics query that combines a stage-specific dimension without a filter with other stage-specific dimensions that do have filters, the generated SQL was invalid.
Example:
API request (against
/api/analytics/enrollments/aggregate/<programUid>):Postgres response:
The outer SELECT referenced
uiogg.ev_eventstatus(whereuioggaliased thelatest_events_A03MvHHogjRCTE), but that CTE did not projectev_eventstatus.Fix
Make the per-stage filter CTE the "single source of truth" for every stage dimension requested in that stage's scope.
The aggregate branch no longer pre-filters items by
hasFilter(). Instead it groups every stage item from bothparams.getItems()andparams.getItemFilters()by program stageUID, then emits alatest_events_<stage>CTE only when at leastone item for that stage carries a filter.
Unfiltered stage items belonging to a stage that does have a filter get projected into the same CTE, sharing the "latest event matching the filter" row.