Skip to content

Commit 3fe6669

Browse files
committed
impl(google_bigquery_table): exposing TableMetadataView query param
1 parent fed2c98 commit 3fe6669

File tree

3 files changed

+26
-3
lines changed

3 files changed

+26
-3
lines changed

mmv1/products/bigquery/Table.yaml

+8
Original file line numberDiff line numberDiff line change
@@ -645,3 +645,11 @@ properties:
645645
from BigQuery Engine. The connection_id can have the form `<project_id>.<location_id>.<connection_id>`
646646
or `projects/<project_id>/locations/<location_id>/connections/<connection_id>`.
647647
min_version: beta
648+
virtual_fields:
649+
- name: 'table_metadata_view'
650+
type: String
651+
description: |
652+
View sets the optional parameter "view": Specifies the view that determines which table information is
653+
returned. By default, basic table information and storage statistics (STORAGE_STATS) are returned.
654+
Possible values: TABLE_METADATA_VIEW_UNSPECIFIED, BASIC, STORAGE_STATS, FULL
655+
default_value: "TABLE_METADATA_VIEW_UNSPECIFIED"

mmv1/third_party/terraform/services/bigquery/resource_bigquery_table.go.tmpl

+14-1
Original file line numberDiff line numberDiff line change
@@ -1447,6 +1447,12 @@ func ResourceBigQueryTable() *schema.Resource {
14471447
},
14481448
},
14491449
},
1450+
"table_metadata_view": {
1451+
Type: schema.TypeString,
1452+
Optional: true,
1453+
Default: "TABLE_METADATA_VIEW_UNSPECIFIED",
1454+
Description: `View sets the optional parameter "view": Specifies the view that determines which table information is returned. By default, basic table information and storage statistics (STORAGE_STATS) are returned. Possible values: TABLE_METADATA_VIEW_UNSPECIFIED, BASIC, STORAGE_STATS, FULL`,
1455+
},
14501456
// TableReplicationInfo: [Optional] Replication info of a table created using `AS REPLICA` DDL like: `CREATE MATERIALIZED VIEW mv1 AS REPLICA OF src_mv`.
14511457
"table_replication_info": {
14521458
Type: schema.TypeList,
@@ -1834,7 +1840,14 @@ func resourceBigQueryTableRead(d *schema.ResourceData, meta interface{}) error {
18341840
datasetID := d.Get("dataset_id").(string)
18351841
tableID := d.Get("table_id").(string)
18361842

1837-
res, err := config.NewBigQueryClient(userAgent).Tables.Get(project, datasetID, tableID).Do()
1843+
tableMetadataView := d.Get("table_metadata_view").(string)
1844+
1845+
client := config.NewBigQueryClient(userAgent).Tables.Get(project, datasetID, tableID)
1846+
if len(tableMetadataView) > 0 {
1847+
client = client.View(tableMetadataView)
1848+
}
1849+
res, err := client.Do()
1850+
18381851
if err != nil {
18391852
return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("BigQuery table %q", tableID))
18401853
}

mmv1/third_party/terraform/services/bigquery/resource_bigquery_table_test.go.tmpl

+4-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func TestAccBigQueryTable_Basic(t *testing.T) {
3030
ResourceName: "google_bigquery_table.test",
3131
ImportState: true,
3232
ImportStateVerify: true,
33-
ImportStateVerifyIgnore: []string{"deletion_protection"},
33+
ImportStateVerifyIgnore: []string{"deletion_protection", "last_modified_time", "table_metadata_view"},
3434
},
3535
{
3636
Config: testAccBigQueryTableUpdated(datasetID, tableID),
@@ -39,7 +39,7 @@ func TestAccBigQueryTable_Basic(t *testing.T) {
3939
ResourceName: "google_bigquery_table.test",
4040
ImportState: true,
4141
ImportStateVerify: true,
42-
ImportStateVerifyIgnore: []string{"deletion_protection"},
42+
ImportStateVerifyIgnore: []string{"deletion_protection", "last_modified_time", "table_metadata_view"},
4343
},
4444
},
4545
})
@@ -2096,6 +2096,8 @@ resource "google_bigquery_table" "test" {
20962096
table_id = "%s"
20972097
dataset_id = google_bigquery_dataset.test.dataset_id
20982098

2099+
table_metadata_view = "BASIC"
2100+
20992101
time_partitioning {
21002102
type = "%s"
21012103
field = "ts"

0 commit comments

Comments
 (0)