diff --git a/google/resource_bigquery_table.go b/google/resource_bigquery_table.go index abb46b7703d..c9ea365ab21 100644 --- a/google/resource_bigquery_table.go +++ b/google/resource_bigquery_table.go @@ -533,6 +533,14 @@ func resourceBigQueryTable() *schema.Resource { Optional: true, Description: `When set, what mode of hive partitioning to use when reading data.`, }, + // 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, + Description: `If set to true, queries over this table require a partition filter that can be used for partition elimination to be specified.`, + }, // SourceUriPrefix: [Optional] [Experimental] When hive partition detection is requested, a common for all source uris must be required. // The prefix must end immediately before the partition key encoding begins. "source_uri_prefix": { @@ -1410,6 +1418,10 @@ func expandHivePartitioningOptions(configured interface{}) *bigquery.HivePartiti opts.Mode = v.(string) } + if v, ok := raw["require_partition_filter"]; ok { + opts.RequirePartitionFilter = v.(bool) + } + if v, ok := raw["source_uri_prefix"]; ok { opts.SourceUriPrefix = v.(string) } @@ -1424,6 +1436,10 @@ func flattenHivePartitioningOptions(opts *bigquery.HivePartitioningOptions) []ma result["mode"] = opts.Mode } + if opts.RequirePartitionFilter { + result["require_partition_filter"] = opts.RequirePartitionFilter + } + if opts.SourceUriPrefix != "" { result["source_uri_prefix"] = opts.SourceUriPrefix } diff --git a/google/resource_bigquery_table_test.go b/google/resource_bigquery_table_test.go index 8521b7c5868..41ff303be75 100644 --- a/google/resource_bigquery_table_test.go +++ b/google/resource_bigquery_table_test.go @@ -1006,6 +1006,7 @@ resource "google_bigquery_table" "test" { hive_partitioning_options { mode = "AUTO" source_uri_prefix = "gs://${google_storage_bucket.test.name}/" + require_partition_filter = true } } @@ -1044,6 +1045,7 @@ resource "google_bigquery_table" "test" { hive_partitioning_options { mode = "CUSTOM" source_uri_prefix = "gs://${google_storage_bucket.test.name}/{key1:STRING}" + require_partition_filter = true } schema = <