Request a demo

BigQuery error · Query and syntax errors

The query is too large

The SQL text is longer than BigQuery's limit of 1,024K characters, counting comments and whitespace. It is almost always a huge inline list (IN with thousands of IDs, VALUES rows, a generated CASE). Pass the list as an array query parameter or load it into a table and join.

Checked against the Google Cloud docs in November 2026

The error message

The query is too large (<N>K characters, <M> characters over the limit). The maximum standard SQL query length is 1024.00K characters, including comments and white space characters.

Causes

Long inline lists

Applications and notebooks that paste thousands of IDs into WHERE user_id IN (...) or build UNION ALL SELECT rows for every record grow the query text until it passes the limit.

Generated SQL

Macros, BI tools and code generators that expand a mapping into a giant CASE, or repeat expressions for hundreds of columns, produce very long statements. The limit counts the text you send, including comments and whitespace.

Related limits

GoogleSQL also limits the unresolved query to 1 MB and the resolved query, including the text of all referenced views and wildcard tables, to 12 MB. Legacy SQL queries are limited to 256 KB unresolved.

How to fix it

1. Pass the list as an array parameter

Send the values as one ARRAY<STRING> query parameter (--parameter='ids:ARRAY<STRING>:[...]' in bq, or the array parameter type in your client library). The query text stays short however long the list is.

SELECT user_id, event_name, event_ts
FROM `project.dataset.events`
WHERE event_date = '2026-11-22'
  AND user_id IN UNNEST(@user_ids);

2. Load the list into a table and join

For large or reused lists, load them into a table (or a temp table in a script) and join. Joining on a small table also keeps the plan simple.

SELECT e.user_id, e.event_name, e.event_ts
FROM `project.dataset.events` AS e
JOIN `project.scratch.campaign_users` AS c USING (user_id)
WHERE e.event_date = '2026-11-22';

3. Turn generated CASE mappings into lookup tables

Store the mapping as rows (key, value) and join it, instead of writing one WHEN per key.

How to prevent it

  • Never build SQL by concatenating data into the query text; use query parameters, which also prevents SQL injection.
  • Keep mapping and filter lists in tables owned by the pipeline, so they are versioned and visible.

FAQ

What is the maximum query length in BigQuery?

1,024K characters for a GoogleSQL query, including comments and whitespace. Separate limits apply to the unresolved query (1 MB) and the resolved query with all referenced views (12 MB).

Is a query that is too large billed?

No. BigQuery rejects the request before a job runs, so nothing is billed and no slots are used.

How many query parameters can a query have?

Up to 10,000 parameters per GoogleSQL query, and the whole request, including parameters, can be up to 10 MB. One array parameter holding the whole list counts as a single parameter.

SQL reference

More query and syntax errors

All BigQuery error messages · What 50M daily events say about BigQuery failures

Stop finding BigQuery failures in Slack threads

Masthead watches every BigQuery job, dbt model, Dataform action and Airflow task from audit logs, groups failures into incidents and shows which tables and dashboards are affected. No access to your data and no added BigQuery cost.