Azure 数据工厂:源数据集具有用户定义的 Table 类型的存储过程

Azure Data Factory : Source data set has a stored procedure with user-defined Table Type

我有一个存储过程,它接受用户定义的 Table 类型作为参数。我想在 Azure 数据工厂的复制数据 activity 中的源数据集中使用此 SP。我看过一些示例,我们可以在接收器数据集中使用用户定义的 Table 类型,但不能在源数据集中使用。

是否可以使用用户定义的 Table 类型作为参数执行 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

如果您需要此功能,请点赞。

有关更多基于配置的方法,您可以从 pragmatic works 查看此博客条目: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

希望对您有所帮助!