Skip to content

Commit 3f139d1

Browse files
authored
feat: frontend of gap fill (#23166)
1 parent 9a9b60d commit 3f139d1

File tree

26 files changed

+2389
-8
lines changed

26 files changed

+2389
-8
lines changed
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Benchmark configuration for GAP_FILL in EOWC (Emit On Window Close) mode
2+
# This benchmark measures the throughput of processing incoming data through GAP_FILL with EOWC
3+
benchmark_name: gap_fill_eowc
4+
5+
# SQL to set up the initial schema and data (run once)
6+
setup_sql: |
7+
CREATE TABLE sensor_data_eowc (
8+
ts TIMESTAMP,
9+
value DOUBLE,
10+
WATERMARK FOR ts AS ts - INTERVAL '1' MINUTE,
11+
PRIMARY KEY (ts)
12+
) APPEND ONLY;
13+
14+
CREATE MATERIALIZED VIEW gap_filled_sensors_eowc AS
15+
SELECT ts, value
16+
FROM GAP_FILL(sensor_data_eowc, ts, INTERVAL '1' MINUTE)
17+
EMIT ON WINDOW CLOSE;
18+
19+
# SQL to prepare the data before each run
20+
prepare_sql: |
21+
-- No preparation needed for each run
22+
23+
# SQL to clean up after each run
24+
conclude_sql: |
25+
-- APPEND ONLY tables do not support DELETE
26+
-- We use different time ranges for each run to avoid primary key conflicts
27+
28+
# SQL to clean up everything after all runs are complete
29+
cleanup_sql: |
30+
DROP MATERIALIZED VIEW IF EXISTS gap_filled_sensors_eowc;
31+
DROP TABLE IF EXISTS sensor_data_eowc;
32+
33+
# SQL to benchmark - Insert sparse time series data and measure processing time
34+
# This tests the throughput of GAP_FILL with EOWC processing incoming data
35+
# Note: Uses current timestamp to ensure unique time ranges for each run
36+
benchmark_sql: |
37+
-- Insert data with gaps (every 5 minutes) starting from NOW()
38+
-- Each run will use a different time range since NOW() advances
39+
INSERT INTO sensor_data_eowc (ts, value)
40+
SELECT
41+
NOW() + (i * INTERVAL '5 minutes'),
42+
20.0 + (i * 0.5)
43+
FROM generate_series(0, 100) AS i;
44+
45+
-- Insert a timestamp far in the future to advance watermark and close all windows
46+
-- Watermark is defined as ts - INTERVAL '1' MINUTE, so this will close all windows
47+
INSERT INTO sensor_data_eowc (ts, value)
48+
VALUES (
49+
NOW() + INTERVAL '10 hours', -- Far enough to close all windows
50+
999.0
51+
);
52+
53+
-- Wait for watermark to advance and windows to close
54+
SELECT pg_sleep(3);
55+
56+
-- Query the results - windows should now be closed by watermark advancement
57+
SELECT COUNT(*) FROM gap_filled_sensors_eowc;
58+
59+
# Number of times to run the benchmark
60+
runs: 30
61+
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Benchmark configuration for GAP_FILL in normal streaming mode
2+
benchmark_name: gap_fill_streaming
3+
4+
# SQL to set up the initial schema and data (run once)
5+
setup_sql: |
6+
CREATE TABLE sensor_data (
7+
ts TIMESTAMP,
8+
value DOUBLE,
9+
PRIMARY KEY (ts)
10+
);
11+
12+
CREATE MATERIALIZED VIEW gap_filled_sensors AS
13+
SELECT ts, value
14+
FROM GAP_FILL(sensor_data, ts, INTERVAL '1' MINUTE);
15+
16+
# SQL to prepare the data before each run
17+
prepare_sql: |
18+
-- No preparation needed for each run
19+
20+
# SQL to clean up after each run
21+
conclude_sql: |
22+
-- Clean up the inserted data after each run
23+
DELETE FROM sensor_data;
24+
25+
# SQL to clean up everything after all runs are complete
26+
cleanup_sql: |
27+
DROP MATERIALIZED VIEW IF EXISTS gap_filled_sensors;
28+
DROP TABLE IF EXISTS sensor_data;
29+
30+
# SQL to benchmark - Insert sparse time series data and measure processing time
31+
# This tests the throughput of GAP_FILL processing incoming data
32+
benchmark_sql: |
33+
INSERT INTO sensor_data (ts, value)
34+
SELECT
35+
'2024-05-21 10:00:00'::TIMESTAMP + (i * INTERVAL '5 minutes'),
36+
20.0 + (i * 0.5)
37+
FROM generate_series(0, 100) AS i;
38+
39+
-- Wait for all data to be processed
40+
SELECT COUNT(*) FROM gap_filled_sensors;
41+
42+
# Number of times to run the benchmark
43+
runs: 30
44+

0 commit comments

Comments
 (0)