Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add defaultPartitionExpirationMs field to google_bigquery_dataset resource #2287

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"}, 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 @@ -336,6 +359,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