Every chart refresh in Data Studio (formerly Looker Studio) runs a BigQuery query that someone pays for. Three settings keep that cost down on the table etlmcp writes when the BigQuery destination is available: make the date column the report's date filter, so BigQuery reads only the days on screen; put the right project in the billing project field; and, in a custom query, compare date to the report's date parameters without wrapping the column in a function. The BigQuery destination is coming, so this page describes the table as the code builds it today.
The table etlmcp creates
When the destination is available, etlmcp creates the table itself and refuses to write into a table it did not create. The table is partitioned by day on date and clustered on _etlmcp_pipeline_id, the column that records which pipeline wrote each row. Several pipelines can share one table: each run deletes only its own pipeline's rows in the run's date range and inserts the new ones in one transaction.
The columns follow etlmcp's common row shape:
| Column | BigQuery type |
|---|---|
date |
DATE |
impressions, clicks, cost, conversions, conversion_value, ctr, cpc, cpm, cpa |
FLOAT64 |
network, account_id, account_name, campaign_id, campaign_name, adgroup_id, adgroup_name, ad_id, ad_name, currency |
STRING |
_etlmcp_pipeline_id |
STRING |
Platform-specific fields arrive as extra columns. etlmcp names them extra.<field> and, for BigQuery, replaces every character that is not a letter, digit or underscore with an underscore: extra.utm source becomes extra_utm_source. You type those names in Looker Studio without quotes, unlike the dotted names in PostgreSQL. The project defaults to the one in the service-account key unless you enter another project id on the destination.
Use the partition column as the date filter
Looker Studio reads tables partitioned on a DATE, DATETIME or TIMESTAMP column, and Google's connector page lets you choose the partition column as the data source's main date filter. Google says this makes charts faster and queries cheaper. When you add the table through the BigQuery connector, pick date as that column. The date range control then limits which daily partitions a query reads.
Billing project versus data project
The billing project pays for the queries; the data project holds the table. When you pick a table from your recent projects, the chosen project does both jobs; from shared projects you can choose them separately. In a custom query you type the billing project into its own field and name the table by its full path, project.dataset.table, in the FROM clause.
Whichever project pays must be linked to a Google Cloud billing account. The account whose credentials the data source uses (the owner by default, or each viewer, or a service account) needs the BigQuery Data Viewer and BigQuery Job User roles.
Custom queries with the report's date range
Turn on the date range parameters in the Parameters section of the connection, then use @DS_START_DATE and @DS_END_DATE in upper case. Looker Studio passes every parameter as text, and its examples parse the dates as YYYYMMDD, so convert them with PARSE_DATE('%Y%m%d', …) before comparing them to date:
SELECT
date,
network,
campaign_name,
SUM(cost) AS cost,
SUM(clicks) AS clicks,
SUM(conversions) AS conversions,
SUM(conversion_value) AS conversion_value
FROM `your-data-project.your_dataset.your_table`
WHERE date BETWEEN PARSE_DATE('%Y%m%d', @DS_START_DATE)
AND PARSE_DATE('%Y%m%d', @DS_END_DATE)
GROUP BY date, network, campaign_name
Sum cost only within one currency: accounts in different currencies share the column.
Queries that stop partition pruning
BigQuery skips partitions only when the filter on date compares the column with constant values, either bare or inside one of the built-in functions BigQuery lists as supporting pruning. These forms read every partition:
- Wrapping the column in an unsupported function, such as
FORMAT_DATE('%Y%m%d', date) BETWEEN @DS_START_DATE AND @DS_END_DATE. Parse the parameters instead and leavedatealone. - Arithmetic on the column, such as adding an interval to
date. Move the arithmetic to the other side of the comparison. - Comparing
datewith another column or with the result of a subquery. - Joining the date filter with
ORto a condition on another column, such asnetwork.
Before you paste a query into Looker Studio, dry-run it in the BigQuery console to confirm that partition pruning applies.