BigQuery - Where can I find the error stream?

Viewed 27581

I have uploaded a CSV file with 300K rows from GCS to BigQuery, and received the following error:

error_image

Where can I find the error stream?

I've changed the create table configuration to allow 4000 errors and it worked, so it must be a problem with the 3894 rows in the message, but this error message does not tell me much about which rows or why.

Thanks

5 Answers

I'm finally managed to see the error stream by running the following command in the terminal:

bq --format=prettyjson show -j <JobID>

It returns a JSON with more details. In my case it was:

"message": "Error while reading data, error message: Could not parse '16.66666666666667' as int for field Course_Percentage (position 46) starting at location 1717164"

You should be able to click on Job History in the BigQuery UI, then click the failed load job. I tried loading an invalid CSV file just now, and the errors that I see are:

Errors:
Error while reading data, error message: CSV table encountered too many errors, giving up. Rows: 1; errors: 1. Please look into the error stream for more details. (error code: invalid)
Error while reading data, error message: CSV table references column position 1, but line starting at position:0 contains only 1 columns. (error code: invalid)

The first one is just a generic message indicating the failure, but the second error (from the "error stream") is the one that provides more context for the failure, namely CSV table references column position 1, but line starting at position:0 contains only 1 columns.

Edit: given a job ID, you can also use the BigQuery CLI to see complete information about the failure. You would use:

bq --format=prettyjson show -j <job ID>

Using python client it's

from google.api_core.exceptions import BadRequest

job = client.load_table_from_file(*args, **kwargs)
try:
    result = job.result()
except BadRequest as ex:

    for err in ex.errors:
        print(err)
    raise
    # or alternatively
    # job.errors

You could also just do.

try:
    load_job.result()  # Waits for the job to complete.
except ClientError as e:
    print(load_job.errors)
    raise e

This will print the errors to screen or you could log them etc.

Following the rest of the answers, you could also see this information in the GCP logs (Stackdriver) tool.

But It might happen that this does not answer your question. It seems like there are detailed errors (such as the one Elliot found) and more imprecise ones. Which gives you no description at all independently of the UI you're using to explore it.

Related