[英]Azure Data Factory Data Flow: how to filter input column with multiple values
What I am trying to do is basically something that emulates SQL WHERE IN CLAUSE in a data flow.我想做的基本上是在数据流中模拟 SQL WHERE IN CLAUSE 的东西。 I want to pass comma separated string of values into my data flow, ie ptf_proc_link_id = "A, B, C".我想将逗号分隔的字符串值传递到我的数据流中,即 ptf_proc_link_id = "A, B, C"。
Inside of the data flow, I want to use those values, to filter one of my input columns:在数据流内部,我想使用这些值来过滤我的输入列之一:
It would be equal to writing in SQL SELECT * FROM my_delta_table where ptf_proc_link_id in (A, B, C).这等同于在 SQL 中编写 SELECT * FROM my_delta_table where ptf_proc_link_id in (A, B, C)。
However, data flow documentation only hints that I can filter single values ie ptf_proc_link_id = A. I have tried to use intersect, but then both parameters needs to be arrays, and in my case one of them is a column.然而,数据流文档只提示我可以过滤单个值,即 ptf_proc_link_id = A。我尝试使用相交,但两个参数都需要是数组,在我的例子中,其中一个是一列。 I could do something like ptf_proc_link_id = A OR ptf_proc_link_id = B OR ptf_proc_link_id = C, but I never know how many input values I would have, so I cannot hardcode it.我可以做类似 ptf_proc_link_id = A OR ptf_proc_link_id = B OR ptf_proc_link_id = C 的事情,但我不知道我会有多少输入值,所以我不能硬编码。
It seems like a very simple use case for a data flow, so I would be really thankful if someone could explain me what the correct approach would be.这似乎是一个非常简单的数据流用例,所以如果有人能向我解释正确的方法是什么,我将非常感激。
Thank you!谢谢!
You can use in()
function in ADF data flow to filter multiple values.您可以在 ADF 数据流中使用in()
函数来过滤多个值。
Syntax: in(array of items,item to find)
语法: in(array of items,item to find)
key钥匙 | class班级 | name姓名 | mark标记 | DOB出生日期 |
---|---|---|---|---|
1 1个 | 1 1个 | Arjuna阿周那 | 50 50 | 1/2/2015 2015 年 1 月 2 日 |
2 2个 | 1 1个 | Basanta巴桑塔 | 47 47 | 5/1/2015 5/1/2015 |
3 3个 | 1 1个 | Subala苏巴拉 | 54 54 | 5/6/2015 5/6/2015 |
4 4个 | 2 2个 | Gandharva干闼婆 | 60 60 | 1/2/2014 2014 年 1 月 2 日 |
5 5个 | 2 2个 | Ujjvala乌伊瓦拉 | 55 55 | 9/2/2014 9/2/2014 |
6 6个 | 2 2个 | Sanadhana萨那达那 | 64 64 | 1/12/2014 2014 年 1 月 12 日 |
7 7 | 3 3个 | Sridama斯里达玛 | 75 75 | 1/2/2013 2013 年 1 月 2 日 |
8 8个 | 3 3个 | Sudama须玉 | 80 80 | 13/12/2013 13/12/2013 |
9 9 | 3 3个 | Vasu瓦苏 | 81 81 | 1/12/2013 2013 年 1 月 12 日 |
img:1 Source data preview. img:1 源数据预览。
I tried to filter the records with key=2,4,6我尝试使用 key=2,4,6 过滤记录
Filter condition can be given as in(['2','4','6'], key)
or in(array('2','4','6'), key)
过滤条件可以指定为in(['2','4','6'], key)
或in(array('2','4','6'), key)
img:2 Filter condition settings img:2 过滤条件设置
Output data of the filter Transformation:过滤器转换的输出数据:
img:3 Filter Transformation data preview img:3 Filter Transformation数据预览
You can also create a dataflow parameter of array type and give that parameter in the filter condition of filter transformation.您也可以创建一个数组类型的数据流参数,并在过滤转换的过滤条件中赋予该参数。 img: 4 dataflow parameters img:4个数据流参数
Filter condition while using parameter will be in($parameter1,key)
使用参数时的过滤条件为in($parameter1,key)
Reference: Microsoft document on data flow expression - in
参考资料:关于data flow expression - in
Microsoft 文档- 在
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.