cancel
Showing results for 
Search instead for 
Did you mean: 

Add column to document and repeat value in each row

maahutch
New Contributor

I have one document structured like this: 

FirstNameLastNameTitle
AnnSmithMs
JuneJonesMrs
SamJohnsonMrs

And a second document like this: 

LabelValue
MyEvent8/21/23

I'm trying to merge them together to get a final product like this: 

FirstNameLastNameTitleValue
AnnSmithMs8/21/23
JuneJonesMrs8/21/23
SamJohnsonMrs8/21/23

I'm trying to append the Value column and repeat the value for every row in the first table. I've tried Union and Join but without success. What would be the correct Snap for this use case? 

 

 

 

1 ACCEPTED SOLUTION

ivicakoteski
New Contributor III

Hi @maahutch ,

You can try Join Snap. You will need to specify the type Inner Join and hardcode the value 1 as the left and right paths.

ivicakoteski_0-1692687045698.png
And after that in the mapper snap, you will remove the Label column, or you can use this mapper for removing the Label column before the join snap. 🙂

ivicakoteski_0-1692687618506.png


Hope this helps!
BR.
Ivica

View solution in original post

2 REPLIES 2

ivicakoteski
New Contributor III

Hi @maahutch ,

You can try Join Snap. You will need to specify the type Inner Join and hardcode the value 1 as the left and right paths.

ivicakoteski_0-1692687045698.png
And after that in the mapper snap, you will remove the Label column, or you can use this mapper for removing the Label column before the join snap. 🙂

ivicakoteski_0-1692687618506.png


Hope this helps!
BR.
Ivica

alchemiz
Contributor III

Hi @maahutch ,

Good day,  here's my suggestion first convet the second document into a key-value pair then use join snap to merge it from the streaming documents

I assume that the value from "Label" will be the keyname then value from "Value" will be the value

Expression: sl.ensureArray($.values().join('|')).toObject(v=> v.split('|')[0], v=> v.split('|')[1] )
Target Path: $

alchemiz_0-1692726272032.png