带有存储过程的 Azure 数据工厂副本 activity
Azure Data Factory copy activity with stored procedure
对于您需要将存储过程的第一个参数(包含 table 类型的参数)命名为与 属性 "tableName" 完全相同的事实,是否有解决方法输入数据集?
我正在使用 Azure 数据工厂 V1。
输入数据集(本地 Oracle 源)
{
"name": "DS-ORA-WMS-CDC-DLYTRN",
"properties": {
"published": false,
"type": "OracleTable",
"linkedServiceName": "LS-ORA-WMS-CDC",
"typeProperties": {
"tableName": "WMST.DLYTRN"
},
"availability": {
"frequency": "Hour",
"interval": 1
},
"external": true,
"policy": {}
}}
输出数据集(Azure SQL 数据库)
{
"name": "DS-ASQL-ANALYTICS-DLYTRN",
"properties": {
"published": false,
"type": "AzureSqlTable",
"linkedServiceName": "LS-SQL-ANALYTICS-DB",
"typeProperties": {
"tableName": "wms.DLYTRN"
},
"availability": {
"frequency": "Hour",
"interval": 1
}
}}
管道
{
"name": "test",
"properties": {
"description": "test pipeline",
"activities": [
{
"type": "Copy",
"typeProperties": {
"source": {
"type": "OracleSource",
"oracleReaderQuery": "select * from WMST.DLYTRN"
},
"sink": {
"type": "SqlSink",
"sqlWriterStoredProcedureName": "wms.spPersistDlytrn",
"storedProcedureParameters": {
"srcdc": {
"value": "CDC"
}
},
"sqlWriterTableType": "wms.DLYTRNType",
"writeBatchSize": 0,
"writeBatchTimeout": "00:00:00"
}
},
"inputs": [
{
"name": "DS-ORA-WMS-CDC-DLYTRN"
}
],
"outputs": [
{
"name": "DS-ASQL-ANALYTICS-DLYTRN"
}
],
"policy": {
"timeout": "1.00:00:00",
"concurrency": 1,
"retry": 3
},
"scheduler": {
"frequency": "Hour",
"interval": 1
},
"name": "TestWMSCopyWithSproc"
}
],
"start": "2018-01-04T07:00:00Z",
"end": "2018-01-08T00:00:00Z",
"isPaused": false,
"hubName": "hub",
"pipelineMode": "Scheduled"
}}
存储过程
CREATE PROCEDURE [wms].[spPersistDlytrn]
@DLYTRNTable [wms].[DLYTRNType] READONLY,
@srcdc VARCHAR(4)
AS
...
RETURN 0
当 运行 activity 时 return 出现以下错误信息:
Database operation failed on server 'Sink:tcp:someservername.database.windows.net,1433' with SQL Error Number '349'. Error message from database execution : The procedure "spPersistDlytrn" has no parameter named "@wms.DLYTRN"..
因为无法命名存储过程参数"wms.DLYTRN"有没有办法排除架构前缀?
我现在无法对此进行测试,但正如此处所说 https://docs.microsoft.com/en-us/azure/data-factory/v1/data-factory-invoke-stored-procedure-from-copy-activity#stored-procedure-definition "The name of the first parameter of stored procedure must match the tableName defined in the dataset JSON"。
在示例中,它在 sp 中声明了两个参数:
- @Marketing [dbo].[MarketingType] READONLY
- @stringData varchar(256)
在数据集中它不使用模式前缀,它只是说:"tableName": "Marketing",没有模式(试试这个,因为你的输出数据集定义中有模式)。
然后在管道中,它只是为 stringData 赋值。还有这个:"SqlWriterTableType":"MarketingType",看到它没有架构前缀,而你的管道定义确实有它。
所以总结一下:MarketingType是table的实际名称,在副本activity的SqlWriterTableType属性处,而Marketing是参数的名称在存储过程中,以及输出数据集中 tablename 的名称。
希望对您有所帮助!
我最近解决了完全相同的问题。
编辑您的副本 activity 引用为 "Source" 的数据集代码,因此它的 typeProperties
部分包含 table 没有架构前缀的名称。
例如:
"typeProperties": {
"tableName": "DLYTRN"
}
此外,您的过程的第一个参数的名称必须与 table 的名称匹配,因此它应该是 @DLYTRN
而不是 @DLYTRNTable
。
对于您需要将存储过程的第一个参数(包含 table 类型的参数)命名为与 属性 "tableName" 完全相同的事实,是否有解决方法输入数据集?
我正在使用 Azure 数据工厂 V1。
输入数据集(本地 Oracle 源)
{
"name": "DS-ORA-WMS-CDC-DLYTRN",
"properties": {
"published": false,
"type": "OracleTable",
"linkedServiceName": "LS-ORA-WMS-CDC",
"typeProperties": {
"tableName": "WMST.DLYTRN"
},
"availability": {
"frequency": "Hour",
"interval": 1
},
"external": true,
"policy": {}
}}
输出数据集(Azure SQL 数据库)
{
"name": "DS-ASQL-ANALYTICS-DLYTRN",
"properties": {
"published": false,
"type": "AzureSqlTable",
"linkedServiceName": "LS-SQL-ANALYTICS-DB",
"typeProperties": {
"tableName": "wms.DLYTRN"
},
"availability": {
"frequency": "Hour",
"interval": 1
}
}}
管道
{
"name": "test",
"properties": {
"description": "test pipeline",
"activities": [
{
"type": "Copy",
"typeProperties": {
"source": {
"type": "OracleSource",
"oracleReaderQuery": "select * from WMST.DLYTRN"
},
"sink": {
"type": "SqlSink",
"sqlWriterStoredProcedureName": "wms.spPersistDlytrn",
"storedProcedureParameters": {
"srcdc": {
"value": "CDC"
}
},
"sqlWriterTableType": "wms.DLYTRNType",
"writeBatchSize": 0,
"writeBatchTimeout": "00:00:00"
}
},
"inputs": [
{
"name": "DS-ORA-WMS-CDC-DLYTRN"
}
],
"outputs": [
{
"name": "DS-ASQL-ANALYTICS-DLYTRN"
}
],
"policy": {
"timeout": "1.00:00:00",
"concurrency": 1,
"retry": 3
},
"scheduler": {
"frequency": "Hour",
"interval": 1
},
"name": "TestWMSCopyWithSproc"
}
],
"start": "2018-01-04T07:00:00Z",
"end": "2018-01-08T00:00:00Z",
"isPaused": false,
"hubName": "hub",
"pipelineMode": "Scheduled"
}}
存储过程
CREATE PROCEDURE [wms].[spPersistDlytrn]
@DLYTRNTable [wms].[DLYTRNType] READONLY,
@srcdc VARCHAR(4)
AS
...
RETURN 0
当 运行 activity 时 return 出现以下错误信息:
Database operation failed on server 'Sink:tcp:someservername.database.windows.net,1433' with SQL Error Number '349'. Error message from database execution : The procedure "spPersistDlytrn" has no parameter named "@wms.DLYTRN"..
因为无法命名存储过程参数"wms.DLYTRN"有没有办法排除架构前缀?
我现在无法对此进行测试,但正如此处所说 https://docs.microsoft.com/en-us/azure/data-factory/v1/data-factory-invoke-stored-procedure-from-copy-activity#stored-procedure-definition "The name of the first parameter of stored procedure must match the tableName defined in the dataset JSON"。
在示例中,它在 sp 中声明了两个参数:
- @Marketing [dbo].[MarketingType] READONLY
- @stringData varchar(256)
在数据集中它不使用模式前缀,它只是说:"tableName": "Marketing",没有模式(试试这个,因为你的输出数据集定义中有模式)。
然后在管道中,它只是为 stringData 赋值。还有这个:"SqlWriterTableType":"MarketingType",看到它没有架构前缀,而你的管道定义确实有它。
所以总结一下:MarketingType是table的实际名称,在副本activity的SqlWriterTableType属性处,而Marketing是参数的名称在存储过程中,以及输出数据集中 tablename 的名称。
希望对您有所帮助!
我最近解决了完全相同的问题。
编辑您的副本 activity 引用为 "Source" 的数据集代码,因此它的 typeProperties
部分包含 table 没有架构前缀的名称。
例如:
"typeProperties": {
"tableName": "DLYTRN"
}
此外,您的过程的第一个参数的名称必须与 table 的名称匹配,因此它应该是 @DLYTRN
而不是 @DLYTRNTable
。