fix: allow sorting a report by a column not in the output - #1469
Draft
romandubovyi wants to merge 1 commit into
Draft
fix: allow sorting a report by a column not in the output#1469romandubovyi wants to merge 1 commit into
romandubovyi wants to merge 1 commit into
Conversation
Report sorting no longer requires the sorted column to be among the selected output columns. A non-aggregated report can now sort by any known column of its data mart (including joined/blended columns when the report has an explicit column selection), the same way filters already work — so the "Output controls validation failed" error no longer fires for a valid sort on a hidden column. Aggregated (GROUP BY) reports are unchanged: they can still sort only by a projected dimension or an aggregated metric. The frontend sort picker now offers all columns for non-aggregated reports with an explicit selection, and stays limited to the selected columns otherwise.
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.
Problem
Configuring a report sort on a column that was not among the selected output columns failed with
Output controls validation failed(SORT_COLUMN_NOT_SELECTED). Filtering already allowed hidden columns, so the two controls behaved inconsistently — you could filter by a column you didn't output, but not sort by it.Root cause
OutputControlsValidatorService.validateSortrequired every sort column to be in the selected set, while filters validate against all known fields. The SQL builders (plain and blended/multi-storage) already supportORDER BYon a non-selected column for non-aggregated reports:src.<col>, and the full source table is available.referencedColumnsand qualifies them tomain.<col>or the joined CTE.The only place the restriction is genuinely required is aggregated (
GROUP BY) reports, whereORDER BYresolves through the aggregated-alias resolver and can reference only a projected dimension or an aggregated metric.Changes
Backend (
output-controls-validator.service.ts)GROUP BY) → unchanged: sort must reference a projected dimension or aggregated metric.SELECT *over native fields) → sort still limited to native columns (blended aliases aren't projected on that path).Frontend (
OutputSettingsDropdown/SortSection, newhasExplicitColumnsprop)SELECT *case) keep offering only the selected output columns, so an invalid sort target is never presented.Multi-storage
Verified against the blended query builder: sort columns are materialized into the relevant CTE and qualified correctly, so sorting by a non-selected joined column works end to end; the
SELECT *+ blended combination is still rejected as before.Tests
output-controls): updated to accept the previously-rejected sort and added an aggregated-report rejection case.OutputSettingsDropdownandReportColumnPickersuites passing;tsc --noEmitclean.