Bibek Adhikari
Bibek Adhikari

Reputation: 181

BigQuery Java API - Cannot Send Null For TableRow Value

I am trying to set values on BigQuery table using java big query api but its throwing NullPointerException (java.lang.NullPointerException: null value in entry: popup=null ) every time I send the null value.

The null value should be completely acceptable since my Mode is NULLABLE on schema itself. I have bunch of other fields that have null value on them.

Any suggestion on this issue would be really helpful for me, I am stuck no where due to this.

Note : I may ignore and not set those fields having null values on them but that is not the solution I am looking for. My piece of code is below:

TableRow row = new TableRow();
                row.set("ip", "test");
                row.set("popup", null);

Upvotes: 1

Views: 1121

Answers (1)

Graham Polley
Graham Polley

Reputation: 14781

Don't explicitly set the value to null. Simply ignore it. If it's not present in the payload to BigQuery, it will be set to null. You will not be able to set it to null anyway, because the API is checking for null parameters, and you can't change that behaviour.

So, do this instead:

TableRow row = new TableRow();
row.set("ip", "test");

Upvotes: 4

Related Questions