Skip to content

Commit 98181a5

Browse files
committed
update Table javadoc
1 parent e629b02 commit 98181a5

File tree

2 files changed

+52
-9
lines changed
  • google-cloud-bigquery/src/main/java/com/google/cloud/bigquery
  • google-cloud-examples/src/main/java/com/google/cloud/examples/bigquery/snippets

2 files changed

+52
-9
lines changed

google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/Table.java

Lines changed: 50 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ public Table build() {
142142
* <p>Example of ensuring that a table exists.
143143
* <pre> {@code
144144
* if (!table.exists()) {
145-
* throw new RuntimeException("Table does not exist.");
145+
* throw new RuntimeException("Table does not exist.");
146146
* }
147147
* }</pre>
148148
*
@@ -344,7 +344,7 @@ public Job copy(String destinationDataset, String destinationTable, JobOption...
344344
* } else {
345345
* // Handle error case.
346346
* }
347-
* } catch(InterruptedException | TimeoutException e) {
347+
* } catch (InterruptedException | TimeoutException e) {
348348
* // Handle interrupted wait.
349349
* }
350350
* }</pre>
@@ -366,7 +366,7 @@ public Job copy(TableId destinationTable, JobOption... options)
366366
* <p>Example extracting data to single Google Cloud Storage file.
367367
* <pre> {@code
368368
* String format = "CSV";
369-
* String gcsUrl = "gs://bucket_name/filename.csv";
369+
* String gcsUrl = "gs://myapp.appspot.com/filename.csv";
370370
* Job job = table.extract(format, gcsUrl);
371371
*
372372
* // Wait for the job to complete.
@@ -378,7 +378,7 @@ public Job copy(TableId destinationTable, JobOption... options)
378378
* } else {
379379
* // Handle error case.
380380
* }
381-
* } catch(InterruptedException | TimeoutException e) {
381+
* } catch (InterruptedException | TimeoutException e) {
382382
* // Handle interrupted wait.
383383
* }
384384
* }</pre>
@@ -401,8 +401,8 @@ public Job extract(String format, String destinationUri, JobOption... options)
401401
* <p>Example extracting data to a list of Google Cloud Storage files.
402402
* <pre> {@code
403403
* String format = "CSV";
404-
* String gcsUrl1 = "gs://bucket_name/PartitionA_*.csv";
405-
* String gcsUrl2 = "gs://bucket_name/PartitionB_*.csv";
404+
* String gcsUrl1 = "gs://myapp.appspot.com/PartitionA_*.csv";
405+
* String gcsUrl2 = "gs://myapp.appspot.com/PartitionB_*.csv";
406406
* List<String> destinationUris = new ArrayList<>();
407407
* destinationUris.add(gcsUrl1);
408408
* destinationUris.add(gcsUrl2);
@@ -418,7 +418,7 @@ public Job extract(String format, String destinationUri, JobOption... options)
418418
* } else {
419419
* // Handle error case.
420420
* }
421-
* } catch(InterruptedException | TimeoutException e) {
421+
* } catch (InterruptedException | TimeoutException e) {
422422
* // Handle interrupted wait.
423423
* }
424424
* }</pre>
@@ -440,6 +440,25 @@ public Job extract(String format, List<String> destinationUris, JobOption... opt
440440
* Starts a BigQuery Job to load data into the current table from the provided source URI. Returns
441441
* the started {@link Job} object.
442442
*
443+
* <p>Example loading data from a single Google Cloud Storage file.
444+
* <pre> {@code
445+
* String sourceUri = "gs://myapp.appspot.com/filename.csv";
446+
* Job job = table.load(FormatOptions.csv(), sourceUri);
447+
*
448+
* // Wait for the job to complete.
449+
* try {
450+
* Job completedJob = job.waitFor(WaitForOption.checkEvery(1, TimeUnit.SECONDS),
451+
* WaitForOption.timeout(60, TimeUnit.SECONDS));
452+
* if (completedJob != null && completedJob.status().error() == null) {
453+
* // Job completed successfully.
454+
* } else {
455+
* // Handle error case.
456+
* }
457+
* } catch (InterruptedException | TimeoutException e) {
458+
* // Handle interrupted wait.
459+
* }
460+
* }</pre>
461+
*
443462
* @param format the format of the data to load
444463
* @param sourceUri the fully-qualified Google Cloud Storage URI (e.g. gs://bucket/path) from
445464
* which to load the data
@@ -455,6 +474,30 @@ public Job load(FormatOptions format, String sourceUri, JobOption... options)
455474
* Starts a BigQuery Job to load data into the current table from the provided source URIs.
456475
* Returns the started {@link Job} object.
457476
*
477+
* <p>Example loading data from a list of Google Cloud Storage files.
478+
* <pre> {@code
479+
* String gcsUrl1 = "gs://myapp.appspot.com/PartitionA_000000000000.csv";
480+
* String gcsUrl2 = "gs://myapp.appspot.com/PartitionB_000000000000.csv";
481+
* List<String> sourceUris = new ArrayList<>();
482+
* sourceUris.add(gcsUrl1);
483+
* sourceUris.add(gcsUrl2);
484+
*
485+
* Job job = table.load(FormatOptions.csv(), sourceUris);
486+
*
487+
* // Wait for the job to complete.
488+
* try {
489+
* Job completedJob = job.waitFor(WaitForOption.checkEvery(1, TimeUnit.SECONDS),
490+
* WaitForOption.timeout(60, TimeUnit.SECONDS));
491+
* if (completedJob != null && completedJob.status().error() == null) {
492+
* // Job completed successfully.
493+
* } else {
494+
* // Handle error case.
495+
* }
496+
* } catch (InterruptedException | TimeoutException e) {
497+
* // Handle interrupted wait.
498+
* }
499+
* }</pre>
500+
*
458501
* @param format the format of the exported data
459502
* @param sourceUris the fully-qualified Google Cloud Storage URIs (e.g. gs://bucket/path) from
460503
* which to load the data

google-cloud-examples/src/main/java/com/google/cloud/examples/bigquery/snippets/TableSnippets.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ public Job extractSingle(String format, String gcsUrl) {
274274
/**
275275
* Example loading data from a list of Google Cloud Storage files.
276276
*/
277-
// [TARGET load(String, List, JobOption...)]
277+
// [TARGET load(FormatOptions, List, JobOption...)]
278278
// [VARIABLE "gs://myapp.appspot.com/PartitionA_000000000000.csv"]
279279
// [VARIABLE "gs://myapp.appspot.com/PartitionB_000000000000.csv"]
280280
public Job loadList(String gcsUrl1, String gcsUrl2) {
@@ -304,7 +304,7 @@ public Job loadList(String gcsUrl1, String gcsUrl2) {
304304
/**
305305
* Example loading data from a single Google Cloud Storage file.
306306
*/
307-
// [TARGET load(String, String, JobOption...)]
307+
// [TARGET load(FormatOptions, String, JobOption...)]
308308
// [VARIABLE "gs://myapp.appspot.com/filename.csv"]
309309
public Job loadSingle(String sourceUri) {
310310
// [START loadSingle]

0 commit comments

Comments
 (0)