Skip to content

Commit 1b56b62

Browse files
authored
feat: add random data generator pipe for testing (#189)
1 parent 82b7cc9 commit 1b56b62

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
DESCRIPTION >
2+
Copy pipe that generates random analytics events data with configurable row limit and date range parameters for testing purposes
3+
4+
NODE generate_random_events
5+
SQL >
6+
%
7+
SELECT
8+
now() - interval rand() % ({{ Int32(days_back, 7, description="Number of days back to generate timestamps for") }} * 86400) second as timestamp,
9+
concat('session_', toString(rand() % 10000)) as session_id,
10+
arrayElement(['page_hit', 'web_vital', 'click', 'scroll'], (rand() % 4) + 1) as action,
11+
arrayElement(['1.0', '1.1', '2.0'], (rand() % 3) + 1) as version,
12+
concat('{"href":"https://example.com/', arrayElement(['home', 'about', 'contact', 'products', 'blog'], (rand() % 5) + 1), '","domain":"example.com","pathname":"/', arrayElement(['home', 'about', 'contact', 'products', 'blog'], (rand() % 5) + 1), '","user-agent":"Mozilla/5.0 (compatible; test)"}') as payload,
13+
concat('tenant_', toString((rand() % 5) + 1)) as tenant_id,
14+
arrayElement(['example.com', 'test.com', 'demo.org'], (rand() % 3) + 1) as domain
15+
FROM numbers({{ Int32(row_limit, 1000, description="Number of random rows to generate") }})
16+
17+
TYPE COPY
18+
TARGET_DATASOURCE analytics_events

0 commit comments

Comments
 (0)