unnest_in_view.sql
1 CREATE TABLE impulse_source ( 2 timestamp TIMESTAMP, 3 counter bigint unsigned not null, 4 subtask_index bigint unsigned not null 5 ) WITH ( 6 connector = 'single_file', 7 path = '$input_dir/impulse.json', 8 format = 'json', 9 type = 'source', 10 event_time_field = 'timestamp' 11 ); 12 13 CREATE TABLE unnest_output ( 14 counter bigint unsigned not null, 15 ) WITH ( 16 connector = 'single_file', 17 path = '$output_path', 18 format = 'json', 19 type = 'sink' 20 ); 21 22 CREATE VIEW unnest_view AS 23 SELECT unnest(counters) as counter FROM ( 24 SELECT array_agg(counter) as counters, tumble(interval '1 day') FROM impulse_source GROUP BY tumble(interval '1 day')); 25 26 INSERT INTO unnest_output SELECT counter FROM unnest_view;