1
votes

I am getting missing row with invalid reason in response while inserting data into BigQuery.

{"errors":[{"message":"Missing row.","reason":"invalid"}],"index":0}, {"errors":[{"message":"Missing row.","reason":"invalid"}]

Below is the code which i am executing:

/The below lines calls the dfp API to get all adunits AdUnitPage page = inventoryService.getAdUnitsByStatement(statementBuilder.toStatement()); List dfpadunits = new ArrayList();

                if (page.getResults() != null) {
                    totalResultSetSize = page.getTotalResultSetSize();
                    int i = page.getStartIndex();
                    for (AdUnit adUnit : page.getResults()) {
                        /*System.out.printf(
                                "%d) Ad unit with ID '%s' and name '%s' was found.%n", i++,
                                adUnit.getId(), adUnit.getName());*/

                        //Map<String,Object> dfpadunitrow = new HashMap<String,Object>();
                        //dfpadunitrow.put(adUnit.getId(), adUnit.getName());
                        Rows dfpadunit = new TableDataInsertAllRequest.Rows();
                        dfpadunit.setInsertId(adUnit.getId());
                        dfpadunit.set("id",adUnit.getId());
                        dfpadunit.set("name",adUnit.getName());
                        dfpadunits.add(dfpadunit);

                    }
                }

                TableDataInsertAllRequest content = new TableDataInsertAllRequest();
                content.setRows(dfpadunits);
                content.setSkipInvalidRows(true);
                content.setIgnoreUnknownValues(true);
                System.out.println(dfpadunits.get(0));
                Bigquery.Tabledata.InsertAll request = bigqueryService.tabledata().insertAll(projectId, datasetId, tableId, content);
                TableDataInsertAllResponse response = request.execute();
                System.out.println(response.getInsertErrors());

I put loggers to check my data is populated correctly but when i try to insert records into bigquery using insertAll , I get missing row in response with invalid reason.

Thanks, Kapil

1
Did my answer work for you? - Graham Polley

1 Answers

4
votes

You need to use a TableRow object. This works (I tested):

TableDataInsertAllRequest.Rows dfpadunit = new TableDataInsertAllRequest.Rows();

TableRow row = new TableRow();
row.set("id",adUnit.getId());
row.set("name",adUnit.getName());

dfpadunit.setInsertId(adUnit.getId());
dfpadunit.setJson(row);

dfpadunits.add(dfpadunit);