BigQuery Billing Setup
CREATE TABLE IF NOT EXISTS analytics.pipeline_cost_history (
pipeline_id STRING, -- Identifies which pipeline (e.g., 'user_analytics_daily')
run_id STRING, -- Unique identifier for each pipeline execution
stage STRING, -- Pipeline stage (e.g., 'extract', 'transform', 'load')
query_id STRING, -- Individual BigQuery job ID for granular tracking
cost FLOAT64, -- Actual cost in USD for this query/stage
timestamp TIMESTAMP -- When the cost was incurred
);CREATE OR REPLACE VIEW analytics.query_costs AS
SELECT
job_id,
(total_bytes_processed / POW(1024,4)) * 5.0 AS cost, -- replace with current $/TB pricing
end_time AS timestamp
FROM region-us.INFORMATION_SCHEMA.JOBS_BY_PROJECT;Alternative Approaches
1. Native BigQuery Cost Controls
2. Real-time Cost Tracking
3. Enhanced Cost Attribution
Last updated
