Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bq table - add geojson support #17663

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/10215.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
bigquery_table - add support for `external_data_configuration.json_extension`
```
15 changes: 15 additions & 0 deletions google/services/bigquery/resource_bigquery_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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)
}
Expand Down
2 changes: 2 additions & 0 deletions google/services/bigquery/resource_bigquery_table_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down
2 changes: 2 additions & 0 deletions website/docs/r/bigquery_table.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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).

Expand Down