Skip to content

Commit

Permalink
Merge pull request #600 from mziccard/bigquery-hierachies
Browse files Browse the repository at this point in the history
Remove TableInfo hierarchy, add TableType hierarchy
  • Loading branch information
aozarov committed Feb 2, 2016
2 parents d3abf25 + 28a457e commit 2bb03eb
Show file tree
Hide file tree
Showing 31 changed files with 1,389 additions and 1,333 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,23 +125,25 @@ Here is a code snippet showing a simple usage example from within Compute/App En
must [supply credentials](#authentication) and a project ID if running this snippet elsewhere.
```java
import com.google.gcloud.bigquery.BaseTableInfo;
import com.google.gcloud.bigquery.BigQuery;
import com.google.gcloud.bigquery.BigQueryOptions;
import com.google.gcloud.bigquery.Field;
import com.google.gcloud.bigquery.JobStatus;
import com.google.gcloud.bigquery.JobInfo;
import com.google.gcloud.bigquery.LoadJobConfiguration;
import com.google.gcloud.bigquery.Schema;
import com.google.gcloud.bigquery.StandardTableDefinition;
import com.google.gcloud.bigquery.TableId;
import com.google.gcloud.bigquery.TableInfo;
BigQuery bigquery = BigQueryOptions.defaultInstance().service();
TableId tableId = TableId.of("dataset", "table");
BaseTableInfo info = bigquery.getTable(tableId);
TableInfo info = bigquery.getTable(tableId);
if (info == null) {
System.out.println("Creating table " + tableId);
Field integerField = Field.of("fieldName", Field.Type.integer());
bigquery.create(TableInfo.of(tableId, Schema.of(integerField)));
Schema schema = Schema.of(integerField);
bigquery.create(TableInfo.of(tableId, StandardTableDefinition.of(schema)));
} else {
System.out.println("Loading data into table " + tableId);
LoadJobConfiguration configuration = LoadJobConfiguration.of(tableId, "gs://bucket/path");
Expand Down
12 changes: 7 additions & 5 deletions gcloud-java-bigquery/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,9 @@ are created from a BigQuery SQL query. In this code snippet we show how to creat
with only one string field. Add the following imports at the top of your file:

```java
import com.google.gcloud.bigquery.BaseTableInfo;
import com.google.gcloud.bigquery.Field;
import com.google.gcloud.bigquery.Schema;
import com.google.gcloud.bigquery.StandardTableDefinition;
import com.google.gcloud.bigquery.TableId;
import com.google.gcloud.bigquery.TableInfo;
```
Expand All @@ -126,7 +126,8 @@ Field stringField = Field.of("StringField", Field.Type.string());
// Table schema definition
Schema schema = Schema.of(stringField);
// Create a table
TableInfo createdTableInfo = bigquery.create(TableInfo.of(tableId, schema));
StandardTableDefinition tableDefinition = StandardTableDefinition.of(schema);
TableInfo createdTableInfo = bigquery.create(TableInfo.of(tableId, tableDefinition));
```

#### Loading data into a table
Expand Down Expand Up @@ -204,7 +205,6 @@ the code from the main method to your application's servlet class and change the
display on your webpage.

```java
import com.google.gcloud.bigquery.BaseTableInfo;
import com.google.gcloud.bigquery.BigQuery;
import com.google.gcloud.bigquery.BigQueryOptions;
import com.google.gcloud.bigquery.DatasetInfo;
Expand All @@ -215,6 +215,7 @@ import com.google.gcloud.bigquery.InsertAllResponse;
import com.google.gcloud.bigquery.QueryRequest;
import com.google.gcloud.bigquery.QueryResponse;
import com.google.gcloud.bigquery.Schema;
import com.google.gcloud.bigquery.StandardTableDefinition;
import com.google.gcloud.bigquery.TableId;
import com.google.gcloud.bigquery.TableInfo;

Expand All @@ -240,7 +241,8 @@ public class GcloudBigQueryExample {
// Table schema definition
Schema schema = Schema.of(stringField);
// Create a table
TableInfo createdTableInfo = bigquery.create(TableInfo.of(tableId, schema));
StandardTableDefinition tableDefinition = StandardTableDefinition.of(schema);
TableInfo createdTableInfo = bigquery.create(TableInfo.of(tableId, tableDefinition));

// Define rows to insert
Map<String, Object> firstRow = new HashMap<>();
Expand All @@ -267,7 +269,7 @@ public class GcloudBigQueryExample {
.build();
// Request query to be executed and wait for results
QueryResponse queryResponse = bigquery.query(queryRequest);
while (!queryResponse.jobComplete()) {
while (!queryResponse.jobCompleted()) {
Thread.sleep(1000L);
queryResponse = bigquery.getQueryResults(queryResponse.jobId());
}
Expand Down
Loading

0 comments on commit 2bb03eb

Please sign in to comment.