Skip to content
Advertisement

Iterate inside BigQuery errors[] collection in Java

When I execute this Java code :

(note : string parameters are dummy examples)

JavaScript

I have this error : com.google.cloud.bigquery.BigQueryException: Error while reading data, error message: JSON table encountered too many errors, giving up. Rows: 1; errors: 1. Please look into the errors[] collection for more details.

I want to iterate this errors collection, but I did not succeed to 🙁

Can someone please give me an hint ?

I found something in Python:

But I did not succeed to have a Java equivalent.

I looked into JavaDoc : https://javadoc.io/doc/com.google.cloud/google-cloud-bigquery/latest/index.html

  • “com.google.cloud.bigquery.Job” object has no “getErrors” method (or something equivalent).
  • I saw a “com.google.cloud.bigquery.BigQueryErrorMessages” object, but I did not succeed to get it from the above “Job” object.

Advertisement

Answer

The error was in my “catch” block header. I catched a generic Exception raiser than a specific BigQueryException. BigQueryException has a getErrors method wich contains all the errors.

JavaScript

So console output is :

JavaScript

And the error root cause in now clear : Invalid NUMERIC value

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement