public void insertDataToTable( String projectId, String datasetId, String tableName, List<Map<String, Object>> rows) { try { List<Rows> dataRows = rows.stream().map(row -> new Rows().setJson(row)).collect(Collectors.toList()); this.bqClient .tabledata() .insertAll( projectId, datasetId, tableName, new TableDataInsertAllRequest().setRows(dataRows)) .execute(); LOG.info("Successfully inserted data into table : " + tableName); } catch (Exception e) { LOG.debug("Exceptions caught when inserting data: " + e.getMessage()); } } }
private void verifyInsertAll(int expectedRetries) throws IOException { verify(mockClient, times(expectedRetries)).tabledata(); verify(mockTabledata, times(expectedRetries)) .insertAll(anyString(), anyString(), anyString(), any(TableDataInsertAllRequest.class)); }
TableDataInsertAllResponse response = bigquery.tabledata().insertAll(projectId, datasetId, tableId, content).execute();
client .tabledata() .insertAll(ref.getProjectId(), ref.getDatasetId(), ref.getTableId(), content);
.insertAll(configuration.getProjectId(), configuration.getDatasetId(), tableIdWithPartition,
private void onInsertAll(List<List<Long>> errorIndicesSequence) throws Exception { when(mockClient.tabledata()).thenReturn(mockTabledata); final List<TableDataInsertAllResponse> responses = new ArrayList<>(); for (List<Long> errorIndices : errorIndicesSequence) { List<TableDataInsertAllResponse.InsertErrors> errors = new ArrayList<>(); for (long i : errorIndices) { TableDataInsertAllResponse.InsertErrors error = new TableDataInsertAllResponse.InsertErrors(); error.setIndex(i); } TableDataInsertAllResponse response = new TableDataInsertAllResponse(); response.setInsertErrors(errors); responses.add(response); } doAnswer( invocation -> { Bigquery.Tabledata.InsertAll mockInsertAll = mock(Bigquery.Tabledata.InsertAll.class); when(mockInsertAll.execute()) .thenReturn( responses.get(0), responses .subList(1, responses.size()) .toArray(new TableDataInsertAllResponse[responses.size() - 1])); return mockInsertAll; }) .when(mockTabledata) .insertAll(anyString(), anyString(), anyString(), any(TableDataInsertAllRequest.class)); }
@Override public TableDataInsertAllResponse insertAll( String projectId, String datasetId, String tableId, TableDataInsertAllRequest request) { try { return bigquery.tabledata().insertAll(projectId, datasetId, tableId, request).execute(); } catch (IOException ex) { throw translate(ex); } }
@Override public TableDataInsertAllResponse insertAll(String datasetId, String tableId, TableDataInsertAllRequest request) { try { return bigquery.tabledata() .insertAll(this.options.projectId(), datasetId, tableId, request) .execute(); } catch (IOException ex) { throw translate(ex); } }
@Override public TableDataInsertAllResponse insertAll(String datasetId, String tableId, TableDataInsertAllRequest request) { try { return bigquery.tabledata() .insertAll(this.options.projectId(), datasetId, tableId, request) .execute(); } catch (IOException ex) { throw translate(ex); } }
@Override public TableDataInsertAllResponse insertAll( String projectId, String datasetId, String tableId, TableDataInsertAllRequest request) { try { return bigquery.tabledata().insertAll(projectId, datasetId, tableId, request).execute(); } catch (IOException ex) { throw translate(ex); } }