CREATE TABLE datagen_source_table (
id INT,
name STRING,
part1 INT,
part2 INT
) WITH (
'connector' = 'datagen',
'rows-per-second'='1', -- 每秒产生的数据条数
'fields.part1.min'='1',
'fields.part1.max'='2',
'fields.part2.min'='1',
'fields.part2.max'='2'
);
CREATE TABLE hdfs_sink_table
(
id INT,
name STRING,
part1 INT,
part2 INT
) PARTITIONED BY (part1, part2) WITH (
'connector' = 'filesystem',
'path' = 'hdfs://HDFS10000/data/',
'format' = 'json',
'sink.rolling-policy.file-size' = '1M',
'sink.rolling-policy.rollover-interval' = '10 min',
'sink.partition-commit.delay' = '1 s',
'sink.partition-commit.policy.kind' = 'success-file'
);
INSERT INTO hdfs_sink_table
SELECT id, name, part1, part2
FROM datagen_source_table;