@Override ExtractJobConfiguration setProjectId(String projectId) { if (Strings.isNullOrEmpty(getSourceTable().getProject())) { return toBuilder().setSourceTable(getSourceTable().setProjectId(projectId)).build(); } return this; }
@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; }
/** * 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(); }
@SuppressWarnings("unchecked") static ExtractJobConfiguration fromPb( com.google.api.services.bigquery.model.JobConfiguration confPb) { return new Builder(confPb).build(); } }
@SuppressWarnings("unchecked") static ExtractJobConfiguration fromPb( com.google.api.services.bigquery.model.JobConfiguration confPb) { return new Builder(confPb).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 builder(sourceTable, destinationUri).format(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(); }
/** * 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 builder(sourceTable, destinationUris).format(format).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 * URIs. */ public static ExtractJobConfiguration of( TableId sourceTable, List<String> destinationUris, String format) { return newBuilder(sourceTable, destinationUris).setFormat(format).build(); }
@Test public void testSetProjectIdDoNotOverride() { ExtractJobConfiguration configuration = EXTRACT_CONFIGURATION .toBuilder() .setSourceTable(TABLE_ID.setProjectId(TEST_PROJECT_ID)) .build() .setProjectId("do-not-update"); assertEquals(TEST_PROJECT_ID, configuration.getSourceTable().getProject()); }
/** * 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(); }
@Test public void testToBuilderIncomplete() { ExtractJobConfiguration job = ExtractJobConfiguration.of(TABLE_ID, DESTINATION_URIS); compareExtractJobConfiguration(job, job.toBuilder().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(); }
@Test public void testToBuilder() { compareExtractJobConfiguration( EXTRACT_CONFIGURATION, EXTRACT_CONFIGURATION.toBuilder().build()); ExtractJobConfiguration job = EXTRACT_CONFIGURATION.toBuilder().setSourceTable(TableId.of("dataset", "newTable")).build(); assertEquals("newTable", job.getSourceTable().getTable()); job = job.toBuilder().setSourceTable(TABLE_ID).build(); compareExtractJobConfiguration(EXTRACT_CONFIGURATION, job); }
@SuppressWarnings("unchecked") static ExtractJobConfiguration fromPb( com.google.api.services.bigquery.model.JobConfiguration confPb) { return new Builder(confPb).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(); }