Azure数据工厂: Source data set has a stored procedure with user-defined Table Type

标签 azure stored-procedures azure-pipelines azure-data-factory user-defined-types

我有一个存储过程,它接受用户定义的表类型作为参数。我想在 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

当我遇到这个问题时,我解决它的方法是使用查询而不是使用存储过程 enter image description here

然后像从 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/

相关文章:

versioning - 在 VSTS 构建过程中使用 `dotnet pack` 将构建号添加到包版本

azure - 引用 azurepipelines.yml 中的发布变量

node.js - 将 Cordova 的文件传输插件与 Express/blob 存储结合使用

Azure SQL 数据库太慢或太贵

azure - 将 HTTPS 重定向到 HTTP 的规则重写到 IIS 会导致 null HttpContext.Request.ContentType

python - 在 Azure DevOps 管道中找不到 Pytest

sql - 如何使用模式绑定(bind)创建存储过程?

MySQL SP 和事件被 Google Cloud SQL 自动回滚

oracle - oracle存储过程中的更新语句不起作用

azure - 更改 Azure Pipelines 中的当前工作目录