Skip to content

Commit

Permalink
Add external catalog dataset options to google_bigquery_dataset beta (h…
Browse files Browse the repository at this point in the history
…ashicorp#12113) (hashicorp#20097)

[upstream:eb942f6be819dcb43d40b1c707d2b00a28579c3e]

Signed-off-by: Modular Magician <[email protected]>
  • Loading branch information
modular-magician authored Oct 29, 2024
1 parent 8b193ee commit 5edfa01
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .changelog/12113.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
bigquery: added `external_catalog_dataset_options` fields to `google_bigquery_dataset` resource (beta)
```
41 changes: 40 additions & 1 deletion google/services/bigquery/resource_bigquery_dataset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,6 @@ func TestAccBigQueryDataset_bigqueryDatasetResourceTags_update(t *testing.T) {
},
})
}

func testAccAddTable(t *testing.T, datasetID string, tableID string) resource.TestCheckFunc {
// Not actually a check, but adds a table independently of terraform
return func(s *terraform.State) error {
Expand Down Expand Up @@ -866,3 +865,43 @@ resource "google_bigquery_dataset" "dataset" {
}
`, context)
}

func testAccBigQueryDataset_externalCatalogDatasetOptions_basic(context map[string]interface{}) string {
return acctest.Nprintf(`
resource "google_bigquery_dataset" "dataset" {
provider = google-beta
dataset_id = "dataset%{random_suffix}"
friendly_name = "test"
description = "This is a test description"
location = "US"
external_catalog_dataset_options {
parameters = {
"dataset_owner" = "dataset_owner"
}
default_storage_location_uri = "gs://test_dataset/tables"
}
}
`, context)
}

func testAccBigQueryDataset_externalCatalogDatasetOptions_update(context map[string]interface{}) string {
return acctest.Nprintf(`
resource "google_bigquery_dataset" "dataset" {
provider = google-beta
dataset_id = "dataset%{random_suffix}"
friendly_name = "test"
description = "This is a test description"
location = "US"
external_catalog_dataset_options {
parameters = {
"new_dataset_owner" = "new_dataset_owner"
}
default_storage_location_uri = "gs://new_test_dataset/new_tables"
}
}
`, context)
}
43 changes: 43 additions & 0 deletions website/docs/r/bigquery_dataset.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,31 @@ resource "google_bigquery_dataset" "dataset" {
}
}
```
<div class = "oics-button" style="float: right; margin: 0 0 -15px">
<a href="https://console.cloud.google.com/cloudshell/open?cloudshell_git_repo=https%3A%2F%2Fgithub.com%2Fterraform-google-modules%2Fdocs-examples.git&cloudshell_image=gcr.io%2Fcloudshell-images%2Fcloudshell%3Alatest&cloudshell_print=.%2Fmotd&cloudshell_tutorial=.%2Ftutorial.md&cloudshell_working_dir=bigquery_dataset_external_catalog_dataset_options&open_in_editor=main.tf" target="_blank">
<img alt="Open in Cloud Shell" src="//gstatic.com/cloudssh/images/open-btn.svg" style="max-height: 44px; margin: 32px auto; max-width: 100%;">
</a>
</div>
## Example Usage - Bigquery Dataset External Catalog Dataset Options


```hcl
resource "google_bigquery_dataset" "dataset" {
provider = google-beta
dataset_id = "example_dataset"
friendly_name = "test"
description = "This is a test description"
location = "US"
external_catalog_dataset_options {
parameters = {
"dataset_owner" = "test_dataset_owner"
}
default_storage_location_uri = "gs://test_dataset/tables"
}
}
```

## Argument Reference

Expand Down Expand Up @@ -346,6 +371,12 @@ The following arguments are supported:
to be the short name, for example "Production". See [Tag definitions](/iam/docs/tags-access-control#definitions)
for more details.

* `external_catalog_dataset_options` -
(Optional, [Beta](https://terraform.io/docs/providers/google/guides/provider_versions.html))
Options defining open source compatible datasets living in the BigQuery catalog. Contains
metadata of open source database, schema or namespace represented by the current dataset.
Structure is [documented below](#nested_external_catalog_dataset_options).

* `project` - (Optional) The ID of the project in which the resource belongs.
If it is not provided, the provider project is used.

Expand Down Expand Up @@ -489,6 +520,18 @@ destroying the resource will fail if tables are present.
BigQuery table. The BigQuery Service Account associated with your project requires
access to this encryption key.

<a name="nested_external_catalog_dataset_options"></a>The `external_catalog_dataset_options` block supports:

* `parameters` -
(Optional, [Beta](https://terraform.io/docs/providers/google/guides/provider_versions.html))
A map of key value pairs defining the parameters and properties of the open source schema.
Maximum size of 2Mib.

* `default_storage_location_uri` -
(Optional, [Beta](https://terraform.io/docs/providers/google/guides/provider_versions.html))
The storage location URI for all tables in the dataset. Equivalent to hive metastore's
database locationUri. Maximum length of 1024 characters.

## Attributes Reference

In addition to the arguments listed above, the following computed attributes are exported:
Expand Down

0 comments on commit 5edfa01

Please sign in to comment.