Skip to content

Commit d620a64

Browse files
modular-magicianrileykarson
authored andcommitted
Add timePartitioning.requirePartitionFilter to bigquery table (#2815)
<!-- This change is generated by MagicModules. --> /cc @rileykarson
1 parent 4af5438 commit d620a64

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

google/resource_bigquery_table.go

+17-1
Original file line numberDiff line numberDiff line change
@@ -142,14 +142,22 @@ func resourceBigQueryTable() *schema.Resource {
142142
ValidateFunc: validation.StringInSlice([]string{"DAY"}, false),
143143
},
144144

145-
// Type: [Optional] The field used to determine how to create a time-based
145+
// Field: [Optional] The field used to determine how to create a time-based
146146
// partition. If time-based partitioning is enabled without this value, the
147147
// table is partitioned based on the load time.
148148
"field": {
149149
Type: schema.TypeString,
150150
Optional: true,
151151
ForceNew: true,
152152
},
153+
154+
// RequirePartitionFilter: [Optional] If set to true, queries over this table
155+
// require a partition filter that can be used for partition elimination to be
156+
// specified.
157+
"require_partition_filter": {
158+
Type: schema.TypeBool,
159+
Optional: true,
160+
},
153161
},
154162
},
155163
},
@@ -436,6 +444,10 @@ func expandTimePartitioning(configured interface{}) *bigquery.TimePartitioning {
436444
tp.ExpirationMs = int64(v.(int))
437445
}
438446

447+
if v, ok := raw["require_partition_filter"]; ok {
448+
tp.RequirePartitionFilter = v.(bool)
449+
}
450+
439451
return tp
440452
}
441453

@@ -450,6 +462,10 @@ func flattenTimePartitioning(tp *bigquery.TimePartitioning) []map[string]interfa
450462
result["expiration_ms"] = tp.ExpirationMs
451463
}
452464

465+
if tp.RequirePartitionFilter == true {
466+
result["require_partition_filter"] = tp.RequirePartitionFilter
467+
}
468+
453469
return []map[string]interface{}{result}
454470
}
455471

google/resource_bigquery_table_test.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,8 @@ resource "google_bigquery_table" "test" {
122122
123123
time_partitioning {
124124
type = "DAY"
125-
field = "ts"
125+
field = "ts"
126+
require_partition_filter = true
126127
}
127128
128129
schema = <<EOH

website/docs/r/bigquery_table.html.markdown

+4
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,10 @@ The `time_partitioning` block supports:
8888
* `type` - (Required) The only type supported is DAY, which will generate
8989
one partition per day based on data loading time.
9090

91+
* `require_partition_filter` - (Optional) If set to true, queries over this table
92+
require a partition filter that can be used for partition elimination to be
93+
specified.
94+
9195
The `view` block supports:
9296

9397
* `query` - (Required) A query that BigQuery executes when the view is referenced.

0 commit comments

Comments
 (0)