Azure Data Explorer Kusto Sort Order make_set guaranteed order of input

databricksuser-5173 20 Reputation points
2025-07-31T21:06:01.9133333+00:00

Hi,

https://learn.microsoft.com/en-us/kusto/query/make-set-aggregation-function?view=microsoft-fabric

Above link says "The array's sort order is undefined". Is there a way to construct the array guaranteeing preserving the order of input elements received in the input object on which make_set is applied?

Azure Data Explorer
Azure Data Explorer
An Azure data analytics service for real-time analysis on large volumes of data streaming from sources including applications, websites, and internet of things devices.
{count} votes

1 answer

Sort by: Most helpful
  1. Venkat Reddy Navari 5,255 Reputation points Microsoft External Staff Moderator
    2025-07-31T23:42:39.2633333+00:00

    Hi databricksuser-5173 You're right, make_set() does not guarantee any specific order of elements, as stated in the documentation. If preserving the input order is important, you can use make_list() instead, which does retain input order:

    
    | summarize ordered_vals = make_list(columnName) by groupColumn
    

    To ensure correct ordering in distributed contexts, you can add serialize before the aggregation:

    
    
    | serialize
    | summarize ordered_vals = make_list(columnName) by groupColumn
    

    Note: make_list() does not remove duplicates.


    I hope this information helps. Please do let us know if you have any further queries.

    Kindly consider upvoting the comment if the information provided is helpful. This can assist other community members in resolving similar issues.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.