Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions tinybird/copies/random_data_generator.pipe
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
DESCRIPTION >
Copy pipe that generates random analytics events data with configurable row limit and date range parameters for testing purposes

NODE generate_random_events
SQL >
%
SELECT
now() - interval rand() % ({{ Int32(days_back, 7, description="Number of days back to generate timestamps for") }} * 86400) second as timestamp,
concat('session_', toString(rand() % 10000)) as session_id,
arrayElement(['page_hit', 'web_vital', 'click', 'scroll'], (rand() % 4) + 1) as action,
arrayElement(['1.0', '1.1', '2.0'], (rand() % 3) + 1) as version,
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,
concat('tenant_', toString((rand() % 5) + 1)) as tenant_id,
arrayElement(['example.com', 'test.com', 'demo.org'], (rand() % 3) + 1) as domain
FROM numbers({{ Int32(row_limit, 1000, description="Number of random rows to generate") }})

TYPE COPY
TARGET_DATASOURCE analytics_events