Skip to content

Commit 0f2b2c2

Browse files
nevzhengabd-goog
authored andcommitted
# Add: biglake_configuration to bigquery_table (GoogleCloudPlatform#11724)
1 parent 9dbae65 commit 0f2b2c2

File tree

3 files changed

+125
-0
lines changed

3 files changed

+125
-0
lines changed

mmv1/third_party/terraform/services/bigquery/resource_bigquery_table.go

+47
Original file line numberDiff line numberDiff line change
@@ -890,6 +890,53 @@ func ResourceBigQueryTable() *schema.Resource {
890890
},
891891
},
892892

893+
// BiglakeConfiguration [Optional] Specifies the configuration of a BigLake managed table.
894+
"biglake_configuration": {
895+
Type: schema.TypeList,
896+
Optional: true,
897+
MaxItems: 1,
898+
ForceNew: true,
899+
Description: "Specifies the configuration of a BigLake managed table.",
900+
Elem: &schema.Resource{
901+
Schema: map[string]*schema.Schema{
902+
// ConnectionId: [Required] The connection specifying the credentials to be used to read
903+
// and write to external storage, such as Cloud Storage. The connection_id can have the
904+
// form "<project\_id>.<location\_id>.<connection\_id>" or
905+
// "projects/<project\_id>/locations/<location\_id>/connections/<connection\_id>".
906+
"connection_id": {
907+
Type: schema.TypeString,
908+
Required: true,
909+
DiffSuppressFunc: bigQueryTableConnectionIdSuppress,
910+
ForceNew: true,
911+
Description: `The connection specifying the credentials to be used to read and write to external storage, such as Cloud Storage. The connection_id can have the form "<project\_id>.<location\_id>.<connection\_id>" or "projects/<project\_id>/locations/<location\_id>/connections/<connection\_id>".`,
912+
},
913+
// StorageUri: [Required] The fully qualified location prefix of the external folder where
914+
// table data is stored. The '*' wildcard character is not allowed.
915+
// The URI should be in the format "gs://bucket/path_to_table/"
916+
"storage_uri": {
917+
Type: schema.TypeString,
918+
Required: true,
919+
ForceNew: true,
920+
Description: `The fully qualified location prefix of the external folder where table data is stored. The '*' wildcard character is not allowed. The URI should be in the format "gs://bucket/path_to_table/"`,
921+
},
922+
// FileFormat: [Required] The file format the data is stored in.
923+
"file_format": {
924+
Type: schema.TypeString,
925+
Required: true,
926+
ForceNew: true,
927+
Description: "The file format the data is stored in.",
928+
},
929+
// TableFormat: [Required]
930+
"table_format": {
931+
Type: schema.TypeString,
932+
Required: true,
933+
ForceNew: true,
934+
Description: "The table format the metadata only snapshots are stored in.",
935+
},
936+
},
937+
},
938+
},
939+
893940
// FriendlyName: [Optional] A descriptive name for this table.
894941
"friendly_name": {
895942
Type: schema.TypeString,

mmv1/third_party/terraform/services/bigquery/resource_bigquery_table_test.go

+62
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,68 @@ func TestAccBigQueryTable_AvroPartitioning(t *testing.T) {
279279
})
280280
}
281281

282+
func TestAccBigQueryBigLakeManagedTable(t *testing.T) {
283+
t.Parallel()
284+
bucketName := acctest.TestBucketName(t)
285+
connectionID := fmt.Sprintf("tf_test_%s", acctest.RandString(t, 10))
286+
287+
datasetID := fmt.Sprintf("tf_test_%s", acctest.RandString(t, 10))
288+
tableID := fmt.Sprintf("tf_test_%s", acctest.RandString(t, 10))
289+
290+
acctest.VcrTest(t, resource.TestCase{
291+
PreCheck: func() { acctest.AccTestPreCheck(t) },
292+
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
293+
CheckDestroy: testAccCheckBigQueryTableDestroyProducer(t),
294+
Steps: []resource.TestStep{
295+
{
296+
Config: testAccBigLakeManagedTable(bucketName, connectionID, datasetID, tableID, TEST_SIMPLE_CSV_SCHEMA),
297+
},
298+
},
299+
})
300+
}
301+
302+
func testAccBigLakeManagedTable(bucketName, connectionID, datasetID, tableID, schema string) string {
303+
return fmt.Sprintf(`
304+
data "google_project" "project" {}
305+
resource "google_storage_bucket" "test" {
306+
name = "%s"
307+
location = "US"
308+
force_destroy = true
309+
uniform_bucket_level_access = true
310+
}
311+
resource "google_bigquery_connection" "test" {
312+
connection_id = "%s"
313+
location = "US"
314+
cloud_resource {}
315+
}
316+
resource "google_project_iam_member" "test" {
317+
role = "roles/storage.objectViewer"
318+
project = data.google_project.project.id
319+
member = "serviceAccount:${google_bigquery_connection.test.cloud_resource[0].service_account_id}"
320+
}
321+
resource "google_bigquery_dataset" "test" {
322+
dataset_id = "%s"
323+
}
324+
resource "google_bigquery_table" "test" {
325+
deletion_protection = false
326+
table_id = "%s"
327+
dataset_id = google_bigquery_dataset.test.dataset_id
328+
biglake_configuration {
329+
connection_id = google_bigquery_connection.test.name
330+
storage_uri = "gs://${google_storage_bucket.test.name}/data/"
331+
file_format = "PARQUET"
332+
table_format = "ICEBERG"
333+
}
334+
335+
schema = jsonencode(%s)
336+
337+
depends_on = [
338+
google_project_iam_member.test
339+
]
340+
}
341+
`, bucketName, connectionID, datasetID, tableID, schema)
342+
}
343+
282344
func TestAccBigQueryExternalDataTable_json(t *testing.T) {
283345
t.Parallel()
284346
bucketName := acctest.TestBucketName(t)

mmv1/third_party/terraform/website/docs/r/bigquery_table.html.markdown

+16
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ The following arguments are supported:
104104
By defining these properties, the data source can then be queried as
105105
if it were a standard BigQuery table. Structure is [documented below](#nested_external_data_configuration).
106106

107+
* `biglake_configuration` - (Optional) Specifies the configuration of a BigLake managed table. Structure is [documented below](#nested_biglake_configuration)
108+
107109
* `friendly_name` - (Optional) A descriptive name for the table.
108110

109111
* `max_staleness`: (Optional) The maximum staleness of data that could be
@@ -492,6 +494,20 @@ The following arguments are supported:
492494
* `replication_interval_ms` (Optional) - The interval at which the source
493495
materialized view is polled for updates. The default is 300000.
494496

497+
<a name="nested_biglake_configuration"></a>The `biglake_configuration` block supports:
498+
499+
* `connection_id` - (Required) The connection specifying the credentials to be used to
500+
read and write to external storage, such as Cloud Storage. The connection_id can
501+
have the form "&lt;project\_id&gt;.&lt;location\_id&gt;.&lt;connection\_id&gt;" or
502+
projects/&lt;project\_id&gt;/locations/&lt;location\_id&gt;/connections/&lt;connection\_id&gt;".
503+
504+
* `storage_uri` - (Required) The fully qualified location prefix of the external folder where table data
505+
is stored. The '*' wildcard character is not allowed. The URI should be in the format "gs://bucket/path_to_table/"
506+
507+
* `file_format` - (Required) The file format the table data is stored in.
508+
509+
* `table_format` - (Required) The table format the metadata only snapshots are stored in.
510+
495511
## Attributes Reference
496512

497513
In addition to the arguments listed above, the following computed attributes are

0 commit comments

Comments
 (0)