Home > Software design >  Azure Synapse ingest pipeline with ForEach activity on multiple database tables (MySQL)
Azure Synapse ingest pipeline with ForEach activity on multiple database tables (MySQL)

Time:10-22

I am trying to ingest several tables incrementally in a pipeline on Azure Synapse using a ForEach Activity.

I have defined a variable as an array of strings. Each string corresponds to the name of a table that I want to query inside the ForEach and copy data from it.

My basic problem is how to pass as the table name at a SELECT query at the source of the Copy Activity, the @item that iterates in the ForEach.

*My connection to the MySQL database is established via ODBC.

CodePudding user response:

enter image description hereLet's say you have two tables named as dimcustomer,dimpersondetail. 1.You can put this two values in a array type variable 2.you can use the command @concat('select * from ',item()) in the source querty. Please refer to the screenshots attached.

CodePudding user response:

In the copy activity which is inside the for-each activity, instead of giving query as select * from @item(), give select * from {@item()}.

I tried to repro this in my environment. Below are the steps.

  • A variable named list is created and two sample table names T3, T4 are given as default value.

enter image description here

  • In for each activity Items, @variables('list') is given

enter image description here

  • Inside for each activity, a lookup activity and copy activity is added.

enter image description here

  • In copy activity, Query is given as select * from @{item()} where datet > '@{activity('Lookup1').output.firstRow. datet}

enter image description here

  • All activities inside for-each got executed successfully.

enter image description here

  • Related