Skip to content

Commit 63da718

Browse files
Adding support for Routines in Listings (#14472) (#23559)
[upstream:487b6c8093e6da5b2658a82ee59ac2f544d0224e] Signed-off-by: Modular Magician <[email protected]>
1 parent 58443d3 commit 63da718

File tree

3 files changed

+76
-0
lines changed

3 files changed

+76
-0
lines changed

.changelog/14472.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:enhancement
2+
bigqueryanalyticshub: added `routine` field to `google_bigquery_analytics_hub_listing` resource (beta)
3+
```

google/services/bigqueryanalyticshub/resource_bigquery_analytics_hub_listing.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ func ResourceBigqueryAnalyticsHubListing() *schema.Resource {
107107
ForceNew: true,
108108
DiffSuppressFunc: tpgresource.ProjectNumberDiffSuppress,
109109
Description: `Format: For table: projects/{projectId}/datasets/{datasetId}/tables/{tableId} Example:"projects/test_project/datasets/test_dataset/tables/test_table"`,
110+
ExactlyOneOf: []string{},
110111
},
111112
},
112113
},

website/docs/r/bigquery_analytics_hub_listing.html.markdown

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,74 @@ resource "google_bigquery_analytics_hub_listing" "listing" {
247247
}
248248
}
249249
```
250+
<div class = "oics-button" style="float: right; margin: 0 0 -15px">
251+
<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_analyticshub_listing_dcr_routine&open_in_editor=main.tf" target="_blank">
252+
<img alt="Open in Cloud Shell" src="//gstatic.com/cloudssh/images/open-btn.svg" style="max-height: 44px; margin: 32px auto; max-width: 100%;">
253+
</a>
254+
</div>
255+
## Example Usage - Bigquery Analyticshub Listing Dcr Routine
256+
257+
258+
```hcl
259+
resource "google_bigquery_analytics_hub_data_exchange" "dcr_data_exchange_example" {
260+
provider = google-beta
261+
location = "us"
262+
data_exchange_id = "tf_test_data_exchange"
263+
display_name = "tf_test_data_exchange"
264+
description = "Example for listing with routine"
265+
sharing_environment_config {
266+
dcr_exchange_config {}
267+
}
268+
}
269+
270+
resource "google_bigquery_dataset" "listing" {
271+
provider = google-beta
272+
dataset_id = "tf_test_dataset"
273+
friendly_name = "tf_test_dataset"
274+
description = "Example for listing with routine"
275+
location = "us"
276+
}
277+
278+
resource "google_bigquery_routine" "listing" {
279+
provider = google-beta
280+
dataset_id = google_bigquery_dataset.listing.dataset_id
281+
routine_id = "tf_test_routine"
282+
routine_type = "TABLE_VALUED_FUNCTION"
283+
language = "SQL"
284+
description = "A DCR routine example."
285+
definition_body = <<-EOS
286+
SELECT 1 + value AS value
287+
EOS
288+
arguments {
289+
name = "value"
290+
argument_kind = "FIXED_TYPE"
291+
data_type = jsonencode({ "typeKind" : "INT64" })
292+
}
293+
return_table_type = jsonencode({
294+
"columns" : [
295+
{ "name" : "value", "type" : { "typeKind" : "INT64" } },
296+
]
297+
})
298+
}
299+
300+
resource "google_bigquery_analytics_hub_listing" "listing" {
301+
provider = google-beta
302+
location = "US"
303+
data_exchange_id = google_bigquery_analytics_hub_data_exchange.dcr_data_exchange_example.data_exchange_id
304+
listing_id = "tf_test_listing_routine"
305+
display_name = "tf_test_listing_routine"
306+
description = "Example for listing with routine"
307+
bigquery_dataset {
308+
dataset = google_bigquery_dataset.listing.id
309+
selected_resources {
310+
routine = google_bigquery_routine.listing.id
311+
}
312+
}
313+
restricted_export_config {
314+
enabled = true
315+
}
316+
}
317+
```
250318

251319
## Argument Reference
252320

@@ -366,6 +434,10 @@ The following arguments are supported:
366434
(Optional)
367435
Format: For table: projects/{projectId}/datasets/{datasetId}/tables/{tableId} Example:"projects/test_project/datasets/test_dataset/tables/test_table"
368436

437+
* `routine` -
438+
(Optional, [Beta](https://terraform.io/docs/providers/google/guides/provider_versions.html))
439+
Format: For routine: projects/{projectId}/datasets/{datasetId}/routines/{routineId} Example:"projects/test_project/datasets/test_dataset/routines/test_routine"
440+
369441
<a name="nested_pubsub_topic"></a>The `pubsub_topic` block supports:
370442

371443
* `topic` -

0 commit comments

Comments
 (0)