Skip to content

Commit

Permalink
Merge pull request #522 from mziccard/fix-template-suffix-test
Browse files Browse the repository at this point in the history
Document delay in table creation when insertAll is used with templateSuffix
  • Loading branch information
ajkannan committed Jan 5, 2016
2 parents 70b350c + 46f7958 commit 64114c1
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,16 @@ public Builder ignoreUnknownValues(boolean ignoreUnknownValues) {
/**
* If specified, the destination table is treated as a base template. Rows are inserted into an
* instance table named "{destination}{templateSuffix}". BigQuery will manage the creation of
* the instance table, using the schema of the base template table.
* the instance table, using the schema of the base template table. Table creation might take
* some time. To obtain table's information after {@link BigQuery#insertAll(InsertAllRequest)}
* is called use:
* <pre> {@code
* String suffixTableId = ...;
* BaseTableInfo suffixTable = bigquery.getTable(DATASET, suffixTableId);
* while (suffixTable == null) {
* Thread.sleep(1000L);
* suffixTable = bigquery.getTable(DATASET, suffixTableId);
* }}</pre>
*
* @see <a
* href="https://cloud.google.com/bigquery/streaming-data-into-bigquery#template-tables">
Expand Down Expand Up @@ -293,7 +302,16 @@ public Boolean skipInvalidRows() {
/**
* If specified, the destination table is treated as a base template. Rows are inserted into an
* instance table named "{destination}{templateSuffix}". BigQuery will manage the creation of the
* instance table, using the schema of the base template table.
* instance table, using the schema of the base template table. Table creation might take some
* time. To obtain table's information after {@link BigQuery#insertAll(InsertAllRequest)} is
* called use:
* <pre> {@code
* String suffixTableId = ...;
* BaseTableInfo suffixTable = bigquery.getTable(DATASET, suffixTableId);
* while (suffixTable == null) {
* Thread.sleep(1000L);
* suffixTable = bigquery.getTable(DATASET, suffixTableId);
* }}</pre>
*
* @see <a
* href="https://cloud.google.com/bigquery/streaming-data-into-bigquery#template-tables">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -506,11 +506,11 @@ public void testInsertAllWithSuffix() throws InterruptedException {
assertEquals(0, response.insertErrors().size());
String newTableName = tableName + "_suffix";
BaseTableInfo suffixTable = bigquery.getTable(DATASET, newTableName, TableOption.fields());
// wait until the new table is created. If the table is never created the test will time-out
while (suffixTable == null) {
Thread.sleep(1000L);
suffixTable = bigquery.getTable(DATASET, newTableName, TableOption.fields());
}
assertNotNull(suffixTable);
assertTrue(bigquery.delete(TableId.of(DATASET, tableName)));
assertTrue(bigquery.delete(TableId.of(DATASET, newTableName)));
}
Expand Down

0 comments on commit 64114c1

Please sign in to comment.