Load data into BigQuery, write SQL to analyze it, understand partitioning, and visualize results with Looker Studio.
BigQuery is Google's serverless data warehouse. You pay per query (first 1TB/month free). It can analyze terabytes in seconds using standard SQL.
# Create a dataset
bq mk --dataset my_project:my_dataset
# Load a CSV file
bq load \
--source_format=CSV \
--autodetect \
my_dataset.my_table \
gs://my-bucket/data.csv
# Run a query
bq query --use_legacy_sql=false \
'SELECT name, COUNT(*) as count FROM my_dataset.my_table GROUP BY name ORDER BY count DESC LIMIT 10'-- BigQuery supports standard SQL
SELECT
DATE(created_at) as day,
COUNT(*) as events,
SUM(revenue) as total_revenue,
AVG(revenue) as avg_revenue
FROM `my_project.analytics.events`
WHERE created_at >= TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL 30 DAY)
AND status = 'completed'
GROUP BY day
ORDER BY day DESC
-- Window functions work
SELECT
user_id,
event_time,
ROW_NUMBER() OVER (PARTITION BY user_id ORDER BY event_time) as session_event
FROM `my_project.analytics.events`PARTITION BY DATE(created_at).