2017-07-25 76 views
2

我正在將SQL Server Integration Services包移植到Azure數據工廠。將7列表複製到6列表

我有兩個表(表1和表2),它們位於不同的服務器上。一個有七個專欄,另外六個專欄。我隨後在https://docs.microsoft.com/en-us/azure/data-factory/data-factory-map-columns

表1 DDL的例子:

CREATE TABLE dbo.Table1 
(
    zonename nvarchar(max), 
    propertyname nvarchar(max), 
    basePropertyid int, 
    dfp_ad_unit_id bigint, 
    MomentType nvarchar(200), 
    OperatingSystemName nvarchar(50) 
) 

表2 DDL

CREATE TABLE dbo.Table2 
(
    ZoneID int IDENTITY, 
    ZoneName nvarchar(max), 
    propertyName nvarchar(max), 
    BasePropertyID int, 
    dfp_ad_unit_id bigint, 
    MomentType nvarchar(200), 
    OperatingSystemName nvarchar(50) 
) 

在ADF中,我定義表1中:

{ 
    "$schema": "http://datafactories.schema.management.azure.com/schemas/2015-09-01/Microsoft.DataFactory.Table.json", 
    "name": "Table1", 
    "properties": { 
    "type": "AzureSqlTable", 
    "linkedServiceName": "PlatformX", 
    "structure": [ 
     { "name": "zonename" }, 
     { "name": "propertyname" }, 
     { "name": "basePropertyid" }, 
     { "name": "dfp_ad_unit_id" }, 
     { "name": "MomentType" }, 
     { "name": "OperatingSystemName" } 
    ], 
    "external": true, 
    "typeProperties": { 
     "tableName": "Platform.Zone" 
    }, 
    "availability": { 
     "frequency": "Day", 
     "interval": 1 
    } 
    } 
} 

在ADF我將表2定義爲:

{ 
    "$schema": "http://datafactories.schema.management.azure.com/schemas/2015-09-01/Microsoft.DataFactory.Table.json", 
    "name": "Table2", 
    "properties": { 
    "type": "SqlServerTable", 
    "linkedServiceName": "BrixDW", 
    "structure": [ 
     { "name": "ZoneID" }, 
     { "name": "ZoneName" }, 
     { "name": "propertyName" }, 
     { "name": "BasePropertyID" }, 
     { "name": "dfp_ad_unit_id" }, 
     { "name": "MomentType" }, 
     { "name": "OperatingSystemName" } 
    ], 
    "external": true, 
    "typeProperties": { 
     "tableName": "staging.DimZone" 
    }, 
    "availability": { 
     "frequency": "Day", 
     "interval": 1 
    } 
    } 
} 

正如你所看到的,Table2有一個標識列,它將自動填充。

這應該是一個簡單的複製活動:

{ 
    "$schema": "http://datafactories.schema.management.azure.com/schemas/2015-09-01/Microsoft.DataFactory.Pipeline.json", 
    "name": "Copy_Table1_to_Table2", 
    "properties": { 
    "description": "Copy_Table1_to_Table2", 
    "activities": [ 
     { 
     "name": "Copy_Table1_to_Table2", 
     "type": "Copy", 
     "inputs": [ 
      { "name": "Table1" } 
     ], 
     "outputs": [ 
      { 
      "name": "Table2" 
      } 
     ], 
     "typeProperties": { 
      "source": { 
      "type": "SqlSource", 
      "sqlReaderQuery": "select * from dbo.Table1" 
      }, 
      "sink": { 
      "type": "SqlSink" 
      }, 
      "translator": { 
      "type": "TabularTranslator", 
      "columnMappings": "zonename: ZoneName, propertyname: propertyName, basePropertyid: BasePropertyID, dfp_ad_unit_id: dfp_ad_unit_id, MomentType: MomentType, OperatingSystemName: OperatingSystemName" 
      } 
     }, 
     "policy": { 
      "concurrency": 1, 
      "executionPriorityOrder": "OldestFirst", 
      "retry": 3, 
      "timeout": "01:00:00" 
     }, 
     "scheduler": { 
      "frequency": "Day", 
      "interval": 1 
     } 
     } 
    ], 
    "start": "2017-07-23T00:00:00Z", 
    "end": "2020-07-19T00:00:00Z" 
    } 
} 

我想通過不映射了zoneid,它只是被忽略。但ADF給我以下錯誤。

拷貝活動遇到了用戶錯誤:GatewayNodeName = APP1250S,錯誤碼= UserErrorInvalidColumnMappingColumnCountMismatch, '類型= Microsoft.DataTransfer.Common.Shared.HybridDeliveryException,提供給複製活動消息=無效的列映射:' 區域名稱:ZONENAME,PROPERTYNAME:propertyName的,basePropertyid:BasePropertyID,dfp_ad_unit_id:dfp_ad_unit_id,MomentType:MomentType,OperatingSystemName:OperatingSystemName',詳細消息:目標結構和列映射之間的不同列數。目標列數:7,列映射數:6。檢查表定義中的列映射。Source = Microsoft.DataTransfer.Common,'

簡而言之,我試圖將7列表複製到6列表中,Data Factory不喜歡它。我怎樣才能完成這項任務?

回答

0

一個選項是創建一個不包含標識列並插入該視圖的7列表的視圖。

CREATE VIEW bulkLoad.Table2 
AS 
SELECT 
    ZoneName, 
    propertyName, 
    BasePropertyID, 
    dfp_ad_unit_id, 
    MomentType, 
    OperatingSystemName 
GO 

我可以做一些挖掘,看看列映射是否可能有一些技巧,但應該解除阻止。

HTH

0

我被MSFT支持告知剛剛從表定義中刪除標識列。它似乎有效。

+0

你的意思是來自JSON的'structure'組件嗎?目前尚不清楚。 – wBob