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

SQL: ordering doesn't work properly for multiple groupings #39956

Closed
astefan opened this issue Mar 12, 2019 · 0 comments · Fixed by #40087
Closed

SQL: ordering doesn't work properly for multiple groupings #39956

astefan opened this issue Mar 12, 2019 · 0 comments · Fixed by #40087
Assignees
Labels

Comments

@astefan
Copy link
Contributor

astefan commented Mar 12, 2019

For a multi GROUP BY statement, the order in which the sources are used in the composite aggregation is incorrect.

For example, for the query SELECT first_name AS n, gender AS g FROM test GROUP BY n, g ORDER BY g, n the generated composite aggregation has the order of its sources like the one from the GROUP BY definition, where in fact it should be the one from the ORDER BY statement:

                "sources": [
                    {
                        "1331": {
                            "terms": {
                                "field": "first_name.keyword",
                                "missing_bucket": true,
                                "order": "asc"
                            }
                        }
                    },
                    {
                        "1335": {
                            "terms": {
                                "field": "gender",
                                "missing_bucket": true,
                                "order": "asc"
                            }
                        }
                    }
                ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
1 participant