Skip to content

Commit 3bf8667

Browse files
Support replica materialized view in resource_bigquery_table in the beta provider (#9773) (#17020)
* support replica materialized view in resource_bigquery_table * fix typo * add unit tests * fix white spaces * fix the condition check for table_replication_info in Update * create source materialized view in unit tests using DDL instead of table API * add missing google-beta provider declarations in unit test * create source table using DDL in unit test * Revert "create source table using DDL in unit test" This reverts commit 232a7ac431114cd405f0cec858bb0496d48fd07c. * reorder input args in unit tests * remove wrong project declaration in unit tests * remove update check, make the new fields forcenew, and add default to replication_interval_ms * add ForceNew to table_replication_info [upstream:256f7f56789ee965c2e7582735140de383270400] Signed-off-by: Modular Magician <[email protected]>
1 parent f4046af commit 3bf8667

File tree

3 files changed

+51
-48
lines changed

3 files changed

+51
-48
lines changed

.changelog/9773.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:enhancement
2+
bigquery: support replica materialized view in resource_bigquery_table (beta)
3+
```

google/services/bigquery/resource_bigquery_table.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,7 @@ func ResourceBigQueryTable() *schema.Resource {
530530
Default: "NONE",
531531
Description: `The compression type of the data source. Valid values are "NONE" or "GZIP".`,
532532
},
533-
// Schema: Optional] The schema for the data.
533+
// Schema: [Optional] The schema for the data.
534534
// Schema is required for CSV and JSON formats if autodetect is not on.
535535
// Schema is disallowed for Google Cloud Bigtable, Cloud Datastore backups, Avro, Iceberg, ORC, and Parquet formats.
536536
"schema": {
@@ -889,7 +889,7 @@ func ResourceBigQueryTable() *schema.Resource {
889889
Type: schema.TypeInt,
890890
Default: 1800000,
891891
Optional: true,
892-
Description: `Specifies maximum frequency at which this materialized view will be refreshed. The default is 1800000`,
892+
Description: `Specifies maximum frequency at which this materialized view will be refreshed. The default is 1800000.`,
893893
},
894894

895895
"allow_non_incremental_definition": {
@@ -1390,7 +1390,7 @@ func resourceBigQueryTableCreate(d *schema.ResourceData, meta interface{}) error
13901390

13911391
if table.View != nil && table.Schema != nil {
13921392

1393-
log.Printf("[INFO] Removing schema from table definition because big query does not support setting schema on view creation")
1393+
log.Printf("[INFO] Removing schema from table definition because BigQuery does not support setting schema on view creation")
13941394
schemaBack := table.Schema
13951395
table.Schema = nil
13961396

@@ -1410,7 +1410,7 @@ func resourceBigQueryTableCreate(d *schema.ResourceData, meta interface{}) error
14101410
return err
14111411
}
14121412

1413-
log.Printf("[INFO] BigQuery table %s has been update with schema", res.Id)
1413+
log.Printf("[INFO] BigQuery table %s has been updated with schema", res.Id)
14141414
} else {
14151415
log.Printf("[INFO] Creating BigQuery table: %s", table.TableReference.TableId)
14161416

google/services/bigquery/resource_bigquery_table_test.go

+44-44
Original file line numberDiff line numberDiff line change
@@ -1765,7 +1765,7 @@ resource "google_bigquery_table" "test" {
17651765
hive_partitioning_options {
17661766
mode = "AUTO"
17671767
source_uri_prefix = "gs://${google_storage_bucket.test.name}/"
1768-
require_partition_filter = true
1768+
require_partition_filter = true
17691769
}
17701770
17711771
}
@@ -1805,7 +1805,7 @@ resource "google_bigquery_table" "test" {
18051805
hive_partitioning_options {
18061806
mode = "CUSTOM"
18071807
source_uri_prefix = "gs://${google_storage_bucket.test.name}/{key1:STRING}"
1808-
require_partition_filter = true
1808+
require_partition_filter = true
18091809
}
18101810
18111811
schema = <<EOH
@@ -3012,48 +3012,48 @@ resource "google_bigquery_table" "test" {
30123012

30133013
func testAccBigQueryTableFromBigtable(context map[string]interface{}) string {
30143014
return acctest.Nprintf(`
3015-
resource "google_bigtable_instance" "instance" {
3016-
name = "tf-test-bigtable-inst-%{random_suffix}"
3017-
cluster {
3018-
cluster_id = "tf-test-bigtable-%{random_suffix}"
3019-
zone = "us-central1-b"
3020-
}
3021-
instance_type = "DEVELOPMENT"
3022-
deletion_protection = false
3023-
}
3024-
resource "google_bigtable_table" "table" {
3025-
name = "%{random_suffix}"
3026-
instance_name = google_bigtable_instance.instance.name
3027-
column_family {
3028-
family = "cf-%{random_suffix}-first"
3029-
}
3030-
column_family {
3031-
family = "cf-%{random_suffix}-second"
3032-
}
3033-
}
3034-
resource "google_bigquery_table" "table" {
3035-
deletion_protection = false
3036-
dataset_id = google_bigquery_dataset.dataset.dataset_id
3037-
table_id = "tf_test_bigtable_%{random_suffix}"
3038-
external_data_configuration {
3039-
autodetect = true
3040-
source_format = "BIGTABLE"
3041-
ignore_unknown_values = true
3042-
source_uris = [
3043-
"https://googleapis.com/bigtable/${google_bigtable_table.table.id}",
3044-
]
3045-
}
3046-
}
3047-
resource "google_bigquery_dataset" "dataset" {
3048-
dataset_id = "tf_test_ds_%{random_suffix}"
3049-
friendly_name = "test"
3050-
description = "This is a test description"
3051-
location = "EU"
3052-
default_table_expiration_ms = 3600000
3053-
labels = {
3054-
env = "default"
3055-
}
3056-
}
3015+
resource "google_bigtable_instance" "instance" {
3016+
name = "tf-test-bigtable-inst-%{random_suffix}"
3017+
cluster {
3018+
cluster_id = "tf-test-bigtable-%{random_suffix}"
3019+
zone = "us-central1-b"
3020+
}
3021+
instance_type = "DEVELOPMENT"
3022+
deletion_protection = false
3023+
}
3024+
resource "google_bigtable_table" "table" {
3025+
name = "%{random_suffix}"
3026+
instance_name = google_bigtable_instance.instance.name
3027+
column_family {
3028+
family = "cf-%{random_suffix}-first"
3029+
}
3030+
column_family {
3031+
family = "cf-%{random_suffix}-second"
3032+
}
3033+
}
3034+
resource "google_bigquery_table" "table" {
3035+
deletion_protection = false
3036+
dataset_id = google_bigquery_dataset.dataset.dataset_id
3037+
table_id = "tf_test_bigtable_%{random_suffix}"
3038+
external_data_configuration {
3039+
autodetect = true
3040+
source_format = "BIGTABLE"
3041+
ignore_unknown_values = true
3042+
source_uris = [
3043+
"https://googleapis.com/bigtable/${google_bigtable_table.table.id}",
3044+
]
3045+
}
3046+
}
3047+
resource "google_bigquery_dataset" "dataset" {
3048+
dataset_id = "tf_test_ds_%{random_suffix}"
3049+
friendly_name = "test"
3050+
description = "This is a test description"
3051+
location = "EU"
3052+
default_table_expiration_ms = 3600000
3053+
labels = {
3054+
env = "default"
3055+
}
3056+
}
30573057
`, context)
30583058
}
30593059

0 commit comments

Comments
 (0)