adding randomly generated suffix to a duplicated value

Highlighted
Four Stars

adding randomly generated suffix to a duplicated value

I'm retrieving data from a database with the field id (PK) | name fields and I'm supposed to input values from these 2 fields in to another database. However the names in the source database are not unique and I want to have unique names by adding a randomly generated string to it for example

 

testname becomes testname-1223489

 

after my input from the data source, I added the sort row component to sort the name field, and tuniqrow to find the duplicated fields. What are the next steps I should be doing to add the random suffix to the duplicated values in the name column? 

 

Thanks

Forteen Stars

Re: adding randomly generated suffix to a duplicated value

generally, if you need only this, it possible to use tSortRow + tJavaRow (tJavaFlex)

 

define context variable - current_name

 

store first row into context variable

then for each row:

- name == context variable? -> name = name+sequence

- if not, store new name into context variable 

-----------
Employee

Re: adding randomly generated suffix to a duplicated value

Hi, 

 

    If you are not inclined to use tJava components, another method is to do the lookup with target table to identify the existing data and new data (when you are doing left outer join, only new elements will have blank value in lookup). Once existing data is identified, then you can add an additional sequence number as tie-braker for duplicate data.


Warm Regards,
Nikhil Thampi

Please appreciate our Talend community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved :-)

2019 GARNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

What’s New for Talend Summer ’19

Watch the recorded webinar!

Watch Now

Best Practices for Using Context Variables with Talend – Part 2

Part 2 of a series on Context Variables

Blog

Best Practices for Using Context Variables with Talend – Part 1

Learn how to do cool things with Context Variables

Blog

Migrate Data from one Database to another with one Job using the Dynamic Schema

Find out how to migrate from one database to another using the Dynamic schema

Blog