Skip to content

Commit

Permalink
bq table - add geojson support (GoogleCloudPlatform#10215)
Browse files Browse the repository at this point in the history
* bq table - add geojson support

* bq table - add geojson support

* CR comments
  • Loading branch information
DrFaust92 authored Mar 22, 2024
1 parent 50a4202 commit 6c2de90
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,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 @@ -1784,6 +1791,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 @@ -1851,6 +1862,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
Original file line number Diff line number Diff line change
Expand Up @@ -2953,6 +2953,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
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

0 comments on commit 6c2de90

Please sign in to comment.