diff --git a/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/BigQuery.java b/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/BigQuery.java
index 8f11d03fa0..2712783576 100644
--- a/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/BigQuery.java
+++ b/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/BigQuery.java
@@ -121,6 +121,20 @@ public String getSelector() {
}
}
+ /**
+ * Metadata of a BigQuery Table.
+ *
+ * @see Table
+ * Resource
+ */
+ enum TableMetadataView {
+ BASIC,
+ FULL,
+ STORAGE_STATS,
+ TABLE_METADATA_VIEW_UNSPECIFIED;
+ }
+
/**
* Fields of a BigQuery Model resource.
*
@@ -384,6 +398,11 @@ public static TableOption fields(TableField... fields) {
public static TableOption autodetectSchema(boolean autodetect) {
return new TableOption(BigQueryRpc.Option.AUTODETECT_SCHEMA, autodetect);
}
+
+ /** Returns an option to specify the metadata of the table. */
+ public static TableOption tableMetadataView(TableMetadataView tableMetadataView) {
+ return new TableOption(BigQueryRpc.Option.TABLE_METADATA_VIEW, tableMetadataView);
+ }
}
/* Class for specifying IAM options. */
diff --git a/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/BigQueryImpl.java b/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/BigQueryImpl.java
index b5ca2e5776..6512a6e008 100644
--- a/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/BigQueryImpl.java
+++ b/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/BigQueryImpl.java
@@ -775,6 +775,8 @@ public Table getTable(TableId tableId, TableOption... options) {
? getOptions().getProjectId()
: tableId.getProject());
final Map optionsMap = optionMap(options);
+ System.out.println("Penguins");
+ System.out.println(optionsMap);
try {
com.google.api.services.bigquery.model.Table answer =
runWithRetries(
diff --git a/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/Table.java b/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/Table.java
index 3e67e8d750..1235c45ec2 100644
--- a/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/Table.java
+++ b/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/Table.java
@@ -49,10 +49,10 @@ public static class Builder extends TableInfo.Builder {
private final BigQuery bigquery;
private final TableInfo.BuilderImpl infoBuilder;
- Builder(BigQuery bigquery, TableId tableId, TableDefinition defintion) {
+ Builder(BigQuery bigquery, TableId tableId, TableDefinition definition) {
this.bigquery = bigquery;
this.infoBuilder = new TableInfo.BuilderImpl();
- this.infoBuilder.setTableId(tableId).setDefinition(defintion);
+ this.infoBuilder.setTableId(tableId).setDefinition(definition);
}
Builder(Table table) {
diff --git a/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/spi/v2/BigQueryRpc.java b/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/spi/v2/BigQueryRpc.java
index 33480a91b3..3416409190 100644
--- a/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/spi/v2/BigQueryRpc.java
+++ b/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/spi/v2/BigQueryRpc.java
@@ -40,7 +40,7 @@
@InternalExtensionOnly
public interface BigQueryRpc extends ServiceRpc {
- // These options are part of the Google Cloud BigQuery query parameters
+ // These options are part of the Google Cloud BigQuery query parameters.
enum Option {
FIELDS("fields"),
DELETE_CONTENTS("deleteContents"),
@@ -56,7 +56,8 @@ enum Option {
START_INDEX("startIndex"),
STATE_FILTER("stateFilter"),
TIMEOUT("timeoutMs"),
- REQUESTED_POLICY_VERSION("requestedPolicyVersion");
+ REQUESTED_POLICY_VERSION("requestedPolicyVersion"),
+ TABLE_METADATA_VIEW("view");
private final String value;
diff --git a/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/spi/v2/HttpBigQueryRpc.java b/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/spi/v2/HttpBigQueryRpc.java
index a63e3cc2ba..90d3014256 100644
--- a/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/spi/v2/HttpBigQueryRpc.java
+++ b/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/spi/v2/HttpBigQueryRpc.java
@@ -294,6 +294,7 @@ public Table getTable(
.get(projectId, datasetId, tableId)
.setPrettyPrint(false)
.setFields(Option.FIELDS.getString(options))
+ .setView(getTableMetadataOption(options))
.execute();
} catch (IOException ex) {
BigQueryException serviceException = translate(ex);
@@ -304,6 +305,19 @@ public Table getTable(
}
}
+ private String getTableMetadataOption(Map