From 6658fddd24b75b7c5e23c660367c56137c25e3ae Mon Sep 17 00:00:00 2001 From: alrocar Date: Wed, 22 Oct 2025 11:23:57 +0200 Subject: [PATCH] feat: add random data generator pipe for testing --- tinybird/copies/random_data_generator.pipe | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 tinybird/copies/random_data_generator.pipe diff --git a/tinybird/copies/random_data_generator.pipe b/tinybird/copies/random_data_generator.pipe new file mode 100644 index 00000000..854a85f3 --- /dev/null +++ b/tinybird/copies/random_data_generator.pipe @@ -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 \ No newline at end of file