public void deleteDataset(String projectId, String datasetId) { try { TableList tables = bqClient.tables().list(projectId, datasetId).execute(); for (Tables table : tables.getTables()) { this.deleteTable(projectId, datasetId, table.getTableReference().getTableId()); } } catch (Exception e) { LOG.debug("Exceptions caught when listing all tables: " + e.getMessage()); } try { bqClient.datasets().delete(projectId, datasetId).execute(); LOG.info("Successfully deleted dataset: " + datasetId); } catch (Exception e) { LOG.debug("Exceptions caught when deleting dataset: " + e.getMessage()); } }
private void deleteDataset(String datasetId) throws IOException, InterruptedException { executeWithBackOff( client.datasets().delete(projectId, datasetId), String.format( "Error when trying to delete the temporary dataset %s in project %s. " + "Manual deletion may be required.", datasetId, projectId)); }
/** * {@inheritDoc} * * <p>Tries executing the RPC for at most {@code MAX_RPC_RETRIES} times until it succeeds. * * @throws IOException if it exceeds {@code MAX_RPC_RETRIES} attempts. */ @Override public void deleteDataset(String projectId, String datasetId) throws IOException, InterruptedException { executeWithRetries( client.datasets().delete(projectId, datasetId), String.format( "Unable to delete table: %s, aborting after %d retries.", datasetId, MAX_RPC_RETRIES), Sleeper.DEFAULT, createDefaultBackoff(), ALWAYS_RETRY); }
/** * Deletes the temporary dataset, including all of the work tables. * * @param context the job's context. * @throws IOException */ @Override public void cleanupJob(JobContext context) throws IOException { logger.atFine().log("cleanupJob(%s)", lazy(() -> HadoopToStringUtil.toString(context))); Bigquery.Datasets datasets = bigQueryHelper.getRawBigquery().datasets(); try { logger.atFine().log( "cleanupJob: Deleting dataset '%s' from project '%s'", tempTableRef.getDatasetId(), tempTableRef.getProjectId()); datasets.delete(tempTableRef.getProjectId(), tempTableRef.getDatasetId()) .setDeleteContents(true) .execute(); } catch (IOException e) { // Error is swallowed as job has completed successfully and the only failure is deleting // temporary data. // This matches the FileOutputCommitter pattern. logger.atWarning().withCause(e).log( "Could not delete dataset. Temporary data not cleaned up."); } }
void deleteDataset(String projectId, String datasetId) throws IOException { if (datasetExists(projectId, datasetId)) { deleteTables(projectId, datasetId); try { client.datasets().delete(projectId, datasetId).execute(); } catch (GoogleJsonResponseException e) { if (e.getStatusCode() == HttpStatusCodes.STATUS_CODE_NOT_FOUND) { // Already deleted return; } throw e; } } }
@Override public boolean deleteDataset(String datasetId, Map<Option, ?> options) { try { bigquery.datasets().delete(this.options.projectId(), datasetId) .setDeleteContents(DELETE_CONTENTS.getBoolean(options)) .execute(); return true; } catch (IOException ex) { BigQueryException serviceException = translate(ex); if (serviceException.code() == HTTP_NOT_FOUND) { return false; } throw serviceException; } }
@Override public boolean deleteDataset(String datasetId, Map<Option, ?> options) { try { bigquery.datasets().delete(this.options.projectId(), datasetId) .setDeleteContents(DELETE_CONTENTS.getBoolean(options)) .execute(); return true; } catch (IOException ex) { BigQueryException serviceException = translate(ex); if (serviceException.code() == HTTP_NOT_FOUND) { return false; } throw serviceException; } }
@Override public boolean deleteDataset(String projectId, String datasetId, Map<Option, ?> options) { try { bigquery .datasets() .delete(projectId, datasetId) .setDeleteContents(Option.DELETE_CONTENTS.getBoolean(options)) .execute(); return true; } catch (IOException ex) { BigQueryException serviceException = translate(ex); if (serviceException.getCode() == HTTP_NOT_FOUND) { return false; } throw serviceException; } }
@Override public boolean deleteDataset(String projectId, String datasetId, Map<Option, ?> options) { try { bigquery .datasets() .delete(projectId, datasetId) .setDeleteContents(Option.DELETE_CONTENTS.getBoolean(options)) .execute(); return true; } catch (IOException ex) { BigQueryException serviceException = translate(ex); if (serviceException.getCode() == HTTP_NOT_FOUND) { return false; } throw serviceException; } }