I want to use byName() and byNames() in my flow.But I am not getting exact usage of it like am not finding any examples / scenarios . The Examples given by Azure are not clear. Please help .
CodePudding user response:
byName()
searches for a column in a given stream name (stream name is optional). Look at the following example. Let's say you have source data as in the following image:
- I have added another column called team with value as
og
using derived column transformation.
- Now consider you want to populate a column based on whether it exists or not. If there is no column with given name,
null
values are returned. I used the following dynamic content inderivedColumn1
transformation,
toString(byName('team'))
- I get the following output:
Since we have given
team
as a column, it populated each row ofnew
column with correspondingteam
column value. Instead of givingteam
, if we give any other column name that does not exist, then the entirenew
column will be populated with NULL values.byNames()
is similar tobyName()
. Instead of giving a single column, you give an array of column names. The following dynamic content is an example where I have given array of column names, along with stream (optional argument).
array(byNames(['gname','team'],'source1'))
- I got the following output:
- Here I am searching for columns
gname and team
in the streamsource1
(which has only id and gname columns). Since we are looking to get a column where it does not exist, it has populated thenew
column withNULL
. If all the given column names exist, the values are populated accordingly.