Talend tRowGenerator

Talend tRowGenerator 组件用于生成随机行,以便我们用于测试目的。Talend tRowGenerator 支持所有内置函数,并具有一些用于生成名字、姓氏、州等的函数。我们可以使用此 Talend Row Generator 生成任意数量的行。

Talend tRowGenerator 示例

将 tRowGenerator 拖放到作业设计中。

Add Talend tRowGenerator to Workflow to generate rows

有两种方法可以为随机生成的行添加列名。第一种方法是单击“编辑模式”按钮,然后添加列名、数据类型、长度和精度。

为了演示 Talend tRowGenerator,我将添加 SNo 和名字作为列名。

Click the Edit Schema to add Columns

第二种方法是单击“RowGenerator 编辑器”按钮。

单击 Talend tRowGenerator 编辑器按钮将打开以下窗口。在此,您可以看到我们之前创建的列。要添加新列,请使用 + 按钮。为了生成随机行,我们必须分配一个函数。对于 SNo,我们使用了数字序列函数。

Talend tRowGenerator Function to to generate rows

使用下方标记的窗格(函数参数选项卡)来修改值,例如起始值和步长。

请将 Talend tRowGenerator 的行数更改为您需要的数量。默认值为 100,因此默认情况下它会生成 100 行。但是,您可以将其更改为 1000、10 等。

Check the Function parameters for start and step value

Talend 数据生成器类具有 getFirstName 函数,该函数会生成随机的名字。所以,我选择这个。

Add the remaining columns

在这里,我们使用了 tLogRow 来显示行并运行 tRowGenerator 作业。从下面的 Talend 图像中,您可以看到生成的随机行。

Run the Talend tRowGenerator Job to generate rows

我将添加更多列。

  • 姓氏:我们使用 getLastName() 方法生成随机姓氏。接下来,我们使用 StringHandling UPCASE 将随机生成的姓氏转换为大写。
  • 街道:getUsStreet() 方法用于生成美国街道。
  • 日期:getCurrentDate() 用于获取当前日期。
  • 销量:Numeric random 函数从最小值到最大值生成随机整数。
Add More Columns in Talend tRowGenerator to generate rows

请参阅 Talend tRowGenerator 作业生成的随机行。

Run the Talend tRowGenerator to generate random rows