简体   繁体   English

Azure 数据工厂 V2 在 SQL 中使用参数

[英]Azure Data Factory V2 Using Params in SQL

New to ADF in general and hitting a speed bump with the following scenario, would really appreciate any guidance on how to achieve this.一般来说,ADF 的新手和遇到以下情况的减速带,非常感谢有关如何实现这一目标的任何指导。

In my pipeline I want to use simple SQL to control how much data I process, so using:在我的管道中,我想使用简单的 SQL 来控制我处理的数据量,因此使用:

SELECT * FROM DPA.USER_REGISTRATIONS 
WHERE REG_DATE BETWEEN DATE '2020-01-01' AND DATE '2020-06-09'

Using the 'preview data' button/tool in ADF UI this returns a sample of exactly what I am looking for.使用 ADF UI 中的“预览数据”按钮/工具可以返回我正在寻找的样本。 Great, but I need the second DATE value to always be the current date.很好,但我需要第二个 DATE 值始终为当前日期。 I'm sure this must be very simple but I can't seem to find the right way to form the params/expressions to get it to work.我确定这一定非常简单,但我似乎无法找到正确的方法来形成参数/表达式以使其工作。

I am trying:我在尝试:

SELECT * FROM DPA.USER_REGISTRATIONS 
WHERE REG_DATE BETWEEN DATE '2020-01-01' AND DATE @pipeline.parameters.today;

Where I have a pipeline level parameter defined with name: today and value: utcnow() But that doesn't work.我在其中定义了一个管道级参数,名称为:today 和值为:utcnow() 但这不起作用。

Can someone please advise on how to create and reference a suitable param?有人可以就如何创建和引用合适的参数提出建议吗? Thanks!谢谢!

To do this based on dynamic values, you will need to use the Pipeline Expression Language (PEL) (and most likely variables) to build the query string.要基于动态值执行此操作,您将需要使用管道表达式语言 (PEL)(以及最有可能的变量)来构建查询字符串。 This answer may prove useful to you. 这个答案可能对你有用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM