Read the error and fix the query

A failed query tells you what went wrong and where. Most errors in the first weeks are one of a handful, and each message points at the thing to look at.

How it works

An error has two parts. The top is a plain sentence for learners. Under it is the text BigQuery wrote, and that is where the position and the types are. After Run it sits in small grey type under the sentence. After Check it follows the label Original message:. The position is written at [line:column]. Lines count from 1 at the top of the query and columns from 1 at the start of each line. It marks the spot where BigQuery stopped. Read the sentence for the idea, then use the original message to find the exact spot and the name or type it mentions.

Common mistake

The quickest way to silence an error is often the wrong one. ANY_VALUE(x) returns one arbitrary value of x from each group. Using it, or casting a number to text, removes the message and changes the rows. Fix what the message names, then read the result.

Worked example

SELECT vehicle_id, test_result
FROM `learn.mot.fact_mot_test`
WHERE completed_date = '2024-06-15'

The first version of this query wrote test_reslt. The original message was Unrecognized name: test_reslt; Did you mean test_result? at [1:20].

It gives the wrong name, a guess at the right one and the place: line 1, column 20, which is the start of test_reslt in the SELECT list.

All BigQuery lessons