From 7ea3a34efa95ccf4ce6fcc70b1337f9c4b3645af Mon Sep 17 00:00:00 2001 From: Modular Magician Date: Thu, 23 Jan 2025 00:27:21 +0000 Subject: [PATCH] Add foreign type info and definition to google_bigquery_table beta (#12659) [upstream:b387b3600d42dc033ad824a194e78ff2dc4973ab] Signed-off-by: Modular Magician --- .changelog/12659.txt | 3 +++ google/services/bigquery/resource_bigquery_table.go | 3 --- .../bigquery/resource_bigquery_table_internal_test.go | 4 ++-- website/docs/r/bigquery_table.html.markdown | 11 +++++++++++ 4 files changed, 16 insertions(+), 5 deletions(-) create mode 100644 .changelog/12659.txt diff --git a/.changelog/12659.txt b/.changelog/12659.txt new file mode 100644 index 00000000000..c32343ff2ce --- /dev/null +++ b/.changelog/12659.txt @@ -0,0 +1,3 @@ +```release-note:enhancement +bigquery: added `schema_foreign_type_info` field and related schema handling to `google_bigquery_table` resource (beta) +``` \ No newline at end of file diff --git a/google/services/bigquery/resource_bigquery_table.go b/google/services/bigquery/resource_bigquery_table.go index 62ec8539e98..37ac303957b 100644 --- a/google/services/bigquery/resource_bigquery_table.go +++ b/google/services/bigquery/resource_bigquery_table.go @@ -97,7 +97,6 @@ func jsonCompareWithMapKeyOverride(key string, a, b interface{}, compareMapKeyVa for subKey := range objectB { unionOfKeys[subKey] = true } - for subKey := range unionOfKeys { eq := compareMapKeyVal(subKey, objectA, objectB) if !eq { @@ -1542,7 +1541,6 @@ func resourceTable(d *schema.ResourceData, meta interface{}) (*bigquery.Table, e } table.Schema = schema } - if v, ok := d.GetOk("time_partitioning"); ok { table.TimePartitioning = expandTimePartitioning(v) } @@ -2630,7 +2628,6 @@ func schemaHasRequiredFields(schema *bigquery.TableSchema) bool { } return false } - func expandTimePartitioning(configured interface{}) *bigquery.TimePartitioning { raw := configured.([]interface{})[0].(map[string]interface{}) tp := &bigquery.TimePartitioning{Type: raw["type"].(string)} diff --git a/google/services/bigquery/resource_bigquery_table_internal_test.go b/google/services/bigquery/resource_bigquery_table_internal_test.go index 8c69fed1583..cb39fc6053b 100644 --- a/google/services/bigquery/resource_bigquery_table_internal_test.go +++ b/google/services/bigquery/resource_bigquery_table_internal_test.go @@ -378,10 +378,10 @@ func TestBigQueryTableSchemaDiffSuppress(t *testing.T) { var a, b interface{} if err := json.Unmarshal([]byte(tc.Old), &a); err != nil { - t.Fatalf(fmt.Sprintf("unable to unmarshal old json - %v", err)) + t.Fatalf("%v", fmt.Sprintf("unable to unmarshal old json - %v", err)) } if err := json.Unmarshal([]byte(tc.New), &b); err != nil { - t.Fatalf(fmt.Sprintf("unable to unmarshal new json - %v", err)) + t.Fatalf("%v", fmt.Sprintf("unable to unmarshal new json - %v", err)) } if bigQueryTableSchemaDiffSuppress("schema", tc.Old, tc.New, nil) != tc.ExpectDiffSuppress { t.Fatalf("bad: %s, %q => %q expect DiffSuppress to return %t", tn, tc.Old, tc.New, tc.ExpectDiffSuppress) diff --git a/website/docs/r/bigquery_table.html.markdown b/website/docs/r/bigquery_table.html.markdown index 0a4893bed88..6b93aca16d5 100644 --- a/website/docs/r/bigquery_table.html.markdown +++ b/website/docs/r/bigquery_table.html.markdown @@ -143,6 +143,11 @@ The following arguments are supported: with `external_data_configuration.schema`. Otherwise, schemas must be specified with this top-level field. +* `schema_foreign_type_info` - (Optional, [Beta] +(https://terraform.io/docs/providers/google/guides/provider_versions.html)) + Specifies metadata of the foreign data type definition in field schema. + Structure is [documented below](#nested_schema_foreign_type_info). + * `time_partitioning` - (Optional) If specified, configures time-based partitioning for this table. Structure is [documented below](#nested_time_partitioning). @@ -374,6 +379,12 @@ The following arguments are supported: * `enable_list_inference` - (Optional) Indicates whether to use schema inference specifically for Parquet LIST logical type. +The `schema_foreign_type_info` block supports: + +* `type_system` - (Required, [Beta] +(https://terraform.io/docs/providers/google/guides/provider_versions.html)) + Specifies the system which defines the foreign data type. + The `time_partitioning` block supports: * `expiration_ms` - (Optional) Number of milliseconds for which to keep the