@Override public boolean deleteTable(String projectId, String datasetId, String tableId) { try { bigquery.tables().delete(projectId, datasetId, tableId).execute(); return true; } catch (IOException ex) { BigQueryException serviceException = translate(ex); if (serviceException.getCode() == HTTP_NOT_FOUND) { return false; } throw serviceException; } }
@Override public Table getTable( String projectId, String datasetId, String tableId, Map<Option, ?> options) { try { return bigquery .tables() .get(projectId, datasetId, tableId) .setFields(Option.FIELDS.getString(options)) .execute(); } catch (IOException ex) { BigQueryException serviceException = translate(ex); if (serviceException.getCode() == HTTP_NOT_FOUND) { return null; } throw serviceException; } }
TableList tableList = bigquery .tables() .list(projectId, datasetId) .setMaxResults(Option.MAX_RESULTS.getLong(options))
@Override public Table create(Table table, Map<Option, ?> options) { try { // unset the type, as it is output only table.setType(null); TableReference reference = table.getTableReference(); return bigquery .tables() .insert(reference.getProjectId(), reference.getDatasetId(), table) .setFields(Option.FIELDS.getString(options)) .execute(); } catch (IOException ex) { throw translate(ex); } }
@Override public Table patch(Table table, Map<Option, ?> options) { try { // unset the type, as it is output only table.setType(null); TableReference reference = table.getTableReference(); return bigquery .tables() .patch(reference.getProjectId(), reference.getDatasetId(), reference.getTableId(), table) .setFields(Option.FIELDS.getString(options)) .execute(); } catch (IOException ex) { throw translate(ex); } }
public void deleteTable(String projectId, String datasetId, String tableName) { try { bqClient.tables().delete(projectId, datasetId, tableName).execute(); LOG.info("Successfully deleted table: " + tableName); } catch (Exception e) { LOG.debug("Exception caught when deleting table: " + e.getMessage()); } }
private void deleteTable(String datasetId, String tableId) throws IOException, InterruptedException { executeWithBackOff( client.tables().delete(projectId, datasetId, tableId), String.format( "Error when trying to delete the temporary table %s in dataset %s of project %s. " + "Manual deletion may be required.", tableId, datasetId, projectId)); }
public void createNewTable(String projectId, String datasetId, Table newTable) { try { this.bqClient.tables().insert(projectId, datasetId, newTable).execute(); LOG.info("Successfully created new table: " + newTable.getId()); } catch (Exception e) { LOG.debug("Exceptions caught when creating new table: " + e.getMessage()); } }
private static void listTables(Bigquery service, String projectNumber, String datasetId) throws IOException { Bigquery.Tables.List listTablesReply = service.tables().list(projectNumber, datasetId); TableList tableList = listTablesReply.execute(); if (tableList.getTables() != null) { List tables = tableList.getTables(); System.out.println("Tables list:"); for (TableList.Tables table : tables) { System.out.format("%s\n", table.getId()); } } }
private void onTableGet(Table table) throws IOException { when(mockClient.tables()).thenReturn(mockTables); when(mockTables.get(anyString(), anyString(), anyString())).thenReturn(mockTablesGet); when(mockTablesGet.execute()).thenReturn(table); }
private void verifyTableGet() throws IOException { verify(mockClient).tables(); verify(mockTables).get("project", "dataset", "table"); verify(mockTablesGet, atLeastOnce()).execute(); }
@Override public boolean deleteTable(String projectId, String datasetId, String tableId) { try { bigquery.tables().delete(projectId, datasetId, tableId).execute(); return true; } catch (IOException ex) { BigQueryException serviceException = translate(ex); if (serviceException.getCode() == HTTP_NOT_FOUND) { return false; } throw serviceException; } }
private Table getTable(TableReference ref) throws IOException, InterruptedException { Bigquery.Tables.Get get = client.tables().get(ref.getProjectId(), ref.getDatasetId(), ref.getTableId()); return executeWithBackOff( get, String.format( "Error opening BigQuery table %s of dataset %s.", ref.getTableId(), ref.getDatasetId())); }
private TableSchema getSchema(Bigquery bq) { try { return bq.tables() .get( pipelineOptions.getProject(), pipelineOptions.getTargetDataset(), table.getTableReference().getTableId()) .execute() .getSchema(); } catch (IOException e) { throw new RuntimeException(e); } }
@Override public boolean deleteTable(String datasetId, String tableId) { try { bigquery.tables().delete(this.options.projectId(), datasetId, tableId).execute(); return true; } catch (IOException ex) { BigQueryException serviceException = translate(ex); if (serviceException.code() == HTTP_NOT_FOUND) { return false; } throw serviceException; } }
@Override public boolean deleteTable(String datasetId, String tableId) { try { bigquery.tables().delete(this.options.projectId(), datasetId, tableId).execute(); return true; } catch (IOException ex) { BigQueryException serviceException = translate(ex); if (serviceException.code() == HTTP_NOT_FOUND) { return false; } throw serviceException; } }
@Override public Table create(Table table, Map<Option, ?> options) { try { // unset the type, as it is output only table.setType(null); return bigquery.tables() .insert(this.options.projectId(), table.getTableReference().getDatasetId(), table) .setFields(FIELDS.getString(options)) .execute(); } catch (IOException ex) { throw translate(ex); } }
@Override public Table create(Table table, Map<Option, ?> options) { try { // unset the type, as it is output only table.setType(null); return bigquery.tables() .insert(this.options.projectId(), table.getTableReference().getDatasetId(), table) .setFields(FIELDS.getString(options)) .execute(); } catch (IOException ex) { throw translate(ex); } }
@Override public Table patch(Table table, Map<Option, ?> options) { try { // unset the type, as it is output only table.setType(null); TableReference reference = table.getTableReference(); return bigquery .tables() .patch(reference.getProjectId(), reference.getDatasetId(), reference.getTableId(), table) .setFields(Option.FIELDS.getString(options)) .execute(); } catch (IOException ex) { throw translate(ex); } }
@Override public void cleanupExport() throws IOException { if (deleteIntermediateTable) { logger.atInfo().log( "Deleting input intermediate table: %s:%s.%s", tableToExport.getProjectId(), tableToExport.getDatasetId(), tableToExport.getTableId()); Bigquery.Tables tables = bigQueryHelper.getRawBigquery().tables(); Bigquery.Tables.Delete delete = tables.delete( tableToExport.getProjectId(), tableToExport.getDatasetId(), tableToExport.getTableId()); delete.execute(); } delegate.cleanupExport(); }