/** * Creates a builder for a BigQuery Extract Job configuration given source table and destination * URI. */ public static Builder newBuilder(TableId sourceTable, String destinationUri) { return newBuilder(sourceTable, ImmutableList.of(checkNotNull(destinationUri))); }
/** * Returns a BigQuery Extract Job configuration for the given source table and destination URI. */ public static ExtractJobConfiguration of(TableId sourceTable, String destinationUri) { return newBuilder(sourceTable, destinationUri).build(); }
/** * Returns a BigQuery Extract Job configuration for the given source table and destination URIs. */ public static ExtractJobConfiguration of(TableId sourceTable, List<String> destinationUris) { return newBuilder(sourceTable, destinationUris).build(); }
/** * Returns a BigQuery Extract Job configuration for the given source table, format and destination * URI. */ public static ExtractJobConfiguration of( TableId sourceTable, String destinationUri, String format) { return newBuilder(sourceTable, destinationUri).setFormat(format).build(); }
/** * Returns a BigQuery Extract Job configuration for the given source table, format and destination * URIs. */ public static ExtractJobConfiguration of( TableId sourceTable, List<String> destinationUris, String format) { return newBuilder(sourceTable, destinationUris).setFormat(format).build(); }
@Test public void testExtractJob() throws InterruptedException, TimeoutException { String tableName = "test_export_job_table"; TableId destinationTable = TableId.of(DATASET, tableName); LoadJobConfiguration configuration = LoadJobConfiguration.newBuilder(destinationTable, "gs://" + BUCKET + "/" + LOAD_FILE) .setSchema(SIMPLE_SCHEMA) .build(); Job remoteLoadJob = bigquery.create(JobInfo.of(configuration)); remoteLoadJob = remoteLoadJob.waitFor(); assertNull(remoteLoadJob.getStatus().getError()); ExtractJobConfiguration extractConfiguration = ExtractJobConfiguration.newBuilder(destinationTable, "gs://" + BUCKET + "/" + EXTRACT_FILE) .setPrintHeader(false) .build(); Job remoteExtractJob = bigquery.create(JobInfo.of(extractConfiguration)); remoteExtractJob = remoteExtractJob.waitFor(); assertNull(remoteExtractJob.getStatus().getError()); String extractedCsv = new String(storage.readAllBytes(BUCKET, EXTRACT_FILE), StandardCharsets.UTF_8); assertEquals( Sets.newHashSet(CSV_CONTENT.split("\n")), Sets.newHashSet(extractedCsv.split("\n"))); assertTrue(bigquery.delete(DATASET, tableName)); }
/** * Creates a builder for a BigQuery Extract Job configuration given source table and destination * URI. */ public static Builder newBuilder(TableId sourceTable, String destinationUri) { return newBuilder(sourceTable, ImmutableList.of(checkNotNull(destinationUri))); }
/** * Returns a BigQuery Extract Job configuration for the given source table and destination URIs. */ public static ExtractJobConfiguration of(TableId sourceTable, List<String> destinationUris) { return newBuilder(sourceTable, destinationUris).build(); }
/** * Returns a BigQuery Extract Job configuration for the given source table and destination URI. */ public static ExtractJobConfiguration of(TableId sourceTable, String destinationUri) { return newBuilder(sourceTable, destinationUri).build(); }
/** * Returns a BigQuery Extract Job configuration for the given source table, format and destination * URIs. */ public static ExtractJobConfiguration of( TableId sourceTable, List<String> destinationUris, String format) { return newBuilder(sourceTable, destinationUris).setFormat(format).build(); }
/** * Returns a BigQuery Extract Job configuration for the given source table, format and destination * URI. */ public static ExtractJobConfiguration of( TableId sourceTable, String destinationUri, String format) { return newBuilder(sourceTable, destinationUri).setFormat(format).build(); }