@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)); }
@Override ExtractJobConfiguration setProjectId(String projectId) { if (Strings.isNullOrEmpty(getSourceTable().getProject())) { return toBuilder().setSourceTable(getSourceTable().setProjectId(projectId)).build(); } return this; }
@Override public Builder toBuilder() { return new Builder(this); }
@Override public Builder toBuilder() { return new Builder(this); }
@Override ExtractJobConfiguration setProjectId(String projectId) { return toBuilder().sourceTable(sourceTable().setProjectId(projectId)).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 and destination URIs. */ public static ExtractJobConfiguration of(TableId sourceTable, List<String> destinationUris) { return builder(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 builder(sourceTable, destinationUri).build(); }
/** * Creates a builder for a BigQuery Extract Job configuration given source table and destination * URIs. */ public static Builder newBuilder(TableId sourceTable, List<String> destinationUris) { return new Builder().setSourceTable(sourceTable).setDestinationUris(destinationUris); }
/** * Creates a builder for a BigQuery Extract Job configuration given source table and destination * URIs. */ public static Builder builder(TableId sourceTable, List<String> destinationUris) { return new Builder().sourceTable(sourceTable).destinationUris(destinationUris); }
/** * 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(); }
@Override ExtractJobConfiguration setProjectId(String projectId) { if (Strings.isNullOrEmpty(getSourceTable().getProject())) { return toBuilder().setSourceTable(getSourceTable().setProjectId(projectId)).build(); } return this; }
@Override public Builder toBuilder() { return new Builder(this); }
@Test public void testToBuilderIncomplete() { ExtractJobConfiguration job = ExtractJobConfiguration.of(TABLE_ID, DESTINATION_URIS); compareExtractJobConfiguration(job, job.toBuilder().build()); }