Search in sources :

Example 21 with Table

use of com.google.cloud.bigquery.Table in project google-cloud-java by GoogleCloudPlatform.

the class ITDatasetSnippets method testGetTable.

@Test
public void testGetTable() {
    String expectedTableName = "test_table";
    dataset.create(expectedTableName, StandardTableDefinition.newBuilder().build());
    Table actualTable = datasetSnippets.getTable(expectedTableName);
    assertNotNull(actualTable);
    assertEquals(expectedTableName, actualTable.getTableId().getTable());
    bigquery.delete(DATASET, expectedTableName);
}
Also used : Table(com.google.cloud.bigquery.Table) Test(org.junit.Test)

Example 22 with Table

use of com.google.cloud.bigquery.Table in project google-cloud-java by GoogleCloudPlatform.

the class ITDatasetSnippets method testCreateTable.

@Test
public void testCreateTable() {
    String expectedTableName = "test_table";
    String expectedFieldName = "test_field";
    Table actualTable = datasetSnippets.createTable(expectedTableName, expectedFieldName);
    assertNotNull(actualTable);
    assertEquals(expectedTableName, actualTable.getTableId().getTable());
    assertEquals(1, actualTable.getDefinition().getSchema().getFields().size());
    Field actualField = actualTable.getDefinition().getSchema().getFields().get(0);
    assertEquals(expectedFieldName, actualField.getName());
    bigquery.delete(DATASET, expectedTableName);
}
Also used : Field(com.google.cloud.bigquery.Field) Table(com.google.cloud.bigquery.Table) Test(org.junit.Test)

Example 23 with Table

use of com.google.cloud.bigquery.Table in project google-cloud-java by GoogleCloudPlatform.

the class ITDatasetSnippets method testListTablesNotEmpty.

@Test
public void testListTablesNotEmpty() {
    String expectedTableName = "test_table";
    dataset.create(expectedTableName, StandardTableDefinition.newBuilder().build());
    Page<Table> tables = datasetSnippets.list();
    Iterator<Table> iterator = tables.iterateAll().iterator();
    assertTrue(iterator.hasNext());
    Table actualTable = iterator.next();
    assertEquals(expectedTableName, actualTable.getTableId().getTable());
    assertFalse(iterator.hasNext());
    bigquery.delete(DATASET, expectedTableName);
}
Also used : Table(com.google.cloud.bigquery.Table) Test(org.junit.Test)

Example 24 with Table

use of com.google.cloud.bigquery.Table in project google-cloud-java by GoogleCloudPlatform.

the class ITTableSnippets method testReloadTableWithFields.

@Test
public void testReloadTableWithFields() {
    Table latestTable = tableSnippets.reloadTableWithFields(TableField.LAST_MODIFIED_TIME, TableField.NUM_ROWS);
    assertNotNull(latestTable);
    assertNotNull(latestTable.getLastModifiedTime());
}
Also used : Table(com.google.cloud.bigquery.Table) Test(org.junit.Test)

Aggregations

Table (com.google.cloud.bigquery.Table)24 Test (org.junit.Test)18 StandardTableDefinition (com.google.cloud.bigquery.StandardTableDefinition)11 TableId (com.google.cloud.bigquery.TableId)11 TableInfo (com.google.cloud.bigquery.TableInfo)11 Job (com.google.cloud.bigquery.Job)4 Schema (com.google.cloud.bigquery.Schema)4 CopyJobConfiguration (com.google.cloud.bigquery.CopyJobConfiguration)3 Field (com.google.cloud.bigquery.Field)3 FieldValue (com.google.cloud.bigquery.FieldValue)2 QueryRequest (com.google.cloud.bigquery.QueryRequest)2 QueryResponse (com.google.cloud.bigquery.QueryResponse)2 BigQuery (com.google.cloud.bigquery.BigQuery)1 DatasetId (com.google.cloud.bigquery.DatasetId)1 ExternalTableDefinition (com.google.cloud.bigquery.ExternalTableDefinition)1 InsertAllRequest (com.google.cloud.bigquery.InsertAllRequest)1 InsertAllResponse (com.google.cloud.bigquery.InsertAllResponse)1 TableDefinition (com.google.cloud.bigquery.TableDefinition)1 TimePartitioning (com.google.cloud.bigquery.TimePartitioning)1 ViewDefinition (com.google.cloud.bigquery.ViewDefinition)1