The Talend tRowGenerator component generates random rows so that we can use them for testing purposes. The Talend tRowGenerator supports all the built-in functions and has a few functions to generate the first name, last name, state, etc. We can use this Talend Row Generator to generate as many rows as we want.
Talend tRowGenerator Example
Drag and drop the tRowGenerator into the job design.
There are two ways to add column names for the randomly generated rows. The first option is to click the Edit Schema button and add the column names, data type, length, and precision.
For the Talend tRowGenerator demo purpose, let me add the SNo and first name as the column names.
The second option is to click on the RowGenerator Editor button.
Clicking the Talend tRowGenerator Editor button opens the following window. Here, you can see the columns that we created earlier. And to add a new column, please use the + button. In order to generate random rows, we have to assign a function.
For the SNo, we used the Numeric sequence function.
Use the below pane (Function Parameters tab) to alter the values such as the start value and steps.
The Talend Data Generator class has the getFirstName function that generates random first names. So, let me select the same.
Please change the Number of Rows for the Talend tRowGenerator to the required number. The default value is 100, so by default, it generates 100 rows. However, you can change it to 1000, 10, etc.
Here, we used the tLogRow to display the rows and run the tRowGenerator job. From the below Talend image, you can see generated random rows.
Let me add a few more columns.
- LastName: We used getLastName() method to generate random last names. Next, we used the StringHandling UPCASE to convert the randomly generated last names to upper case.
- Street: getUsStreet() method to generate US streets.
- Date: getCurrentDate() to get the current date.
- Sales: The Numeric random function generates random integer numbers from the minimum value to the maximum value.
Please see the randomly generated rows by the Talend tRowGenerator job.