Skip to content

Commit 3474f3b

Browse files
committed
Rename TableType to TableDefinition and other minor fixes
1 parent c010bc8 commit 3474f3b

25 files changed

+307
-292
lines changed

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@ Here is a code snippet showing a simple usage example from within Compute/App En
125125
must [supply credentials](#authentication) and a project ID if running this snippet elsewhere.
126126
127127
```java
128-
import com.google.gcloud.bigquery.BaseTableInfo;
129128
import com.google.gcloud.bigquery.BigQuery;
130129
import com.google.gcloud.bigquery.BigQueryOptions;
131130
import com.google.gcloud.bigquery.Field;
@@ -137,12 +136,12 @@ import com.google.gcloud.bigquery.TableInfo;
137136
138137
BigQuery bigquery = BigQueryOptions.defaultInstance().service();
139138
TableId tableId = TableId.of("dataset", "table");
140-
BaseTableInfo info = bigquery.getTable(tableId);
139+
TableInfo info = bigquery.getTable(tableId);
141140
if (info == null) {
142141
System.out.println("Creating table " + tableId);
143142
Field integerField = Field.of("fieldName", Field.Type.integer());
144143
Schema schema = Schema.of(integerField);
145-
bigquery.create(TableInfo.of(tableId, DefaultTableType.of(schema)));
144+
bigquery.create(TableInfo.of(tableId, DefaultTableDefinition.of(schema)));
146145
} else {
147146
System.out.println("Loading data into table " + tableId);
148147
LoadJobConfiguration configuration = LoadJobConfiguration.of(tableId, "gs://bucket/path");

gcloud-java-bigquery/README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ are created from a BigQuery SQL query. In this code snippet we show how to creat
111111
with only one string field. Add the following imports at the top of your file:
112112

113113
```java
114-
import com.google.gcloud.bigquery.DefaultTableType;
114+
import com.google.gcloud.bigquery.DefaultTableDefinition;
115115
import com.google.gcloud.bigquery.Field;
116116
import com.google.gcloud.bigquery.Schema;
117117
import com.google.gcloud.bigquery.TableId;
@@ -126,8 +126,8 @@ Field stringField = Field.of("StringField", Field.Type.string());
126126
// Table schema definition
127127
Schema schema = Schema.of(stringField);
128128
// Create a table
129-
DefaultTableType tableType = DefaultTableType.of(schema);
130-
TableInfo createdTableInfo = bigquery.create(TableInfo.of(tableId, tableType));
129+
DefaultTableDefinition tableDefinition = DefaultTableDefinition.of(schema);
130+
TableInfo createdTableInfo = bigquery.create(TableInfo.of(tableId, tableDefinition));
131131
```
132132

133133
#### Loading data into a table
@@ -208,7 +208,7 @@ display on your webpage.
208208
import com.google.gcloud.bigquery.BigQuery;
209209
import com.google.gcloud.bigquery.BigQueryOptions;
210210
import com.google.gcloud.bigquery.DatasetInfo;
211-
import com.google.gcloud.bigquery.DefaultTableType;
211+
import com.google.gcloud.bigquery.DefaultTableDefinition;
212212
import com.google.gcloud.bigquery.Field;
213213
import com.google.gcloud.bigquery.FieldValue;
214214
import com.google.gcloud.bigquery.InsertAllRequest;
@@ -241,8 +241,8 @@ public class GcloudBigQueryExample {
241241
// Table schema definition
242242
Schema schema = Schema.of(stringField);
243243
// Create a table
244-
DefaultTableType tableType = DefaultTableType.of(schema);
245-
TableInfo createdTableInfo = bigquery.create(TableInfo.of(tableId, tableType));
244+
DefaultTableDefinition tableDefinition = DefaultTableDefinition.of(schema);
245+
TableInfo createdTableInfo = bigquery.create(TableInfo.of(tableId, tableDefinition));
246246

247247
// Define rows to insert
248248
Map<String, Object> firstRow = new HashMap<>();

gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/BaseTableType.java renamed to gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/BaseTableDefinition.java

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
/**
2828
* Base class for a Google BigQuery table type.
2929
*/
30-
public abstract class BaseTableType implements Serializable{
30+
public abstract class BaseTableDefinition implements Serializable {
3131

3232
private static final long serialVersionUID = -374760330662959529L;
3333

@@ -36,22 +36,22 @@ public abstract class BaseTableType implements Serializable{
3636
*/
3737
public enum Type {
3838
/**
39-
* A normal BigQuery table. Instances of {@code BaseTableType} for this type are implemented by
40-
* {@link DefaultTableType}.
39+
* A normal BigQuery table. Instances of {@code BaseTableDefinition} for this type are
40+
* implemented by {@link DefaultTableDefinition}.
4141
*/
4242
TABLE,
4343

4444
/**
45-
* A virtual table defined by a SQL query. Instances of {@code BaseTableType} for this type are
46-
* implemented by {@link ViewType}.
45+
* A virtual table defined by a SQL query. Instances of {@code BaseTableDefinition} for this
46+
* type are implemented by {@link ViewDefinition}.
4747
*
4848
* @see <a href="https://cloud.google.com/bigquery/querying-data#views">Views</a>
4949
*/
5050
VIEW,
5151

5252
/**
53-
* A BigQuery table backed by external data. Instances of {@code BaseTableType} for this type
54-
* are implemented by {@link ExternalTableType}.
53+
* A BigQuery table backed by external data. Instances of {@code BaseTableDefinition} for this
54+
* type are implemented by {@link ExternalTableDefinition}.
5555
*
5656
* @see <a href="https://cloud.google.com/bigquery/federated-data-sources">Federated Data
5757
* Sources</a>
@@ -68,7 +68,7 @@ public enum Type {
6868
* @param <T> the table type class
6969
* @param <B> the table type builder
7070
*/
71-
public abstract static class Builder<T extends BaseTableType, B extends Builder<T, B>> {
71+
public abstract static class Builder<T extends BaseTableDefinition, B extends Builder<T, B>> {
7272

7373
private Type type;
7474
private Schema schema;
@@ -77,9 +77,9 @@ public abstract static class Builder<T extends BaseTableType, B extends Builder<
7777
this.type = type;
7878
}
7979

80-
Builder(BaseTableType tableType) {
81-
this.type = tableType.type;
82-
this.schema = tableType.schema;
80+
Builder(BaseTableDefinition tableDefinition) {
81+
this.type = tableDefinition.type;
82+
this.schema = tableDefinition.schema;
8383
}
8484

8585
Builder(Table tablePb) {
@@ -113,7 +113,7 @@ public B schema(Schema schema) {
113113
public abstract T build();
114114
}
115115

116-
BaseTableType(Builder builder) {
116+
BaseTableDefinition(Builder builder) {
117117
this.type = builder.type;
118118
this.schema = builder.schema;
119119
}
@@ -152,7 +152,7 @@ final int baseHashCode() {
152152
return Objects.hash(type);
153153
}
154154

155-
final boolean baseEquals(BaseTableType jobConfiguration) {
155+
final boolean baseEquals(BaseTableDefinition jobConfiguration) {
156156
return Objects.equals(toPb(), jobConfiguration.toPb());
157157
}
158158

@@ -166,14 +166,14 @@ Table toPb() {
166166
}
167167

168168
@SuppressWarnings("unchecked")
169-
static <T extends BaseTableType> T fromPb(Table tablePb) {
169+
static <T extends BaseTableDefinition> T fromPb(Table tablePb) {
170170
switch (Type.valueOf(tablePb.getType())) {
171171
case TABLE:
172-
return (T) DefaultTableType.fromPb(tablePb);
172+
return (T) DefaultTableDefinition.fromPb(tablePb);
173173
case VIEW:
174-
return (T) ViewType.fromPb(tablePb);
174+
return (T) ViewDefinition.fromPb(tablePb);
175175
case EXTERNAL:
176-
return (T) ExternalTableType.fromPb(tablePb);
176+
return (T) ExternalTableDefinition.fromPb(tablePb);
177177
default:
178178
// never reached
179179
throw new IllegalArgumentException("Format " + tablePb.getType() + " is not supported");

gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/CsvOptions.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ private CsvOptions(Builder builder) {
144144
* Returns whether BigQuery should accept rows that are missing trailing optional columns. If
145145
* {@code true}, BigQuery treats missing trailing columns as null values. If {@code false},
146146
* records with missing trailing columns are treated as bad records, and if the number of bad
147-
* records exceeds {@link ExternalTableType#maxBadRecords()}, an invalid error is returned
147+
* records exceeds {@link ExternalTableDefinition#maxBadRecords()}, an invalid error is returned
148148
* in the job result.
149149
*/
150150
public Boolean allowJaggedRows() {

gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/Dataset.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ public Table get(String table, BigQuery.TableOption... options) {
225225
* @return a {@code Table} object for the created table
226226
* @throws BigQueryException upon failure
227227
*/
228-
public Table create(String table, BaseTableType type, BigQuery.TableOption... options) {
228+
public Table create(String table, BaseTableDefinition type, BigQuery.TableOption... options) {
229229
TableInfo tableInfo = TableInfo.of(TableId.of(info.datasetId().dataset(), table), type);
230230
return new Table(bigquery, bigquery.create(tableInfo, options));
231231
}

gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/DefaultTableType.java renamed to gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/DefaultTableDefinition.java

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
*
3434
* @see <a href="https://cloud.google.com/bigquery/docs/tables">Managing Tables</a>
3535
*/
36-
public class DefaultTableType extends BaseTableType {
36+
public class DefaultTableDefinition extends BaseTableDefinition {
3737

3838
private static final long serialVersionUID = 2113445776046717900L;
3939

@@ -115,7 +115,8 @@ static StreamingBuffer fromPb(Streamingbuffer streamingBufferPb) {
115115
}
116116
}
117117

118-
public static final class Builder extends BaseTableType.Builder<DefaultTableType, Builder> {
118+
public static final class Builder
119+
extends BaseTableDefinition.Builder<DefaultTableDefinition, Builder> {
119120

120121
private Long numBytes;
121122
private Long numRows;
@@ -126,12 +127,12 @@ private Builder() {
126127
super(Type.TABLE);
127128
}
128129

129-
private Builder(DefaultTableType tableType) {
130-
super(tableType);
131-
this.numBytes = tableType.numBytes;
132-
this.numRows = tableType.numRows;
133-
this.location = tableType.location;
134-
this.streamingBuffer = tableType.streamingBuffer;
130+
private Builder(DefaultTableDefinition tableDefinition) {
131+
super(tableDefinition);
132+
this.numBytes = tableDefinition.numBytes;
133+
this.numRows = tableDefinition.numRows;
134+
this.location = tableDefinition.location;
135+
this.streamingBuffer = tableDefinition.streamingBuffer;
135136
}
136137

137138
private Builder(Table tablePb) {
@@ -167,15 +168,15 @@ Builder streamingBuffer(StreamingBuffer streamingBuffer) {
167168
}
168169

169170
/**
170-
* Creates a {@code DefaultTableType} object.
171+
* Creates a {@code DefaultTableDefinition} object.
171172
*/
172173
@Override
173-
public DefaultTableType build() {
174-
return new DefaultTableType(this);
174+
public DefaultTableDefinition build() {
175+
return new DefaultTableDefinition(this);
175176
}
176177
}
177178

178-
private DefaultTableType(Builder builder) {
179+
private DefaultTableDefinition(Builder builder) {
179180
super(builder);
180181
this.numBytes = builder.numBytes;
181182
this.numRows = builder.numRows;
@@ -228,12 +229,12 @@ public static Builder builder() {
228229
*
229230
* @param schema the schema of the table
230231
*/
231-
public static DefaultTableType of(Schema schema) {
232+
public static DefaultTableDefinition of(Schema schema) {
232233
return builder().schema(schema).build();
233234
}
234235

235236
/**
236-
* Returns a builder for the {@code DefaultTableType} object.
237+
* Returns a builder for the {@code DefaultTableDefinition} object.
237238
*/
238239
@Override
239240
public Builder toBuilder() {
@@ -251,7 +252,7 @@ ToStringHelper toStringHelper() {
251252

252253
@Override
253254
public boolean equals(Object obj) {
254-
return obj instanceof DefaultTableType && baseEquals((DefaultTableType) obj);
255+
return obj instanceof DefaultTableDefinition && baseEquals((DefaultTableDefinition) obj);
255256
}
256257

257258
@Override
@@ -274,7 +275,7 @@ Table toPb() {
274275
}
275276

276277
@SuppressWarnings("unchecked")
277-
static DefaultTableType fromPb(Table tablePb) {
278+
static DefaultTableDefinition fromPb(Table tablePb) {
278279
return new Builder(tablePb).build();
279280
}
280281
}

0 commit comments

Comments
 (0)