0

I'm creating a job in Talend where I have to generate files containing data generated with tRowGenerator along with other sources : SQL Server database and delimited files.

enter image description here

The issue is that I have duplicated files with the same primary key. All i want to get is 100 records(420 rows) : For each Random UUID generated i shall get 42 rows and so on, but instead i'm getting the same row 10 times(it's duplicated 10 times)

enter image description here

I'm getting data from 3 sources as shown below: enter image description here

To get this fields in my output file: enter image description here enter image description here

4

1 回答 1

1

如果我理解正确,您正在使用其中的一个函数tRowGenerator来获取随机数据。
问题是 Talend 提供的数据生成函数并不是真正随机的,它们从预定义的值列表中获取值。您可以查看源代码以验证它们是否有一百左右的价值,因此您一定会得到重复的。
要获取唯一值,请使用生成 UUID 的简单方法创建 Talend 例程:

public class Utils {

    /**
     * getRandom: return a random UUID
     * 
     * 
     * {talendTypes} String
     * 
     * {Category} User Defined
     * 
     * {param} string("world") input: dummy input
     * 
     * {example} getRandom("world") # 01e98b98-05d6-427c-978d-1f86d0ea4712
     */
    public static String getRandom(String input) {
        return java.util.UUID.randomUUID().toString();
    }
}

然后,您可以从以下位置访问此功能tRowGenerator在此处输入图像描述

在此处输入图像描述

还有一件事,我不确定您的要求到底是什么,但是由于您的输入之间没有连接键,因此您将获得所有输入之间的笛卡尔连接(42x298x206 行)。所以你可能想定义一个连接条件。
如果您确实定义了连接条件,请确保tMap输入的顺序正确(您将tRowGenerator流用作主连接,其他用作查找)。

于 2020-05-06T18:26:10.817 回答