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: Fix ORDER BY on aggregates and GROUPed BY fields #51894

Merged
merged 10 commits into from Feb 12, 2020

Commits on Feb 4, 2020

  1. SQL: Fix ORDER BY on aggregates and GROUPed BY fields

    Previously, in the in-memory sorting module
    `LocalAggregationSorterListener` only the aggregate functions where used
    (grabbed by the `sortingColumns`). As a consequence, if the ORDER BY
    was also using columns of the GROUP BY clause, (especially in the case
    of higher priority - before the aggregate functions) wrong results were
    produced. E.g.:
    ```
    SELECT gender, MAX(salary) AS max FROM test_emp
    GROUP BY gender
    ORDER BY gender, max
    ```
    
    Add all columns of the ORDER BY to the `sortingColumns` so that the
    `LocalAggregationSorterListener` can use the correct comparators in
    the underlying PriorityQueue used to implement the in-memory sorting.
    
    Fixes: elastic#50355
    matriv committed Feb 4, 2020
    Copy the full SHA
    b49a23c View commit details
    Browse the repository at this point in the history

Commits on Feb 5, 2020

  1. Copy the full SHA
    a68c6de View commit details
    Browse the repository at this point in the history
  2. make field private

    matriv committed Feb 5, 2020
    Copy the full SHA
    90cb862 View commit details
    Browse the repository at this point in the history
  3. Copy the full SHA
    ab0c627 View commit details
    Browse the repository at this point in the history
  4. fix formatting

    matriv committed Feb 5, 2020
    Copy the full SHA
    9d25c93 View commit details
    Browse the repository at this point in the history
  5. Copy the full SHA
    aaf2bd3 View commit details
    Browse the repository at this point in the history

Commits on Feb 11, 2020

  1. Copy the full SHA
    a1ec293 View commit details
    Browse the repository at this point in the history
  2. Copy the full SHA
    65a1ca3 View commit details
    Browse the repository at this point in the history
  3. Copy the full SHA
    46b9700 View commit details
    Browse the repository at this point in the history
  4. Address comment

    matriv committed Feb 11, 2020
    Copy the full SHA
    637a9f9 View commit details
    Browse the repository at this point in the history