Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove TableInfo hierarchy, add TableType hierarchy #600

Merged
merged 5 commits into from
Feb 2, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
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
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);

This comment was marked as spam.

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