GoogleCloudPlatform / GoogleCloudPlatform/cloud-spanner-emulator

Results returned by SELECT statement with ORDER BY clause and LIMIT clause are out of order

Open
#143 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
334
Forks
77
Avg merge
8m
Merged PRs (30d)
2

Description

Hello, I am getting results that are out of order when I am making a query with an ORDER BY clause _and_ a LIMIT clause that is greater than `1` via the emulator. For example, when I try making a query like this:
```sql
SELECT * FROM Items
WHERE itemId = "42477351-72fa-4412-adbd-c5f3619c2bac"
ORDER BY itemVersionId DESC
LIMIT 3
```
I get results that are out of order:
```json
[{
"itemId": "42477351-72fa-4412-adbd-c5f3619c2bac",
"itemVersionId": "2",
"createdTimestamp": "2023-10-31T20:30:12.703502Z",
"updatedTimestamp": "2023-10-31T20:30:12.703502Z"
},
{
"itemId": "42477351-72fa-4412-adbd-c5f3619c2bac",
"itemVersionId": "3",
"createdTimestamp": "2023-10-31T20:30:13.305168Z",
"updatedTimestamp": "2023-10-31T20:30:13.305168Z"
},
{
"itemId": "42477351-72fa-4412-adbd-c5f3619c2bac",
"itemVersionId": "1",
"createdTimestamp": "2023-10-31T20:30:04.056360Z",
"updatedTimestamp": "2023-10-31T20:30:04.056360Z"
}]
```
The first item and the second item should be swapped.
When I make the same query via actual Spanner, I get the correct results.

We are using emulator version 1.5.11.

Thanks!

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.