Skip to content

Instantly share code, notes, and snippets.

@gomesiago
gomesiago / elevar-bigquery-cleanup-view.sql
Created November 11, 2025 18:02
This SQL query is a predefined template for creating a formatted view of Elevar event data in BigQuery. It extracts key fields from the raw JSON payload (data and attributes columns) into individual columns, allowing for easier reporting and exploration. Replace the final FROM path with your own project, dataset, and table name before running it.
SELECT
-- Metadata
publish_time,
JSON_EXTRACT_SCALAR(attributes, '$.client') AS client,
JSON_EXTRACT_SCALAR(attributes, '$.event') AS attribute_event_name,
-- Event Info
JSON_EXTRACT_SCALAR(data, '$.event.event_name') AS event_name,
JSON_EXTRACT_SCALAR(data, '$.event.event_time') AS event_time,
JSON_EXTRACT_SCALAR(data, '$.event.id') AS event_id,