Flink:使用 Faker 和 DataGen 生成测试数据
最编程
2024-03-20 07:17:36
...
-- example 1: currency_rates
drop table if exists currency_rates;
create table if not exists currency_rates (
currency_code string,
eur_rate decimal(6,4),
rate_time timestamp(3)
)
with (
'connector' = 'faker',
'fields.currency_code.expression' = '#{Currency.code}',
'fields.eur_rate.expression' = '#{Number.randomdouble ''4'',''0'',''10''}',
'fields.rate_time.expression' = '#{date.past ''15'',''SECONDS''}',
'rows-per-second' = '100'
);
select * from currency_rates;
-- example 2: transactions
drop table if exists transactions;
create table if not exists transactions (
`id` string,
`currency_code` string,
`total` decimal(10,2),
`transaction_time` timestamp(3),
watermark for `transaction_time` as transaction_time - interval '30' second
) with (
'connector' = 'faker',
'fields.id.expression' = '#{Internet.UUID}',
'fields.currency_code.expression' = '#{Currency.code}',
'fields.total.expression' = '#{Number.randomDouble ''2'',''10'',''1000''}',
'fields.transaction_time.expression' = '#{date.past ''30'',''SECONDS''}',
'rows-per-second' = '100'
);
select * from transactions;