简体   繁体   English

Azure 数据工厂数据流:如何筛选具有多个值的输入列

[英]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)

  • I tried to repro this with sample input data.我试图用示例输入数据重现这一点。
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.

相关问题 Azure 数据工厂 - 如何在映射数据流中删除列 - Azure Data Factory - How to drop a column in Mapping Data Flow Azure 数据工厂 - 数据流 - Azure Data factory - Data flow Azure 使用派生列的多种日期格式的数据工厂“数据流”时间转换 - Azure Data Factory 'Data Flow' time conversion for multiple Date Formats using Derived Column 如何在 Azure 数据工厂数据流表达式中过滤包含 substring 的字符串(不)? - How do you filter for a string (not) containing a substring in an Azure Data Factory data flow expression? 在 Azure 数据工厂 - 数据流管道中处理多个目的地 - Handling multiple destinations in Azure Data Factory - Data flow pipeline 如何在Azure数据工厂的数据流聚合活动中添加动态GroupBy列 - How to add Dynamic GroupBy Column in Data Flow Aggregate Activity in Azure Data Factory 如何在 Azure 数据流中编写过滤器表达式? - How to write Filter Expression in Azure Data Flow? Azure 数据流/数据工厂错误处理 - Azure Data Flow / Data factory Error Handling Azure 数据工厂 - MQ 数据流 - Azure Data Factory - MQ data flow 如何根据源和目标的不同列名在 Azure 数据工厂中使数据流列映射动态化? - How can I make Data Flow column mapping Dynamic in Azure Data Factory based on different column names of Source and target?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM