Skip to content

Commit

Permalink
Add storage_billing_model for BigQuery datasets (GoogleCloudPlatform#…
Browse files Browse the repository at this point in the history
…7615)

* [Waiting for the feature to go GA] Add storage_billing_model for BigQuery datasets

* updating precheck test function name

---------

Co-authored-by: Luca Prete <lucaprete@google.com>
  • Loading branch information
2 people authored and hao-nan-li committed Jul 27, 2023
1 parent 13241a8 commit fa19dc2
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
9 changes: 9 additions & 0 deletions mmv1/products/bigquery/Dataset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -356,3 +356,12 @@ properties:
- 'und:ci': undetermined locale, case insensitive.
- '': empty string. Default to case-sensitive behavior.
default_from_api: true
- !ruby/object:Api::Type::String
name: 'storageBillingModel'
description: |
Specifies the storage billing model for the dataset.
Set this flag value to LOGICAL to use logical bytes for storage billing,
or to PHYSICAL to use physical bytes instead.
LOGICAL is the default if this flag isn't specified.
default_from_api: true
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,28 @@ func TestAccBigQueryDataset_cmek(t *testing.T) {
})
}

func TestAccBigQueryDataset_storageBillModel(t *testing.T) {
t.Parallel()

datasetID := fmt.Sprintf("tf_test_%s", RandString(t, 10))

VcrTest(t, resource.TestCase{
PreCheck: func() { acctest.AccTestPreCheck(t) },
ProtoV5ProviderFactories: ProtoV5ProviderFactories(t),
CheckDestroy: testAccCheckBigQueryDatasetDestroyProducer(t),
Steps: []resource.TestStep{
{
Config: testAccBigQueryDatasetStorageBillingModel(datasetID),
},
{
ResourceName: "google_bigquery_dataset.test",
ImportState: true,
ImportStateVerify: true,
},
},
})
}

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 @@ -389,3 +411,22 @@ resource "google_bigquery_dataset" "test" {
}
`, pid, datasetID, kmsKey)
}

func testAccBigQueryDatasetStorageBillingModel(datasetID string) string {
return fmt.Sprintf(`
resource "google_bigquery_dataset" "test" {
dataset_id = "%s"
friendly_name = "foo"
description = "This is a foo description"
location = "EU"
default_partition_expiration_ms = 3600000
default_table_expiration_ms = 3600000
storage_billing_model = "PHYSICAL"
labels = {
env = "foo"
default_table_expiration_ms = 3600000
}
}
`, datasetID)
}

0 comments on commit fa19dc2

Please sign in to comment.