I am trying to copy data from csv files found in Azure Datalake to a table in SQL Server. As a condition, I only want to copy files that are not already in the database by using a file name column found in the database table. Below is my attempt (I have not been able to find an example of this on the internet).
I first use a Get Metadata activity that retrieves all the files that are in the data lake. Concurrently, I use a Lookup activity that is getting the distinct file names in the table of choice. First image shows the organization of activities.
Here are the outputs for the Get Metadata and Lookup activities.
Datalake files Metadata Output
{
"childItems": [
{
"name": "surveydetails_eq5d_001.csv",
"type": "File"
},
{
"name": "surveydetails_koos_001.csv",
"type": "File"
},
{
"name": "surveydetails_oxford_001.csv",
"type": "File"
},
{
"name": "surveydetails_womac_001.csv",
"type": "File"
}
],
Database Table File Lookup
{
"count": 4,
"value": [
{
"file_name": "surveydetails_koos_001.csv"
},
{
"file_name": "surveydetails_oxford_001.csv"
},
{
"file_name": "surveydetails_eq5d_001.csv"
},
{
"file_name": "surveydetails_womac_001.csv"
}
],
Once I have the file names, I use a ForEach and iterate the Datalake items:
@activity('Datalake Files Metadata').output.childitems
Inside the ForEach I have an IfCondition that checks if the current Datalake file is in the Lookup array. If the Datalake file is not in the array, then a copy activity executes. However, with this construct, I would expect nothing to copy since the items in the datalake are already in the database. I have a feeling that the dynamic content in the IfCondition is off but after searching online for the last few hours I cannot find any obvious errors. Is there logic in the IfCondition off? Is it something else? Please help.
Logic for IfCondition:
@not(contains(activity('Database Table File Lookup').output.value, item().name))


