New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to order items in makeset? #24135
Comments
Hi @imeya ,
|
thank you. But what I want is that the result is a set(in 1 row like ["a","b","c"]), not in many rows like in row1: a, in row 2, b. |
Proposing changes for makeset functionality as it return array and sort is undefined in the array item
Hi @imeya , I tried to reproduce the issue with the steps you mentioned. here are my findings; Though for a workaround for this , you can use blow query -
which will give you result in rows and later you can concat the result in one row(comma seperated). |
thanks again. then how to concat the result in one row, with comma seperated? |
Hi @imeya , Try this code , it should give you what you are looking for.
Hope it helps. |
@MohitVerma-MSFT, thank you very much. Please correct the document. And actually, we can directly use makelist() which supports ordering. |
Yes, Makelist preserve the ordering of the input items. I have corrected the document and it will be published soon. |
Is there a way to order items in makeset()?
There are some confusion in docs.
In this doc -> Returns section, it says that
: Returns a dynamic (JSON) array of the set of distinct values that Expr takes in the group. The array's sort order is undefined.
But in another doc, it says that: Like makelist, makeset also works with ordered data and will generate the arrays based on the order of the rows that are passed into it.
I also tried some methods, but no ordering in the makeset() result.
method 1:
method 2:
And the result like this: ["","Hong Kong","Chicago","Boydton","Campinas","Des Moines"].
but I want the items should be ordered like this: ["","Boydton","Campinas","Chicago","Des Moines","Hong Kong"]
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
The text was updated successfully, but these errors were encountered: