Files
cfw-autumn/server/tinybird/materializations/events_hourly_mv_pipe.pipe
2026-05-15 12:58:30 +01:00

23 lines
693 B
Plaintext

DESCRIPTION >
Materializes events into hourly aggregates with native JSON properties.
Allows multi-property GROUP BY via properties.field syntax.
NODE materialize
SQL >
SELECT
org_id,
env,
customer_id,
event_name,
coalesce(entity_id, '') as entity_id,
internal_product_id,
toStartOfHour(timestamp) as hour,
CAST(coalesce(properties, '{}') AS JSON) as properties,
sum(toFloat64(coalesce(value, 1))) as total_value,
count() as event_count
FROM events
GROUP BY org_id, env, customer_id, event_name, entity_id, internal_product_id, hour, properties
TYPE materialized
DATASOURCE events_hourly_mv