From 95db749f5e2dc2cc8f656f940594b80fda39e73b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adria=CC=81n=20Matellanes?= Date: Fri, 19 Oct 2018 14:45:17 +0200 Subject: [PATCH] Add timePartitioning.requirePartitionFilter field to google_bigquery_table resource --- .../resources/resource_bigquery_table.go | 18 +++++++++++++++++- .../tests/resource_bigquery_table_test.go | 3 ++- .../docs/r/bigquery_table.html.markdown | 4 ++++ 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/third_party/terraform/resources/resource_bigquery_table.go b/third_party/terraform/resources/resource_bigquery_table.go index 0ea8e95e9f96..52aa33ca7b2c 100644 --- a/third_party/terraform/resources/resource_bigquery_table.go +++ b/third_party/terraform/resources/resource_bigquery_table.go @@ -142,7 +142,7 @@ func resourceBigQueryTable() *schema.Resource { ValidateFunc: validation.StringInSlice([]string{"DAY"}, false), }, - // Type: [Optional] The field used to determine how to create a time-based + // Field: [Optional] The field used to determine how to create a time-based // partition. If time-based partitioning is enabled without this value, the // table is partitioned based on the load time. "field": { @@ -150,6 +150,14 @@ func resourceBigQueryTable() *schema.Resource { Optional: true, ForceNew: true, }, + + // RequirePartitionFilter: [Optional] If set to true, queries over this table + // require a partition filter that can be used for partition elimination to be + // specified. + "require_partition_filter": { + Type: schema.TypeBool, + Optional: true, + }, }, }, }, @@ -436,6 +444,10 @@ func expandTimePartitioning(configured interface{}) *bigquery.TimePartitioning { tp.ExpirationMs = int64(v.(int)) } + if v, ok := raw["require_partition_filter"]; ok { + tp.RequirePartitionFilter = v.(bool) + } + return tp } @@ -450,6 +462,10 @@ func flattenTimePartitioning(tp *bigquery.TimePartitioning) []map[string]interfa result["expiration_ms"] = tp.ExpirationMs } + if tp.RequirePartitionFilter == true { + result["require_partition_filter"] = tp.RequirePartitionFilter + } + return []map[string]interface{}{result} } diff --git a/third_party/terraform/tests/resource_bigquery_table_test.go b/third_party/terraform/tests/resource_bigquery_table_test.go index 7f63543b36cc..dc0b909083de 100644 --- a/third_party/terraform/tests/resource_bigquery_table_test.go +++ b/third_party/terraform/tests/resource_bigquery_table_test.go @@ -122,7 +122,8 @@ resource "google_bigquery_table" "test" { time_partitioning { type = "DAY" - field = "ts" + field = "ts" + require_partition_filter = true } schema = <