No join function for array in azure synapse expression builder

Anurag4 Gupta 21 Reputation points
2022-05-24T13:03:42.837+00:00

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 Synapse Analytics
Azure Synapse Analytics
An Azure analytics service that brings together data integration, enterprise data warehousing, and big data analytics. Previously known as Azure SQL Data Warehouse.
4,369 questions
Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
9,539 questions
0 comments No comments
{count} votes

Accepted answer
  1. HimanshuSinha-msft 19,376 Reputation points Microsoft Employee
    2022-05-25T19:16:39.157+00:00

    Hello @Anurag4 Gupta ,

    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

1 additional answer

Sort by: Most helpful
  1. ShaikMaheer-MSFT 37,896 Reputation points Microsoft Employee
    2022-05-25T18:12:28.94+00:00

    Hi @Anurag4 Gupta ,

    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.