Skip to content

Commit 90f931f

Browse files
authored
fix!: moved require_partition_filter to the top (#335)
1 parent 470c5cc commit 90f931f

8 files changed

+82
-40
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ This module provisions a dataset and a list of tables with associated JSON schem
200200
| max\_time\_travel\_hours | Defines the time travel window in hours | `number` | `null` | no |
201201
| project\_id | Project where the dataset and table are created | `string` | n/a | yes |
202202
| routines | A list of objects which include routine\_id, routine\_type, routine\_language, definition\_body, return\_type, routine\_description and arguments. | <pre>list(object({<br> routine_id = string,<br> routine_type = string,<br> language = string,<br> definition_body = string,<br> return_type = string,<br> description = string,<br> arguments = list(object({<br> name = string,<br> data_type = string,<br> argument_kind = string,<br> mode = string,<br> })),<br> }))</pre> | `[]` | no |
203-
| tables | A list of objects which include table\_id, table\_name, schema, clustering, time\_partitioning, range\_partitioning, expiration\_time and labels. | <pre>list(object({<br> table_id = string,<br> description = optional(string),<br> table_name = optional(string),<br> schema = string,<br> clustering = list(string),<br> time_partitioning = object({<br> expiration_ms = string,<br> field = string,<br> type = string,<br> require_partition_filter = bool,<br> }),<br> range_partitioning = object({<br> field = string,<br> range = object({<br> start = string,<br> end = string,<br> interval = string,<br> }),<br> }),<br> expiration_time = string,<br> deletion_protection = optional(bool),<br> labels = map(string),<br> }))</pre> | `[]` | no |
203+
| tables | A list of objects which include table\_id, table\_name, schema, clustering, time\_partitioning, range\_partitioning, expiration\_time and labels. | <pre>list(object({<br> table_id = string,<br> description = optional(string),<br> table_name = optional(string),<br> schema = string,<br> clustering = list(string),<br> require_partition_filter = optional(bool),<br> time_partitioning = object({<br> expiration_ms = string,<br> field = string,<br> type = string,<br> }),<br> range_partitioning = object({<br> field = string,<br> range = object({<br> start = string,<br> end = string,<br> interval = string,<br> }),<br> }),<br> expiration_time = string,<br> deletion_protection = optional(bool),<br> labels = map(string),<br> }))</pre> | `[]` | no |
204204
| views | A list of objects which include view\_id and view query | <pre>list(object({<br> view_id = string,<br> description = optional(string),<br> query = string,<br> use_legacy_sql = bool,<br> labels = map(string),<br> }))</pre> | `[]` | no |
205205

206206
## Outputs

docs/upgrading_to_bigquery_v8.0.md

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Upgrading to BigQuery v8.0
2+
3+
The v8.0 release of BigQuery is a backwards incompatible release.
4+
5+
- The supported provider has been updated to v5.3
6+
- `require_partition_filter` has been deprecated under the `time_partitioning`
7+
block and can be used at the top level with the same name instead.
8+
9+
## Migration Instructions
10+
11+
1. Upgrade version
12+
13+
```diff
14+
module "bigquery" {
15+
source = "terraform-google-modules/bigquery/google"
16+
- version = "~> 7.0"
17+
+ version = "~> 8.0"
18+
....
19+
}
20+
```
21+
22+
2. Remove `require_partition_filter` from within the `time_partitioning` block
23+
and set it at the top level, if required.
24+
25+
```diff
26+
module "bigquery" {
27+
source = "terraform-google-modules/bigquery/google"
28+
....
29+
tables = [
30+
{
31+
....
32+
+ require_partition_filter = true,
33+
time_partitioning = {
34+
....
35+
- require_partition_filter = true,
36+
....
37+
},
38+
....
39+
}
40+
]
41+
...
42+
}
43+
```

examples/basic_view/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ This is a common practice for providing limited data in a different dataset.
1111
| delete\_contents\_on\_destroy | (Optional) If set to true, delete all the tables in the dataset when destroying the resource; otherwise, destroying the resource will fail if tables are present. | `bool` | `null` | no |
1212
| table\_dataset\_labels | A mapping of labels to assign to the table. | `map(string)` | n/a | yes |
1313
| table\_project\_id | Project where the dataset and table are created. | `any` | n/a | yes |
14-
| tables | A list of maps that includes table\_id, schema, clustering, time\_partitioning, range\_partitioning, view, expiration\_time, labels in each element. | <pre>list(object({<br> table_id = string,<br> schema = string,<br> clustering = list(string),<br> time_partitioning = object({<br> expiration_ms = string,<br> field = string,<br> type = string,<br> require_partition_filter = bool,<br> }),<br> range_partitioning = object({<br> field = string,<br> range = object({<br> start = string,<br> end = string,<br> interval = string,<br> }),<br> }),<br> expiration_time = string,<br> labels = map(string),<br> }))</pre> | `[]` | no |
14+
| tables | A list of maps that includes table\_id, schema, clustering, time\_partitioning, range\_partitioning, view, expiration\_time, labels in each element. | <pre>list(object({<br> table_id = string,<br> schema = string,<br> clustering = list(string),<br> time_partitioning = object({<br> expiration_ms = string,<br> field = string,<br> type = string,<br> }),<br> range_partitioning = object({<br> field = string,<br> range = object({<br> start = string,<br> end = string,<br> interval = string,<br> }),<br> }),<br> expiration_time = string,<br> labels = map(string),<br> }))</pre> | `[]` | no |
1515
| view\_dataset\_labels | A mapping of labels to assign to the table. | `map(string)` | n/a | yes |
1616
| view\_project\_id | Project where the dataset and table are created. | `any` | n/a | yes |
1717
| views | A list of objects which include table\_id, which is view id, and view query | <pre>list(object({<br> view_id = string,<br> query = string,<br> use_legacy_sql = bool,<br> labels = map(string),<br> }))</pre> | `[]` | no |

examples/basic_view/variables.tf

+3-4
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,9 @@ variable "tables" {
3737
schema = string,
3838
clustering = list(string),
3939
time_partitioning = object({
40-
expiration_ms = string,
41-
field = string,
42-
type = string,
43-
require_partition_filter = bool,
40+
expiration_ms = string,
41+
field = string,
42+
type = string,
4443
}),
4544
range_partitioning = object({
4645
field = string,

main.tf

+15-15
Original file line numberDiff line numberDiff line change
@@ -65,25 +65,25 @@ resource "google_bigquery_dataset" "main" {
6565
}
6666

6767
resource "google_bigquery_table" "main" {
68-
for_each = local.tables
69-
dataset_id = google_bigquery_dataset.main.dataset_id
70-
friendly_name = each.value["table_name"] != null ? each.value["table_name"] : each.key
71-
table_id = each.key
72-
description = each.value["description"]
73-
labels = each.value["labels"]
74-
schema = each.value["schema"]
75-
clustering = each.value["clustering"]
76-
expiration_time = each.value["expiration_time"] != null ? each.value["expiration_time"] : 0
77-
project = var.project_id
78-
deletion_protection = coalesce(each.value["deletion_protection"], var.deletion_protection)
68+
for_each = local.tables
69+
dataset_id = google_bigquery_dataset.main.dataset_id
70+
friendly_name = each.value["table_name"] != null ? each.value["table_name"] : each.key
71+
table_id = each.key
72+
description = each.value["description"]
73+
labels = each.value["labels"]
74+
schema = each.value["schema"]
75+
clustering = each.value["clustering"]
76+
expiration_time = each.value["expiration_time"] != null ? each.value["expiration_time"] : 0
77+
project = var.project_id
78+
deletion_protection = coalesce(each.value["deletion_protection"], var.deletion_protection)
79+
require_partition_filter = each.value["require_partition_filter"]
7980

8081
dynamic "time_partitioning" {
8182
for_each = each.value["time_partitioning"] != null ? [each.value["time_partitioning"]] : []
8283
content {
83-
type = time_partitioning.value["type"]
84-
expiration_ms = time_partitioning.value["expiration_ms"] != null ? time_partitioning.value["expiration_ms"] : 0
85-
field = time_partitioning.value["field"]
86-
require_partition_filter = time_partitioning.value["require_partition_filter"]
84+
type = time_partitioning.value["type"]
85+
expiration_ms = time_partitioning.value["expiration_ms"] != null ? time_partitioning.value["expiration_ms"] : 0
86+
field = time_partitioning.value["field"]
8787
}
8888
}
8989

metadata.yaml

+9-9
Original file line numberDiff line numberDiff line change
@@ -182,16 +182,16 @@ spec:
182182
description: A list of objects which include table_id, table_name, schema, clustering, time_partitioning, range_partitioning, expiration_time and labels.
183183
varType: |-
184184
list(object({
185-
table_id = string,
186-
description = optional(string),
187-
table_name = optional(string),
188-
schema = string,
189-
clustering = list(string),
185+
table_id = string,
186+
description = optional(string),
187+
table_name = optional(string),
188+
schema = string,
189+
clustering = list(string),
190+
require_partition_filter = optional(bool),
190191
time_partitioning = object({
191-
expiration_ms = string,
192-
field = string,
193-
type = string,
194-
require_partition_filter = bool,
192+
expiration_ms = string,
193+
field = string,
194+
type = string,
195195
}),
196196
range_partitioning = object({
197197
field = string,

variables.tf

+9-9
Original file line numberDiff line numberDiff line change
@@ -98,16 +98,16 @@ variable "tables" {
9898
description = "A list of objects which include table_id, table_name, schema, clustering, time_partitioning, range_partitioning, expiration_time and labels."
9999
default = []
100100
type = list(object({
101-
table_id = string,
102-
description = optional(string),
103-
table_name = optional(string),
104-
schema = string,
105-
clustering = list(string),
101+
table_id = string,
102+
description = optional(string),
103+
table_name = optional(string),
104+
schema = string,
105+
clustering = list(string),
106+
require_partition_filter = optional(bool),
106107
time_partitioning = object({
107-
expiration_ms = string,
108-
field = string,
109-
type = string,
110-
require_partition_filter = bool,
108+
expiration_ms = string,
109+
field = string,
110+
type = string,
111111
}),
112112
range_partitioning = object({
113113
field = string,

versions.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ terraform {
2020

2121
google = {
2222
source = "hashicorp/google"
23-
version = ">= 4.42, < 6"
23+
version = ">= 5.3, < 6"
2424
}
2525
}
2626

0 commit comments

Comments
 (0)