Fix aggregate queries without explicit grouping#3980
Fix aggregate queries without explicit grouping#3980caglareker wants to merge 2 commits intoFoundationDB:mainfrom
Conversation
When continuing an aggregate query without an explicit GROUP BY clause, the code attempted to deserialize a group key even when groupingKeyValue was null, causing incorrect results. Add null checks to skip group key handling when there is no explicit grouping, ensuring continued queries work correctly.
alecgrieser
left a comment
There was a problem hiding this comment.
Thanks for the contribution! It seems like this could use a regression test covering the error case and then showing that it has been fixed by this change. I believe @hazefully had created a test case that showed this that used the yaml-tests framework.
The yaml-tests directory contains a bunch of queries, and it enables the queries to be executed both against the most recent server version but also against older versions in order to prevent against unexpected cross-version incompatibility problems.
The general process for creating a new file is to make a new file in yaml-tests/src/test/resources with your test case, and then to add a new method to YamlIntegrationTests that runs the tests for that file. You can look at some of the others (like, say, aggregate-index-tests.yamsql) to see how the file is formatted, but it allows the user to define a test schema and then queries that execute against it. I believe this bug only gets hit if an internal limit is hit, so IIRC, @hazefully had set the EXECUTION_SCANNED_ROWS_LIMIT option in the file in order to create a showcasing test case. (For an example of how we set connection options, you can look at, say, case-sensitivity.yamsql.)
There may be other ways to write a test for this. For example, FDBStreamAggregationTest has a bunch of other tests for the streaming aggregate code. It may be that we can add a test there and get more-or-less the same coverage
|
added a yaml-tests case for ungrouped aggregate queries with continuations. uses maxRows=1 to force the continuation path that was hitting the NPE. |
Fixes #3979
When continuing an aggregate query without an explicit GROUP BY clause, the code attempted to deserialize a group key even when no grouping key value existed, causing incorrect results.
Add null checks to handle the case where
groupingKeyValueis null:This ensures continued aggregate queries without grouping work correctly when resuming from a cursor.