【问题标题】:Azure Data Factory Dynamic content parameterAzure 数据工厂动态内容参数
【发布时间】:2019-07-03 14:00:49
【问题描述】:

我正在尝试使用 Azure 数据工厂从源表中将上次运行时的数据加载到 lastmodifieddate。

这工作正常:

@concat(' SELECT  * FROM dbo. ',
        item().TABLE_list ,
       ' WHERE   modifieddate > DATEADD(day, -1, GETDATE())')"

当我使用时:

@concat(' SELECT  * FROM dbo.  ',
         item().TABLE_list ,
        '  WHERE   modifieddate > @{formatDateTime(
                  addhours(pipeline().TriggerTime-24)),
                  ''yyyy','-','MM','-','ddTHH',':','mm',':','ssZ''}')

得到错误为 ""errorCode": "2200",

"message": "Failure happened on 'Source' side. 'Type=System.Data.SqlClient.SqlException,Message=Must declare the scalar variable \"@\".,Source=.Net SqlClient Data Provider,SqlErrorNumber=137,Class=15,ErrorCode=-2146232060,State=2,Errors=[{Class=15,Number=137,State=2,Message=Must declare the scalar variable \"@\".,},],'",
    "failureType": "UserError",
    "target": "Copy Data1"
}
  • 我犯了什么错误?

  • 我需要在 where 条件下动态传递管道的最后运行时间日期。

【问题讨论】:

    标签: azure azure-data-factory


    【解决方案1】:
        SELECT * 
        FROM dbo.@{item().TABLE_LIST} 
        WHERE modifieddate > 
        @{formatDateTime(addhours(pipeline().TriggerTime, -24), 'yyyy-MM-ddTHH:mm:ssZ')}
    

    您可以使用字符串插值表达式。 Concat 让事情变得复杂。

    https://docs.microsoft.com/en-us/azure/data-factory/control-flow-expression-language-functions#expressions

    【讨论】:

    • 我尝试在@item().tablelist 中删除@,但没有用。
    • 你能分享一下语法错误吗?有截图更好。您无法在 @item 处删除该 @。
    • 我猜你需要在日期时间前后加上一个单引号? select * From dbo.@{item().TABLE_LIST} WHERE modifieddate > '@{formatDateTime(addhours(pipeline().TriggerTime, -24), 'yyyy-MM-ddTHH:mm:ssZ')}'
    • Hi Fang Liu,您能否建议如何将 Azure 数据湖的文件名下沉到数据库表,使用元数据和 forach 输入文件。我需要将 ADL 路径的文件名传递到数据库表中。
    • 我浏览了你发的链接“stackoverflow.com/questions/51853329/…
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-11-25
    • 1970-01-01
    • 2022-09-29
    相关资源
    最近更新 更多