Azure Synapse : Contacted array value is resulting with "\ value. How to get rid of this special values

55 Views Asked by At

1. I have 50 file_names coming from lookup.

2. I wanted to Contact all the file_names into one variable and then update the staus of all file_names in one go.

3 I have a variable to do this concat like below.

Append Filename = @item().File_Name
Get list of filenames = @concat(variables('v_conc_filename'), item().File_Name, ',')
fila_filename = @replace(replace(variables('v_get_filenames'), '\"', ''), '\\', '')

enter image description here

However, even on trying to replace the string value. I am getting the final output like below

{
    "name": "v_final_filename",
    "value": 
    "[\"P_Full_Additional_Data_List_Audit.000.PARQUET\",
    \"P_Full_Adviser_Audit.000.PARQUET\",
    \"P_Full_Additional_Data_Delete.000.PARQUET\",
    \"P_Full_Adviser.000.PARQUET\"
}

I want the contacted filenames to be without \ and " like below

{
    "name": "v_final_filename",
    "value": 
    "[P_Full_Additional_Data_List_Audit.000.PARQUET,
    P_Full_Adviser_Audit.000.PARQUET,
    P_Full_Additional_Data_Delete.000.PARQUET,
    P_Full_Adviser.000.PARQUET
}

so that in next step I can take this filenames and directly update in DB with the filename.

2

There are 2 best solutions below

0
AnnuKumari On

Actually '' is not part of the output , it is just an escape character which will be visible on the UI. The reason for that is value contains array which is enclosed in the double quotes as string ". But inside the array, there are 4 values which are individually enclosed within double quotes, which needs to be escaped. That's the reason ADF adds \ before " for the values which are enclosed within another ".

You do not actually need to remove the backslash as it's not part of the output content.

0
Pratik Lad On

To get your desired output you need to use the variable that will get filenames to thr outside of foreach activity.

  • Under foreach activity use append variable to append the filenames in a single array. enter image description here
  • After that take set variable with string type outside foreach variable with below expression:
@concat('[',join(variables('AppendVariableName'),','),']')

enter image description here

Output:

enter image description here