Tuesday, May 12, 2015

How to use tRowGenerator component in Talend for generating random sample data !!

tRowGenerator generates as many rows and fields as needed and feeds each field with a random value.

Drag and drop the tRowGenerator and tLogRow component from palette to job design.
Then connect tRowGenerator by right clicking on it and select Row > Main and drag a line to tLogRow component.



Open the component properties of  tRowGenerator by double clicking on it.
The tRowGenerator Editor opens on a separate window consist of two parts:
  • Schema definition panel at the top of the window
  • Function definition and preview panel at the bottom of the window.
  • Click on [+] sign to add new column.
  • Set the Type of each columns.
  • Select function from “Function” tab on same columns grid by dropdown list or in the Function area, you can select the predefined routine/function if one of them corresponds to your needs.
  • To the change the values of Environment variables in the Schema definition panel in order to customize the function parameters.
    • Select the Function parameters tab in the second part of the window.
    • The Parameter area displays Customized parameter as function name there is no edit option.
    • In the Value area, type the value you want or by clicking ... button it open Expression Builder for editing you can add your custom logic.
    • Click on the Preview Button on the left side of upper part of the window.It will dispaly the details of only one Customer.
    • Set the “Number of Rows for RowGenerator” field to be 10. You can generate as many rows you want.

Now Click on Preview tab you can see that 10 rows are generated randomly.


Open the component properties of  tLogRow by double clicking on it and select option Table(print values in cell of a table). tLogRow displays the flow content on run job console.

Atlast Run the job.

You will see the below result all the data of Customer is generated randomly.

Starting job how_to_use_tRowGenerator_component at 14:43 12/05/2015.

[statistics] connecting to socket on port 3545
[statistics] connected
.----------+-------------------+-----------------+----------------+------------+-------------------+---------------|.
|                                        tLogRow_1                                                                                                   |
|=--------+-------------------+------------------+----------------+------------+-------------------+---------------|
|Cust_ID|Cust_FirstName|Cust_LastName|Cust_Address|Cust_City |Cust_PostalCode|RegisterDate|
|=--------+-------------------+------------------+----------------+------------+-------------------+---------------|
|1           |Woodrow           |Quincy              |4M9zwf         |Providence|691078               |20-02-2015  |
|2           |James                 |Harrison            |agcBva          |Sacramento|453808               |03-10-2013  |
|3           |Lyndon              |Quincy               |7olxAs          |Salem         |593135               |17-10-2014  |
|4           |Herbert              |Madison             |wi2TaM        |Lincoln       |466341              |28-12-2014  |
|5           |Herbert              |Harrison             |mInNN7        |Saint Paul   |477362              |29-03-2014  |
|6           |Harry                 |Taft                    |nT7CIC         |Honolulu     |701503             |08-12-2014  |
|7           |Andrew             |Buchanan           |a9IfVO          |Concord      |457610             |18-10-2013  |
|8           |Ulysses              |Johnson             |H9DlnY         |Harrisburg  |590078              |26-06-2013  |
|9           |John                   |Adams               |I4asX8           |Annapolis   |753132              |12-03-2014  |
|10         |Grover               |Taft                    |z4m4zH         |Pierre          |713152              |18-09-2014  |
'---------+-------------------+-------------------+----------------+-------------+-------------------+---------------|

[statistics] disconnected
Job how_to_use_tRowGenerator_component ended at 14:43 12/05/2015. [exit code=0]

No comments:

Post a Comment