question

Anurag4Gupta-9970 avatar image
0 Votes"
Anurag4Gupta-9970 asked Anurag4Gupta-9970 commented

No join function for array in azure synapse expression builder

There is no function in expression builder which can work as join for an array.
The expected functionality of join function is to convert the array in string by joining the array element with the 2nd argument passed. Basically the functionality should be opposite of split.

only these functions are there:
205157-image.png
Ex: arr = [1, 2, 3, 4]

join(arr, ',') => "1,2,3,4"

For achieving the same functionality, I have to do a work around with reduce and rtrim.

rtrim(toString(reduce(arr, "", #acc + ',' + #item, #result)), ",")

This leads to long nested functions if I have to use this inside another function.


azure-data-factoryazure-synapse-analytics
image.png (88.5 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

HimanshuSinha-MSFT avatar image
0 Votes"
HimanshuSinha-MSFT answered Anurag4Gupta-9970 commented

Hello @Anurag4Gupta-9970,

Just adding to what @ShaikMaheer-MSFT called out earlier . I am assuming the ask here is for data flow . As we do not have a staright forward function , we will have to go and evaluate using other function . I was able to make it work using the below expression . It is simiar to yours , but i am also using the map function .

> reduce(map([1,2,3,4], toString(#item) + ','),'',#acc+toString(#item),#result)

Output

205595-image.png


Please do let me if you have any queries.
Thanks
Himanshu


  • Please don't forget to click on 130616-image.png or upvote 130671-image.png button whenever the information provided helps you. Original posters help the community find answers faster by identifying the correct answer. Here is how

  • Want a reminder to come back and check responses? Here is how to subscribe to a notification

  • If you are interested in joining the VM program and help shape the future of Q&A: Here is how you can be part of Q&A Volunteer Moderators



image.png (1.2 KiB)
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @HimanshuSinha-MSFT , thanks for your answer.

For now, I will continue to use the workaround for split with reduce and rtrim. Have to use rtrim as I dont want the separator character at the end of the string as it is expected from join function.

rtrim(toString(reduce(arr, "", #acc + ',' + #item, #result)), ",")

But it will really help if this function will be available by default.

0 Votes 0 ·
ShaikMaheer-MSFT avatar image
0 Votes"
ShaikMaheer-MSFT answered Anurag4Gupta-9970 commented

Hi @Anurag4Gupta-9970 ,

Thank you for posting query in Microsoft Q&A Platform.

I just tried join() function in Synapse Pipeline. It is there and working fine.

205594-image.png

If you are saying about data flows, then yes in data flows there is not direct method. We should consider work arounds. You also consider converting array directly to string using toString() function and then use replace() function to remove [ and ] symbols.

Hope this helps. Please let us know if any further queires.


Please consider hitting Accept Answer button. Accepted answers help community as well.


image.png (117.5 KiB)
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @ShaikMaheer-MSFT, the join function is present at the dynamic content builder 205980-image.png


But not at visual expression builder which is present at dataflow level. I am not sure about the naming convention of both cause this is what I can find as the header. So, I have to use the custom long function to achieve the same as u can see in the image. It will be good if the same functionality can be provided at the Visual Expression Builder as well.


206058-image.png


0 Votes 0 ·
image.png (54.0 KiB)
image.png (49.3 KiB)