Skip to content
This repository was archived by the owner on Aug 30, 2026. It is now read-only.
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix build errors
  • Loading branch information
stephaniewang526 committed Jan 23, 2020
commit 0c13ae926fc8793621d15fa52da5037c01d1aa4a
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@
public class RelaxTableQueryIT {
private ByteArrayOutputStream bout;
private PrintStream out;
private String tableName;
private Schema originalSchema;

private static final String BIGQUERY_PROJECT_ID = System.getenv("BIGQUERY_PROJECT_ID");
private static final String BIGQUERY_DATASET_NAME = System.getenv("BIGQUERY_DATASET_NAME");
private static final String TABLE_NAME =
"RELAX_TABLE_QUERY_TEST_" + UUID.randomUUID().toString().replace('-', '_');

private static void requireEnvVar(String varName) {
assertNotNull(
Expand All @@ -55,9 +55,10 @@ public static void checkRequirements() {
public void setUp() throws Exception {
bout = new ByteArrayOutputStream();
out = new PrintStream(bout);
tableName =
"RELAX_TABLE_QUERY_TEST" + UUID.randomUUID().toString().substring(0, 5).replace('-', '_');
originalSchema =

CreateTable.createTable(
BIGQUERY_DATASET_NAME,
TABLE_NAME,
Schema.of(
Field.newBuilder("word", LegacySQLTypeName.STRING).setMode(Field.Mode.REQUIRED).build(),
Field.newBuilder("word_count", LegacySQLTypeName.STRING)
Expand All @@ -68,20 +69,19 @@ public void setUp() throws Exception {
.build(),
Field.newBuilder("corpus_date", LegacySQLTypeName.STRING)
.setMode(Field.Mode.REQUIRED)
.build());
CreateTable.createTable(BIGQUERY_DATASET_NAME, tableName, originalSchema);
.build()));
System.setOut(out);
}

@After
public void tearDown() {
DeleteTable.deleteTable(BIGQUERY_DATASET_NAME, tableName);
DeleteTable.deleteTable(BIGQUERY_DATASET_NAME, TABLE_NAME);
System.setOut(null);
}

@Test
public void testRelaxTableQuery() throws Exception {
RelaxTableQuery.relaxTableQuery(BIGQUERY_PROJECT_ID, BIGQUERY_DATASET_NAME, tableName);
RelaxTableQuery.relaxTableQuery(BIGQUERY_PROJECT_ID, BIGQUERY_DATASET_NAME, TABLE_NAME);
assertThat(bout.toString())
.contains("Successfully relaxed all columns in destination table during query job");
}
Expand Down