Fixes a bug when running queries with a limit clause
There is a presently an issue where a final limit stage in MSQ is hardcoded to output all results into a single partition. This is fine for when writing to a query report. However, when using async queries or exports, the query might specify rowsPerPage parameter, which determines how many pages the final result should be split into.
Currently, if the query contains a LIMIT clause, this causes the above parameter to not be respected.
This PR aims to correct this by adding a shuffling after a limit processor depending on the query destination.
This PR has:
- [ ] been self-reviewed.
- [ ] using the concurrency checklist (Remove this item if the PR doesn't have any relation to concurrency.)
- [ ] added documentation for new or modified features or behaviors.
- [ ] a release note entry in the PR description.
- [ ] added Javadocs for most classes and all non-trivial methods. Linked related entities via Javadoc links.
- [ ] added or updated version, license, or notice information in licenses.yaml
- [ ] added comments explaining the "why" and the intent of the code wherever would not be obvious for an unfamiliar reader.
- [ ] added unit tests or modified existing tests to cover new code paths, ensuring the threshold for code coverage is met.
- [ ] added integration tests.
- [ ] been tested in a test Druid cluster.
The finalShuffleSpec must also be set in the case of ingest queries.
~Ingest queries do not allow limit, unless the partitioning is ALL, so this case shouldn't happen.~
I see, the case you mean is with ALL partitioning and LIMIT, should create more than 1 partitions. I think this is an existing bug. I have included this case as well. Thanks for the catch!
I have refactored the code in the QueryKits and added additional tests to address the comments.