I have a copy pipeline that copies the tables based on a query in a lookup function. The code is below. I am trying to figure out how to filter the rows copied from the Azure SQL Database. Any suggestions are appreciated.
{
"name": "ACCopy",
"properties": {
"activities": [
{
"name": "For Each Table",
"type": "ForEach",
"dependsOn": [
{
"activity": "TableList",
"dependencyConditions": [
"Succeeded"
]
}
],
"userProperties": [],
"typeProperties": {
"items": {
"value": "@activity('TableList').output.value",
"type": "Expression"
},
"isSequential": true,
"activities": [
{
"name": "Export Data",
"type": "Copy",
"dependsOn": [],
"policy": {
"timeout": "7.00:00:00",
"retry": 0,
"retryIntervalInSeconds": 30,
"secureOutput": false,
"secureInput": false
},
"userProperties": [],
"typeProperties": {
"source": {
"type": "AzureSqlSource",
"queryTimeout": "02:00:00",
"partitionOption": "None"
},
"sink": {
"type": "AzureSqlSink",
"preCopyScript": "WHILE(EXISTS(SELECT 1 FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS WHERE CONSTRAINT_TYPE = 'FOREIGN KEY' ))\n--AND TABLE_NAME IN ('Table1', 'Table2') AND CONSTRAINT_NAME LIKE '%FK__%__DL%'))\nBEGIN\n DECLARE @alenzi _alterTable_fk NVARCHAR(2000)\n\n SELECT TOP 1 @alenzi _alterTable_fk = ('ALTER TABLE ' + TABLE_SCHEMA + '.[' + TABLE_NAME + '] DROP CONSTRAINT IF EXISTS [' + CONSTRAINT_NAME + ']')\n FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS\n WHERE CONSTRAINT_TYPE = 'FOREIGN KEY'\n \n\n EXEC (@alenzi _alterTable_fk)\nEND;",
"disableMetricsCollection": false
},
"enableStaging": false,
"translator": {
"type": "TabularTranslator",
"typeConversion": true,
"typeConversionSettings": {
"allowDataTruncation": true,
"treatBooleanAsNumber": false
}
}
},
"inputs": [
{
"referenceName": "AC",
"type": "DatasetReference",
"parameters": {
"TableName": {
"value": "@item().Table_Name",
"type": "Expression"
},
"TableSchema": {
"value": "@item().Table_Schema",
"type": "Expression"
}
}
}
],
"outputs": [
{
"referenceName": "destAC",
"type": "DatasetReference",
"parameters": {
"TableName": {
"value": "@item().Table_Name",
"type": "Expression"
},
"TableSchema": {
"value": "@item().Table_Schema",
"type": "Expression"
}
}
}
]
}
]
}
},
{
"name": "TableList",
"type": "Lookup",
"dependsOn": [
{
"activity": "EXEC spDropFKTruncate",
"dependencyConditions": [
"Succeeded"
]
}
],
"policy": {
"timeout": "7.00:00:00",
"retry": 0,
"retryIntervalInSeconds": 30,
"secureOutput": false,
"secureInput": false
},
"userProperties": [],
"typeProperties": {
"source": {
"type": "AzureSqlSource",
"sqlReaderQuery": "select table_schema, table_name\nFROM INFORMATION_SCHEMA.TABLES \nWHERE table_type = 'base table'\nand table_schema = 'dbo'\nand table_name not in ( 'Con_Audit',\n'EmailLog',\n'ElectronicPayment_Audit',\n'EPT_Audit',\n'ReptFavRole',\n'__RefLog',\n'ReptLD',\n'OppServ_Audit',\n'ReptDef',\n'User_Audit',\n'ReptFav',\n'ClockTime_Audit',\n'ReptLayout',\n'ReptLayoutType',\n'SessionHeader',\n'ErrorLog',\n'PayLog',\n'DashboardElement',\n'SearchField',\n'DashboardElementUser',\n'SearchObject',\n'SearchView',\n'SearchViewFieldDisplay',\n'DropDownListMaster',\n'AdminNotification',\n'SearchViewFieldFilter',\n'SearchViewFieldGroup',\n'InventoryVariance_Audit',\n'SearchViewFieldSort',\n'SearchViewUser',\n'ReportFavoriteUser',\n'PageRequest',\n'sysdiagrams',\n'EmailReport',\n'WT_Audit',\n'ExecutionHistory',\n'SearchHistory',\n'SearchViewRole',\n'ASNV',\n'CustomerPortalInvitation',\n'ItemAllocationArchive',\n'ItemAllocationDuplicateExceptions',\n'contactTemp',\n'WTV_audit',\n'AMS',\n'WTT_Audit',\n'DashboardElementUserValue',\n'ActivitySync',\n'ActivitySyncAttachment',\n'ReportLayout_temp',\n'DashboardElementSharedUser',\n'Permission',\n'DeviceData',\n'DashboardElementSharedRole')",
"queryTimeout": "02:00:00",
"partitionOption": "None"
},
"dataset": {
"referenceName": "tablelistTestC",
"type": "DatasetReference"
},
"firstRowOnly": false
}
},
{
"name": "EXEC spDropFKTruncate",
"type": "SqlServerStoredProcedure",
"dependsOn": [],
"policy": {
"timeout": "7.00:00:00",
"retry": 0,
"retryIntervalInSeconds": 30,
"secureOutput": false,
"secureInput": false
},
"userProperties": [],
"typeProperties": {
"storedProcedureName": "[dbo].[spDropFKTruncate]"
},
"linkedServiceName": {
"referenceName": "linkedservicedestTestC",
"type": "LinkedServiceReference"
}
}
],
"annotations": [],
"lastPublishTime": "2021-01-22T16:26:28Z"
},
"type": "Microsoft.DataFactory/factories/pipelines"
}