Skip to content

Commit 46f7958

Browse files
committed
Document delay in table creation when insertAll is used with templateSuffix
1 parent 70b350c commit 46f7958

2 files changed

Lines changed: 21 additions & 3 deletions

File tree

gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/InsertAllRequest.java

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,16 @@ public Builder ignoreUnknownValues(boolean ignoreUnknownValues) {
236236
/**
237237
* If specified, the destination table is treated as a base template. Rows are inserted into an
238238
* instance table named "{destination}{templateSuffix}". BigQuery will manage the creation of
239-
* the instance table, using the schema of the base template table.
239+
* the instance table, using the schema of the base template table. Table creation might take
240+
* some time. To obtain table's information after {@link BigQuery#insertAll(InsertAllRequest)}
241+
* is called use:
242+
* <pre> {@code
243+
* String suffixTableId = ...;
244+
* BaseTableInfo suffixTable = bigquery.getTable(DATASET, suffixTableId);
245+
* while (suffixTable == null) {
246+
* Thread.sleep(1000L);
247+
* suffixTable = bigquery.getTable(DATASET, suffixTableId);
248+
* }}</pre>
240249
*
241250
* @see <a
242251
* href="https://cloud.google.com/bigquery/streaming-data-into-bigquery#template-tables">
@@ -293,7 +302,16 @@ public Boolean skipInvalidRows() {
293302
/**
294303
* If specified, the destination table is treated as a base template. Rows are inserted into an
295304
* instance table named "{destination}{templateSuffix}". BigQuery will manage the creation of the
296-
* instance table, using the schema of the base template table.
305+
* instance table, using the schema of the base template table. Table creation might take some
306+
* time. To obtain table's information after {@link BigQuery#insertAll(InsertAllRequest)} is
307+
* called use:
308+
* <pre> {@code
309+
* String suffixTableId = ...;
310+
* BaseTableInfo suffixTable = bigquery.getTable(DATASET, suffixTableId);
311+
* while (suffixTable == null) {
312+
* Thread.sleep(1000L);
313+
* suffixTable = bigquery.getTable(DATASET, suffixTableId);
314+
* }}</pre>
297315
*
298316
* @see <a
299317
* href="https://cloud.google.com/bigquery/streaming-data-into-bigquery#template-tables">

gcloud-java-bigquery/src/test/java/com/google/gcloud/bigquery/ITBigQueryTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -506,11 +506,11 @@ public void testInsertAllWithSuffix() throws InterruptedException {
506506
assertEquals(0, response.insertErrors().size());
507507
String newTableName = tableName + "_suffix";
508508
BaseTableInfo suffixTable = bigquery.getTable(DATASET, newTableName, TableOption.fields());
509+
// wait until the new table is created. If the table is never created the test will time-out
509510
while (suffixTable == null) {
510511
Thread.sleep(1000L);
511512
suffixTable = bigquery.getTable(DATASET, newTableName, TableOption.fields());
512513
}
513-
assertNotNull(suffixTable);
514514
assertTrue(bigquery.delete(TableId.of(DATASET, tableName)));
515515
assertTrue(bigquery.delete(TableId.of(DATASET, newTableName)));
516516
}

0 commit comments

Comments
 (0)