Search in sources :

Example 1 with Rows

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));
}
Also used : TableDataInsertAllRequest(com.google.api.services.bigquery.model.TableDataInsertAllRequest) RowToInsert(com.google.cloud.bigquery.InsertAllRequest.RowToInsert) Rows(com.google.api.services.bigquery.model.TableDataInsertAllRequest.Rows)

Aggregations

TableDataInsertAllRequest (com.google.api.services.bigquery.model.TableDataInsertAllRequest)1 Rows (com.google.api.services.bigquery.model.TableDataInsertAllRequest.Rows)1 RowToInsert (com.google.cloud.bigquery.InsertAllRequest.RowToInsert)1