@@ -1447,6 +1447,11 @@ func ResourceBigQueryTable() *schema.Resource {
1447
1447
},
1448
1448
},
1449
1449
},
1450
+ "table_metadata_view": {
1451
+ Type: schema.TypeString,
1452
+ Optional: true,
1453
+ 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`,
1454
+ },
1450
1455
// TableReplicationInfo: [Optional] Replication info of a table created using `AS REPLICA` DDL like: `CREATE MATERIALIZED VIEW mv1 AS REPLICA OF src_mv`.
1451
1456
"table_replication_info": {
1452
1457
Type: schema.TypeList,
@@ -1834,7 +1839,12 @@ func resourceBigQueryTableRead(d *schema.ResourceData, meta interface{}) error {
1834
1839
datasetID := d.Get("dataset_id").(string)
1835
1840
tableID := d.Get("table_id").(string)
1836
1841
1837
- res, err := config.NewBigQueryClient(userAgent).Tables.Get(project, datasetID, tableID).Do()
1842
+ client := config.NewBigQueryClient(userAgent).Tables.Get(project, datasetID, tableID)
1843
+ if tableMetadataViewRaw, ok := d.GetOk("table_metadata_view"); ok {
1844
+ client = client.View(tableMetadataViewRaw.(string))
1845
+ }
1846
+ res, err := client.Do()
1847
+
1838
1848
if err != nil {
1839
1849
return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("BigQuery table %q", tableID))
1840
1850
}
@@ -2060,7 +2070,7 @@ type TableReference struct {
2060
2070
2061
2071
func resourceBigQueryTableUpdate(d *schema.ResourceData, meta interface{}) error {
2062
2072
// If only client-side fields were modified, short-circuit the Update function to avoid sending an update API request.
2063
- clientSideFields := map[string]bool{"deletion_protection": true}
2073
+ clientSideFields := map[string]bool{"deletion_protection": true, "table_metadata_view": true }
2064
2074
clientSideOnly := true
2065
2075
for field := range ResourceBigQueryTable().Schema {
2066
2076
if d.HasChange(field) && !clientSideFields[field] {
@@ -2097,14 +2107,18 @@ func resourceBigQueryTableUpdate(d *schema.ResourceData, meta interface{}) error
2097
2107
2098
2108
datasetID := d.Get("dataset_id").(string)
2099
2109
tableID := d.Get("table_id").(string)
2110
+ var tableMetadataView string
2111
+ if tableMetadataViewRaw, ok := d.GetOk("table_metadata_view"); ok {
2112
+ tableMetadataView = tableMetadataViewRaw.(string)
2113
+ }
2100
2114
2101
2115
tableReference := &TableReference{
2102
2116
project: project,
2103
2117
datasetID: datasetID,
2104
2118
tableID: tableID,
2105
2119
}
2106
2120
2107
- if err = resourceBigQueryTableColumnDrop(config, userAgent, table, tableReference); err != nil {
2121
+ if err = resourceBigQueryTableColumnDrop(config, userAgent, table, tableReference, tableMetadataView ); err != nil {
2108
2122
return err
2109
2123
}
2110
2124
@@ -2115,8 +2129,13 @@ func resourceBigQueryTableUpdate(d *schema.ResourceData, meta interface{}) error
2115
2129
return resourceBigQueryTableRead(d, meta)
2116
2130
}
2117
2131
2118
- func resourceBigQueryTableColumnDrop(config *transport_tpg.Config, userAgent string, table *bigquery.Table, tableReference *TableReference) error {
2119
- oldTable, err := config.NewBigQueryClient(userAgent).Tables.Get(tableReference.project, tableReference.datasetID, tableReference.tableID).Do()
2132
+ func resourceBigQueryTableColumnDrop(config *transport_tpg.Config, userAgent string, table *bigquery.Table, tableReference *TableReference, tableMetadataView string) error {
2133
+ client := config.NewBigQueryClient(userAgent).Tables.Get(tableReference.project, tableReference.datasetID, tableReference.tableID)
2134
+ if len(tableMetadataView) > 0 {
2135
+ client = client.View(tableMetadataView)
2136
+ }
2137
+ oldTable, err := client.Do()
2138
+
2120
2139
if err != nil {
2121
2140
return err
2122
2141
}
@@ -3382,6 +3401,8 @@ func resourceBigQueryTableImport(d *schema.ResourceData, meta interface{}) ([]*s
3382
3401
return nil, fmt.Errorf("Error setting deletion_protection: %s", err)
3383
3402
}
3384
3403
3404
+ // Explicitly set virtual fields with default values to their default values on import
3405
+
3385
3406
// Replace import id for the resource id
3386
3407
id, err := tpgresource.ReplaceVars(d, config, "projects/{{"{{"}}project{{"}}"}}/datasets/{{"{{"}}dataset_id{{"}}"}}/tables/{{"{{"}}table_id{{"}}"}}")
3387
3408
if err != nil {
0 commit comments