SelectParser: add support for grouping labels#36887
Open
radu-gheorghe wants to merge 1 commit into
Open
Conversation
Contributor
|
Looks good to me 👍🏻 , but should we run it by the architecture meeting as well? |
Contributor
Author
|
Ah, that would be a good idea 🙈 I'll do it later. |
bjorncs
approved these changes
May 18, 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.
The Select (JSON) syntax didn't support a way to change the label of grouping results. The YQL variant does with something like:
This commit fixes this gap. Something like this now works:
{ "all": { "group": "explanation_attribute", "each": { "output": "count()", "label": "explanations" } } }Note how the label is within
each. Feel free to disagree with that :) It's in the name of simplicity/reliability, because JSON grouping is translated to "normal" grouping, whereasneeds to go aftereach(IIUC). The current implementation guarantees thateachis there. If we did it one level higher (which is more natural), we'd have to do more validation to make sure we don't putasin the wrong place.Speaking of validation, we do a reasonable job (e.g., reject the request if
labelis upper in the hierarchy - see tests for more), but we don't cover everything. AFAIK, the only corner case is when someone has an array foreach(which is unlikely, IMO):In this case, we silently drop the label instead of rejecting the request as invalid. I think this is in line with the rather loose validation that we do for JSON grouping in general: we rely on the underlying grouping syntax parser to catch some of the errors. You can argue that's not nice, but refactoring for better JSON validation is a separate task, IMO.