diff --git a/.changelog/7433.txt b/.changelog/7433.txt new file mode 100644 index 00000000000..d62dcb903da --- /dev/null +++ b/.changelog/7433.txt @@ -0,0 +1,3 @@ +```release-note:bug +bigquery: fixed a permadiff when `friendly_name` is removed from `google_bigquery_dataset` +``` diff --git a/google/resource_big_query_dataset_test.go b/google/resource_big_query_dataset_test.go index e083807fd4b..8c36e10fd47 100644 --- a/google/resource_big_query_dataset_test.go +++ b/google/resource_big_query_dataset_test.go @@ -35,6 +35,14 @@ func TestAccBigQueryDataset_basic(t *testing.T) { ImportState: true, ImportStateVerify: true, }, + { + Config: testAccBigQueryDatasetUpdated2(datasetID), + }, + { + ResourceName: "google_bigquery_dataset.test", + ImportState: true, + ImportStateVerify: true, + }, }, }) } @@ -212,6 +220,24 @@ resource "google_bigquery_dataset" "test" { `, datasetID) } +func testAccBigQueryDatasetUpdated2(datasetID string) string { + return fmt.Sprintf(` +resource "google_bigquery_dataset" "test" { + dataset_id = "%s" + # friendly_name = "bar" + description = "This is a bar description" + location = "EU" + default_partition_expiration_ms = 7200000 + default_table_expiration_ms = 7200000 + + labels = { + env = "bar" + default_table_expiration_ms = 7200000 + } +} +`, datasetID) +} + func testAccBigQueryDatasetDeleteContents(datasetID string) string { return fmt.Sprintf(` resource "google_bigquery_dataset" "contents_test" { diff --git a/google/resource_bigquery_dataset.go b/google/resource_bigquery_dataset.go index 83aaf87c00f..8971f608dd5 100644 --- a/google/resource_bigquery_dataset.go +++ b/google/resource_bigquery_dataset.go @@ -424,7 +424,7 @@ func resourceBigQueryDatasetCreate(d *schema.ResourceData, meta interface{}) err friendlyNameProp, err := expandBigQueryDatasetFriendlyName(d.Get("friendly_name"), d, config) if err != nil { return err - } else if v, ok := d.GetOkExists("friendly_name"); !isEmptyValue(reflect.ValueOf(friendlyNameProp)) && (ok || !reflect.DeepEqual(v, friendlyNameProp)) { + } else if v, ok := d.GetOkExists("friendly_name"); ok || !reflect.DeepEqual(v, friendlyNameProp) { obj["friendlyName"] = friendlyNameProp } labelsProp, err := expandBigQueryDatasetLabels(d.Get("labels"), d, config) @@ -635,7 +635,7 @@ func resourceBigQueryDatasetUpdate(d *schema.ResourceData, meta interface{}) err friendlyNameProp, err := expandBigQueryDatasetFriendlyName(d.Get("friendly_name"), d, config) if err != nil { return err - } else if v, ok := d.GetOkExists("friendly_name"); !isEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, friendlyNameProp)) { + } else if v, ok := d.GetOkExists("friendly_name"); ok || !reflect.DeepEqual(v, friendlyNameProp) { obj["friendlyName"] = friendlyNameProp } labelsProp, err := expandBigQueryDatasetLabels(d.Get("labels"), d, config)