Skip to content

Commit

Permalink
Add foreign type info and definition to google_bigquery_table beta (#…
Browse files Browse the repository at this point in the history
…12659)

[upstream:b387b3600d42dc033ad824a194e78ff2dc4973ab]

Signed-off-by: Modular Magician <[email protected]>
  • Loading branch information
modular-magician committed Jan 23, 2025
1 parent 19daf0c commit 7ea3a34
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
3 changes: 3 additions & 0 deletions .changelog/12659.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
bigquery: added `schema_foreign_type_info` field and related schema handling to `google_bigquery_table` resource (beta)
```
3 changes: 0 additions & 3 deletions google/services/bigquery/resource_bigquery_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
11 changes: 11 additions & 0 deletions website/docs/r/bigquery_table.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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).

Expand Down Expand Up @@ -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.

<a name="nested_schema_foreign_type_info"></a>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.

<a name="nested_time_partitioning"></a>The `time_partitioning` block supports:

* `expiration_ms` - (Optional) Number of milliseconds for which to keep the
Expand Down

0 comments on commit 7ea3a34

Please sign in to comment.