microsoft / durabletask-java

Java SDK for Durable Functions and the Durable Task Framework
MIT License
13 stars 7 forks source link

Add option to sort orchestration query results in descending order #73

Closed cgillum closed 2 years ago

cgillum commented 2 years ago

There has been an ask to support querying for orchestration instances and sorting by descending order. We should investigate if this is practical at the storage provider level and, if it is, expose it all the way up to the Java client SDK.

Suggested implementation

kaibocai commented 2 years ago

I wonder what the cx want to sort the query results by, do they want to sort by orchestration completed time?

ChrisRomp commented 2 years ago

@kaibocai In this instance they are happy with the previous change to get instances by ID using the prefix query (https://github.com/Azure/azure-functions-durable-extension/pull/2194) and they are using a Unix timestamp for the ID, but they'd prefer to get them in reverse order, e.g., using a descending Boolean operator or similar. As a workaround they are considering using something like (Int.Max - $timestamp) as the value so they're reverse timestamp even in ascending order. If they can ask for the results in descending order, this wouldn't be necessary.

kaibocai commented 2 years ago

Hi @ChrisRomp, thanks for the info. So basically we just need to provide an option to reverse the query results right, not fancy multiple sort options. Thanks.

ChrisRomp commented 2 years ago

@kaibocai That's all anyone is asking for - for now. đŸ˜‰ Thank you!!

cgillum commented 2 years ago

After some discussion, we decided to abandon this work item. The primary issue is that Azure Storage (the most common storage backend) doesn't support ordering the results of a query, making it impossible to implement this feature efficiently.