Skip to content

Commit

Permalink
send two false fields (#6566) (#4711)
Browse files Browse the repository at this point in the history
* send two false fields

* updates

Co-authored-by: Edward Sun <sunedward@google.com>
Signed-off-by: Modular Magician <magic-modules@google.com>

Signed-off-by: Modular Magician <magic-modules@google.com>
Co-authored-by: Edward Sun <sunedward@google.com>
  • Loading branch information
modular-magician and Edward Sun authored Sep 22, 2022
1 parent 157bd14 commit b3287ba
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .changelog/6566.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
compute: send `allow_quoted_newlines` and `allow_jagged_rows` when they are set to false on `google_bigquery_table`
```
2 changes: 2 additions & 0 deletions google-beta/resource_bigquery_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -1398,10 +1398,12 @@ func expandCsvOptions(configured interface{}) *bigquery.CsvOptions {

if v, ok := raw["allow_jagged_rows"]; ok {
opts.AllowJaggedRows = v.(bool)
opts.ForceSendFields = append(opts.ForceSendFields, "allow_jagged_rows")
}

if v, ok := raw["allow_quoted_newlines"]; ok {
opts.AllowQuotedNewlines = v.(bool)
opts.ForceSendFields = append(opts.ForceSendFields, "allow_quoted_newlines")
}

if v, ok := raw["encoding"]; ok {
Expand Down
77 changes: 77 additions & 0 deletions google-beta/resource_bigquery_table_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -916,6 +916,42 @@ func TestAccBigQueryExternalDataTable_CSV_WithSchema_UpdateToConnectionID(t *tes
})
}

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

bucketName := testBucketName(t)
objectName := fmt.Sprintf("tf_test_%s.csv", randString(t, 10))

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

vcrTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckBigQueryTableDestroyProducer(t),
Steps: []resource.TestStep{
{
Config: testAccBigQueryTableFromGCSWithSchema(datasetID, tableID, bucketName, objectName, TEST_SIMPLE_CSV, TEST_SIMPLE_CSV_SCHEMA),
},
{
ResourceName: "google_bigquery_table.test",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"etag", "last_modified_time", "deletion_protection"},
},
{
Config: testAccBigQueryTableFromGCSWithSchema_UpdatAllowQuotedNewlines(datasetID, tableID, bucketName, objectName, TEST_SIMPLE_CSV, TEST_SIMPLE_CSV_SCHEMA),
},
{
ResourceName: "google_bigquery_table.test",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"etag", "last_modified_time", "deletion_protection"},
},
},
})
}

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

Expand Down Expand Up @@ -2034,6 +2070,47 @@ resource "google_bigquery_table" "test" {
`, datasetID, bucketName, objectName, content, tableID, schema)
}

func testAccBigQueryTableFromGCSWithSchema_UpdatAllowQuotedNewlines(datasetID, tableID, bucketName, objectName, content, schema string) string {
return fmt.Sprintf(`
resource "google_bigquery_dataset" "test" {
dataset_id = "%s"
}
resource "google_storage_bucket" "test" {
name = "%s"
location = "US"
force_destroy = true
}
resource "google_storage_bucket_object" "test" {
name = "%s"
content = <<EOF
%s
EOF
bucket = google_storage_bucket.test.name
}
resource "google_bigquery_table" "test" {
deletion_protection = false
table_id = "%s"
dataset_id = google_bigquery_dataset.test.dataset_id
schema = <<EOF
%s
EOF
external_data_configuration {
autodetect = false
source_format = "CSV"
csv_options {
encoding = "UTF-8"
quote = ""
allow_quoted_newlines = "false"
allow_jagged_rows = "false"
}
source_uris = [
"gs://${google_storage_bucket.test.name}/${google_storage_bucket_object.test.name}",
]
}
}
`, datasetID, bucketName, objectName, content, tableID, schema)
}

func testAccBigQueryTableFromBigtable(context map[string]interface{}) string {
return Nprintf(`
resource "google_bigtable_instance" "instance" {
Expand Down

0 comments on commit b3287ba

Please sign in to comment.