use of com.google.api.services.bigquery.model.TableDataInsertAllRequest.Rows in project google-cloud-java by GoogleCloudPlatform.
the class BigQueryImpl method insertAll.
@Override
public InsertAllResponse insertAll(InsertAllRequest request) {
final TableId tableId = request.getTable().setProjectId(getOptions().getProjectId());
final TableDataInsertAllRequest requestPb = new TableDataInsertAllRequest();
requestPb.setIgnoreUnknownValues(request.ignoreUnknownValues());
requestPb.setSkipInvalidRows(request.skipInvalidRows());
requestPb.setTemplateSuffix(request.getTemplateSuffix());
List<Rows> rowsPb = Lists.transform(request.getRows(), new Function<RowToInsert, Rows>() {
@Override
public Rows apply(RowToInsert rowToInsert) {
return new Rows().setInsertId(rowToInsert.getId()).setJson(rowToInsert.getContent());
}
});
requestPb.setRows(rowsPb);
return InsertAllResponse.fromPb(bigQueryRpc.insertAll(tableId.getProject(), tableId.getDataset(), tableId.getTable(), requestPb));
}
Aggregations