spanner/spannertest: GROUP BY without an aggregation function returns all rows #5676
Labels
api: spanner
Issues related to the Spanner API.
🚨
This issue needs some love.
triage me
I really want to be triaged.
In Spanner, a GROUP BY clause with no aggregation functions in the selected columns yields the same behavior as a DISTINCT clause. The spannertest package doesn't handle this properly.
Environment
macOS 12.2.1
Go Environment
Code
If I add this test case where a GROUP BY is used to give the same behaviour as a DISTINCT:
Expected behavior
I expect the test to pass.
Actual behavior
The test fails:
Additional context
The code expects that any query with a GROUP BY clause will include an aggregation function (e.g. SUM, MAX), but you don't need to include an aggregation function if the GROUP BY covers all of the selected columns.
See the Spanner docs:
I have confirmed this behavior running against Google Cloud Spanner.
This fixes it but I'm not sure that it's the right approach:
The text was updated successfully, but these errors were encountered: