From 4c98bad946d813ee62f51d3f12f2580202fe8130 Mon Sep 17 00:00:00 2001 From: The Magician Date: Fri, 22 Mar 2024 15:31:16 -0700 Subject: [PATCH] bq table - add geojson support (#10215) (#7138) * bq table - add geojson support * bq table - add geojson support * CR comments [upstream:6c2de90ffeeb029b6c3a49bfdf52540e010b155c] Signed-off-by: Modular Magician --- .changelog/10215.txt | 3 +++ .../services/bigquery/resource_bigquery_table.go | 15 +++++++++++++++ .../bigquery/resource_bigquery_table_test.go | 2 ++ website/docs/r/bigquery_table.html.markdown | 2 ++ 4 files changed, 22 insertions(+) create mode 100644 .changelog/10215.txt diff --git a/.changelog/10215.txt b/.changelog/10215.txt new file mode 100644 index 0000000000..59431cc78c --- /dev/null +++ b/.changelog/10215.txt @@ -0,0 +1,3 @@ +```release-note:enhancement +bigquery_table - add support for `external_data_configuration.json_extension` +``` \ No newline at end of file diff --git a/google-beta/services/bigquery/resource_bigquery_table.go b/google-beta/services/bigquery/resource_bigquery_table.go index 8d7fb5bed4..b1a4a5f412 100644 --- a/google-beta/services/bigquery/resource_bigquery_table.go +++ b/google-beta/services/bigquery/resource_bigquery_table.go @@ -624,6 +624,13 @@ func ResourceBigQueryTable() *schema.Resource { }, }, + "json_extension": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringInSlice([]string{"GEOJSON"}, false), + Description: `Load option to be used together with sourceFormat newline-delimited JSON to indicate that a variant of JSON is being loaded. To load newline-delimited GeoJSON, specify GEOJSON (and sourceFormat must be set to NEWLINE_DELIMITED_JSON).`, + }, + "parquet_options": { Type: schema.TypeList, Optional: true, @@ -1786,6 +1793,10 @@ func expandExternalDataConfiguration(cfg interface{}) (*bigquery.ExternalDataCon edc.Compression = v.(string) } + if v, ok := raw["json_extension"]; ok { + edc.JsonExtension = v.(string) + } + if v, ok := raw["csv_options"]; ok { edc.CsvOptions = expandCsvOptions(v) } @@ -1853,6 +1864,10 @@ func flattenExternalDataConfiguration(edc *bigquery.ExternalDataConfiguration) ( result["compression"] = edc.Compression } + if edc.JsonExtension != "" { + result["json_extension"] = edc.JsonExtension + } + if edc.CsvOptions != nil { result["csv_options"] = flattenCsvOptions(edc.CsvOptions) } diff --git a/google-beta/services/bigquery/resource_bigquery_table_test.go b/google-beta/services/bigquery/resource_bigquery_table_test.go index 1f22989cfa..3ccd89ce02 100644 --- a/google-beta/services/bigquery/resource_bigquery_table_test.go +++ b/google-beta/services/bigquery/resource_bigquery_table_test.go @@ -2955,6 +2955,8 @@ resource "google_bigquery_table" "test" { encoding = "%s" } + json_extension = "GEOJSON" + hive_partitioning_options { mode = "CUSTOM" source_uri_prefix = "gs://${google_storage_bucket.test.name}/{key1:STRING}" diff --git a/website/docs/r/bigquery_table.html.markdown b/website/docs/r/bigquery_table.html.markdown index 525f395d8a..dc0c5df595 100644 --- a/website/docs/r/bigquery_table.html.markdown +++ b/website/docs/r/bigquery_table.html.markdown @@ -190,6 +190,8 @@ in Terraform state, a `terraform destroy` or `terraform apply` that would delete * `json_options` (Optional) - Additional properties to set if `source_format` is set to "JSON". Structure is [documented below](#nested_json_options). +* `json_extension` (Optional) - Used to indicate that a JSON variant, rather than normal JSON, is being used as the sourceFormat. This should only be used in combination with the `JSON` source format. Valid values are: `GEOJSON`. + * `parquet_options` (Optional) - Additional properties to set if `source_format` is set to "PARQUET". Structure is [documented below](#nested_parquet_options).