Skip to content

Commit

Permalink
Add defaultPartitionExpirationMs field to google_bigquery_dataset res…
Browse files Browse the repository at this point in the history
  • Loading branch information
amatellanes authored and nat-henderson committed Dec 21, 2018
1 parent a34118c commit 32431f4
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 1 deletion.
24 changes: 24 additions & 0 deletions google/resource_bigquery_dataset.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,25 @@ func resourceBigQueryDataset() *schema.Resource {
ValidateFunc: validation.StringInSlice([]string{"US", "EU", "asia-northeast1", "europe-west2", "australia-southeast1"}, false),
},

// defaultPartitionExpirationMs: [Optional] The default partition
// expiration for all partitioned tables in the dataset, in
// milliseconds. Once this property is set, all newly-created
// partitioned tables in the dataset will have an expirationMs
// property in the timePartitioning settings set to this value, and
// changing the value will only affect new tables, not existing ones.
// The storage in a partition will have an expiration time of its
// partition time plus this value. Setting this property overrides the
// use of defaultTableExpirationMs for partitioned tables: only one of
// defaultTableExpirationMs and defaultPartitionExpirationMs will be used
// for any new partitioned table. If you provide an explicit
// timePartitioning.expirationMs when creating or updating a partitioned
// table, that value takes precedence over the default partition expiration
// time indicated by this property.
"default_partition_expiration_ms": {
Type: schema.TypeInt,
Optional: true,
},

// DefaultTableExpirationMs: [Optional] The default lifetime of all
// tables in the dataset, in milliseconds. The minimum value is 3600000
// milliseconds (one hour). Once this property is set, all newly-created
Expand Down Expand Up @@ -223,6 +242,10 @@ func resourceDataset(d *schema.ResourceData, meta interface{}) (*bigquery.Datase
dataset.Location = v.(string)
}

if v, ok := d.GetOk("default_partition_expiration_ms"); ok {
dataset.DefaultPartitionExpirationMs = int64(v.(int))
}

if v, ok := d.GetOk("default_table_expiration_ms"); ok {
dataset.DefaultTableExpirationMs = int64(v.(int))
}
Expand Down Expand Up @@ -337,6 +360,7 @@ func resourceBigQueryDatasetRead(d *schema.ResourceData, meta interface{}) error
d.Set("creation_time", res.CreationTime)
d.Set("last_modified_time", res.LastModifiedTime)
d.Set("dataset_id", res.DatasetReference.DatasetId)
d.Set("default_partition_expiration_ms", res.DefaultPartitionExpirationMs)
d.Set("default_table_expiration_ms", res.DefaultTableExpirationMs)

// Older Tables in BigQuery have no Location set in the API response. This may be an issue when importing
Expand Down
2 changes: 2 additions & 0 deletions google/resource_bigquery_dataset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ resource "google_bigquery_dataset" "test" {
friendly_name = "foo"
description = "This is a foo description"
location = "EU"
default_partition_expiration_ms = 3600000
default_table_expiration_ms = 3600000
labels {
Expand All @@ -127,6 +128,7 @@ resource "google_bigquery_dataset" "test" {
friendly_name = "bar"
description = "This is a bar description"
location = "EU"
default_partition_expiration_ms = 7200000
default_table_expiration_ms = 7200000
labels {
Expand Down
15 changes: 15 additions & 0 deletions website/docs/r/bigquery_dataset.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,21 @@ The following arguments are supported:
The default value is multi-regional location `US`.
Changing this forces a new resource to be created.

* `default_partition_expiration_ms` - (Optional) The default partition expiration
for all partitioned tables in the dataset, in milliseconds.

Once this property is set, all newly-created partitioned tables in the dataset
will have an expirationMs property in the timePartitioning settings set to this
value, and changing the value will only affect new tables, not existing ones.
The storage in a partition will have an expiration time of its partition time
plus this value. Setting this property overrides the use of
`defaultTableExpirationMs` for partitioned tables: only one of
`defaultTableExpirationMs` and `defaultPartitionExpirationMs` will be used for
any new partitioned table. If you provide an explicit
`timePartitioning.expirationMs` when creating or updating a partitioned table,
that value takes precedence over the default partition expiration time
indicated by this property.

* `default_table_expiration_ms` - (Optional) The default lifetime of all
tables in the dataset, in milliseconds. The minimum value is 3600000
milliseconds (one hour).
Expand Down
2 changes: 1 addition & 1 deletion website/docs/r/storage_bucket.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ description: |-

Creates a new bucket in Google cloud storage service (GCS).
Once a bucket has been created, its location can't be changed.
[ACLs](https://cloud.google.com/storage/docs/access-control/lists) can be applied using the `google_storage_bucket_acl` resource.
[ACLs](https://cloud.google.com/storage/docs/access-control/lists) can be applied using the [`google_storage_bucket_acl` resource](/docs/providers/google/r/storage_bucket_acl.html).
For more information see
[the official documentation](https://cloud.google.com/storage/docs/overview)
and
Expand Down

0 comments on commit 32431f4

Please sign in to comment.