Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Order by field appears to be broken. #949

Open
lloydtabb opened this issue Dec 2, 2022 · 1 comment · May be fixed by #1080
Open

Order by field appears to be broken. #949

lloydtabb opened this issue Dec 2, 2022 · 1 comment · May be fixed by #1080
Assignees
Labels
bug Something isn't working language An issue in the Malloy language

Comments

@lloydtabb
Copy link
Collaborator

lloydtabb commented Dec 2, 2022

This query should work.

query: airports -> {
  group_by: state
  // aggregate: airport_count
  order_by: airport_count desc
}
@lloydtabb lloydtabb self-assigned this Dec 2, 2022
@bporterfield bporterfield added bug Something isn't working language An issue in the Malloy language labels Feb 7, 2023
@shivanesabharwal
Copy link

Hey @lloydtabb I'd like to work on this issue

I did some initial investigation:

  1. the core issue seems to be that for the order_by field to be processed correctly by a call to getField it must be in the resultStruct. field list. That's why uncommenting aggregate will make the query succeed, as airport_count is in the field list for the resultStruct by the time it is asked for by the order by code.

  2. A good place to make the fix seems to be in

    expandFields(resultStruct: FieldInstanceResult) {

    namely, change the loop on 1932, to also process the order by field for a segment.

  3. Unfortunately, orderBy is not of type QueryField which is the required type for a call to addField

    addField(as: string, field: QueryField, usage: FieldUsage) {

So the proposed solution is to turn QuerySegment#orderBy into a QueryField type so it can be used as an argument to addField

Does that approach sound sensible? Are there pitfalls you can think of?

@shivanesabharwal shivanesabharwal linked a pull request Apr 10, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working language An issue in the Malloy language
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants