我有一个存储过程,它接受用户定义的表类型作为参数。我想在 Azure 数据工厂的复制数据事件的源数据集中使用此 SP。我见过一些示例,其中我们可以在接收器数据集中使用用户定义的表类型,但不能在源数据集中使用用户定义的表类型。
是否可以使用用户定义的表类型作为参数来执行 SP,以从 SQL 中获取数据并将其复制到 Blob 存储上?
这是我的 SP:
CREATE PROCEDURE [export].[up_get_qnxt_enrollment_date]
@effectiveDate DATETIME
, @lobPlanDimIDs export.intList READONLY
AS
BEGIN
......
END
export.intList是用户定义的Table类型:
CREATE TYPE [export].[intList] AS TABLE(
[Id] [int] NULL,
[Name] [varchar(256)] NULL
)
我无法在 Azure DF 的源数据集中设置此参数。我尝试将其设置为 JSON 数组,但没有成功:
"typeProperties": {
"source": {
"type": "AzureSqlSource",
"sqlReaderStoredProcedureName": "[export].[up_get_qnxt_enrollment_date]",
"storedProcedureParameters": {
"effectiveDate": {
"type": "DateTime",
"value": "2004-01-01"
},
"lobPlanDimIDs": {
"type": "export.intList",
"value": [
{
"Id": { "type": "int", "value": 1 },
"Name": { "type": "String", "value": "ABC" }
},
{
"Id": { "type": "int", "value": 2 },
"Name": { "type": "String", "value": "DEF" }
}
]
}
},
"queryTimeout": "02:00:00"
我有什么遗漏或者此功能在 Azure DF 中尚不可用吗?
更新: 根据 Martin Esteban Zurita 的建议,我使用了查询而不是 SP。这是一个非常好的解决方法。我还创建了一个功能请求: Support for User-defined table in Azure DF for Source
如果您需要此功能,请投票。
最佳答案
对于更多基于配置的方法,您可以查看实用作品中的此博客条目:https://blog.pragmaticworks.com/using-stored-procedure-in-azure-data-factory
当我遇到这个问题时,我解决它的方法是使用查询而不是使用存储过程
然后像从 sql 命令行调用查询一样调用查询,例如:
DECLARE @tmp DATETIME
SET @tmp = GETDATE()
DECLARE @lob AS intList
insert into @lob (Id, Name) select 1, 'ABC'
insert into @lob (Id, Name) select 2, 'DEF'
EXEC [up_get_qnxt_enrollment_date] @tmp, @lob
希望这有帮助!
关于Azure数据工厂: Source data set has a stored procedure with user-defined Table Type,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60996541/