Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BigQuery Clustering (#1852) #2600

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions google/image_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,12 @@ func testAccCheckComputeImageResolution(n string) resource.TestCheckFunc {

"global/images/" + name: "global/images/" + name,
"global/images/family/" + family: "global/images/family/" + family,
name: "global/images/" + name,
family: "global/images/family/" + family,
"family/" + family: "global/images/family/" + family,
project + "/" + name: "projects/" + project + "/global/images/" + name,
project + "/" + family: "projects/" + project + "/global/images/family/" + family,
link: link,
name: "global/images/" + name,
family: "global/images/family/" + family,
"family/" + family: "global/images/family/" + family,
project + "/" + name: "projects/" + project + "/global/images/" + name,
project + "/" + family: "projects/" + project + "/global/images/family/" + family,
link: link,
}

for input, expectation := range images {
Expand Down
19 changes: 19 additions & 0 deletions google/resource_bigquery_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,14 @@ func resourceBigQueryTable() *schema.Resource {
},
},

// Clustering: [Optional] Specifies which columns to cluster this table by.
"clustering": &schema.Schema{
Type: schema.TypeList,
Optional: true,
ForceNew: true,
Elem: &schema.Schema{Type: schema.TypeString},
},

// CreationTime: [Output-only] The time when this table was created, in
// milliseconds since the epoch.
"creation_time": {
Expand Down Expand Up @@ -277,6 +285,13 @@ func resourceTable(d *schema.ResourceData, meta interface{}) (*bigquery.Table, e
table.TimePartitioning = expandTimePartitioning(v)
}

if v, ok := d.GetOk("clustering"); ok {
table.Clustering = &bigquery.Clustering{
Fields: convertStringArr(v.([]interface{})),
ForceSendFields: []string{"Fields"},
}
}

return table, nil
}

Expand Down Expand Up @@ -347,6 +362,10 @@ func resourceBigQueryTableRead(d *schema.ResourceData, meta interface{}) error {
}
}

if res.Clustering != nil {
d.Set("clustering", res.Clustering.Fields)
}

if res.Schema != nil {
schema, err := flattenSchema(res.Schema)
if err != nil {
Expand Down
10 changes: 8 additions & 2 deletions google/resource_bigquery_table_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,14 +123,20 @@ resource "google_bigquery_table" "test" {
time_partitioning {
type = "DAY"
field = "ts"
}
}

clustering = ["ts", "uuid"]

schema = <<EOH
[
{
"name": "ts",
"type": "TIMESTAMP"
},
},
{
"name": "uuid",
"type": "STRING"
},
{
"name": "city",
"type": "RECORD",
Expand Down
4 changes: 2 additions & 2 deletions google/resource_binaryauthorization_attestor.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,8 +284,8 @@ func flattenBinaryAuthorizationAttestorAttestationAuthorityNotePublicKeys(v inte
for _, raw := range l {
original := raw.(map[string]interface{})
transformed = append(transformed, map[string]interface{}{
"comment": flattenBinaryAuthorizationAttestorAttestationAuthorityNotePublicKeysComment(original["comment"]),
"id": flattenBinaryAuthorizationAttestorAttestationAuthorityNotePublicKeysId(original["id"]),
"comment": flattenBinaryAuthorizationAttestorAttestationAuthorityNotePublicKeysComment(original["comment"]),
"id": flattenBinaryAuthorizationAttestorAttestationAuthorityNotePublicKeysId(original["id"]),
"ascii_armored_pgp_public_key": flattenBinaryAuthorizationAttestorAttestationAuthorityNotePublicKeysAsciiArmoredPgpPublicKey(original["asciiArmoredPgpPublicKey"]),
})
}
Expand Down
24 changes: 12 additions & 12 deletions google/resource_compute_instance_migrate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ func TestAccComputeInstanceMigrateState_bootDisk(t *testing.T) {
"disk.0.device_name": "persistent-disk-0",
"disk.0.disk_encryption_key_raw": "encrypt-key",
"disk.0.disk_encryption_key_sha256": "encrypt-key-sha",
"zone": zone,
"zone": zone,
}
expected := map[string]string{
"boot_disk.#": "1",
Expand Down Expand Up @@ -223,7 +223,7 @@ func TestAccComputeInstanceMigrateState_v4FixBootDisk(t *testing.T) {
"disk.0.device_name": "persistent-disk-0",
"disk.0.disk_encryption_key_raw": "encrypt-key",
"disk.0.disk_encryption_key_sha256": "encrypt-key-sha",
"zone": zone,
"zone": zone,
}
expected := map[string]string{
"boot_disk.#": "1",
Expand Down Expand Up @@ -305,7 +305,7 @@ func TestAccComputeInstanceMigrateState_attachedDiskFromSource(t *testing.T) {
"disk.0.device_name": "persistent-disk-1",
"disk.0.disk_encryption_key_raw": "encrypt-key",
"disk.0.disk_encryption_key_sha256": "encrypt-key-sha",
"zone": zone,
"zone": zone,
}
expected := map[string]string{
"boot_disk.#": "1",
Expand Down Expand Up @@ -385,7 +385,7 @@ func TestAccComputeInstanceMigrateState_v4FixAttachedDiskFromSource(t *testing.T
"disk.0.device_name": "persistent-disk-1",
"disk.0.disk_encryption_key_raw": "encrypt-key",
"disk.0.disk_encryption_key_sha256": "encrypt-key-sha",
"zone": zone,
"zone": zone,
}
expected := map[string]string{
"boot_disk.#": "1",
Expand Down Expand Up @@ -452,7 +452,7 @@ func TestAccComputeInstanceMigrateState_attachedDiskFromEncryptionKey(t *testing
"disk.0.image": "projects/debian-cloud/global/images/family/debian-9",
"disk.0.disk_encryption_key_raw": "SGVsbG8gZnJvbSBHb29nbGUgQ2xvdWQgUGxhdGZvcm0=",
"disk.0.disk_encryption_key_sha256": "esTuF7d4eatX4cnc4JsiEiaI+Rff78JgPhA/v1zxX9E=",
"zone": zone,
"zone": zone,
}
expected := map[string]string{
"boot_disk.#": "1",
Expand Down Expand Up @@ -520,7 +520,7 @@ func TestAccComputeInstanceMigrateState_v4FixAttachedDiskFromEncryptionKey(t *te
"disk.0.image": "projects/debian-cloud/global/images/family/debian-9",
"disk.0.disk_encryption_key_raw": "SGVsbG8gZnJvbSBHb29nbGUgQ2xvdWQgUGxhdGZvcm0=",
"disk.0.disk_encryption_key_sha256": "esTuF7d4eatX4cnc4JsiEiaI+Rff78JgPhA/v1zxX9E=",
"zone": zone,
"zone": zone,
}
expected := map[string]string{
"boot_disk.#": "1",
Expand Down Expand Up @@ -600,8 +600,8 @@ func TestAccComputeInstanceMigrateState_attachedDiskFromAutoDeleteAndImage(t *te
"attached_disk.0.device_name": "persistent-disk-2",
"attached_disk.1.source": "https://www.googleapis.com/compute/v1/projects/" + config.Project + "/zones/" + zone + "/disks/" + instanceName + "-1",
"attached_disk.1.device_name": "persistent-disk-1",
"zone": zone,
"create_timeout": "4",
"zone": zone,
"create_timeout": "4",
}

runInstanceMigrateTest(t, instanceName, "migrate disk to attached disk", 2 /* state version */, attributes, expected, config)
Expand Down Expand Up @@ -672,7 +672,7 @@ func TestAccComputeInstanceMigrateState_v4FixAttachedDiskFromAutoDeleteAndImage(
"attached_disk.0.device_name": "persistent-disk-2",
"attached_disk.1.source": "https://www.googleapis.com/compute/v1/projects/" + config.Project + "/zones/" + zone + "/disks/" + instanceName + "-1",
"attached_disk.1.device_name": "persistent-disk-1",
"zone": zone,
"zone": zone,
}

runInstanceMigrateTest(t, instanceName, "migrate disk to attached disk", 4 /* state version */, attributes, expected, config)
Expand Down Expand Up @@ -735,8 +735,8 @@ func TestAccComputeInstanceMigrateState_scratchDisk(t *testing.T) {
"boot_disk.#": "1",
"scratch_disk.#": "1",
"scratch_disk.0.interface": "SCSI",
"zone": zone,
"create_timeout": "4",
"zone": zone,
"create_timeout": "4",
}

runInstanceMigrateTest(t, instanceName, "migrate disk to scratch disk", 2 /* state version */, attributes, expected, config)
Expand Down Expand Up @@ -799,7 +799,7 @@ func TestAccComputeInstanceMigrateState_v4FixScratchDisk(t *testing.T) {
"boot_disk.#": "1",
"scratch_disk.#": "1",
"scratch_disk.0.interface": "SCSI",
"zone": zone,
"zone": zone,
}

runInstanceMigrateTest(t, instanceName, "migrate disk to scratch disk", 4 /* state version */, attributes, expected, config)
Expand Down
2 changes: 1 addition & 1 deletion google/resource_compute_network.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func resourceComputeNetworkCreate(d *schema.ResourceData, meta interface{}) erro

// Build the network parameter
network := &compute.Network{
Name: d.Get("name").(string),
Name: d.Get("name").(string),
AutoCreateSubnetworks: autoCreateSubnetworks,
Description: d.Get("description").(string),
}
Expand Down
2 changes: 1 addition & 1 deletion google/resource_sql_database_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -1151,7 +1151,7 @@ func flattenAuthorizedNetworks(entries []*sqladmin.AclEntry) interface{} {
func flattenLocationPreference(locationPreference *sqladmin.LocationPreference) interface{} {
data := map[string]interface{}{
"follow_gae_application": locationPreference.FollowGaeApplication,
"zone": locationPreference.Zone,
"zone": locationPreference.Zone,
}

return []map[string]interface{}{data}
Expand Down
6 changes: 3 additions & 3 deletions google/validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,15 +248,15 @@ func TestOrEmpty(t *testing.T) {
ExpectValidationErrors bool
}{
"accept empty value": {
Value: "",
Value: "",
ExpectValidationErrors: false,
},
"non empty value is accepted when valid": {
Value: "valid",
Value: "valid",
ExpectValidationErrors: false,
},
"non empty value is rejected if invalid": {
Value: "invalid",
Value: "invalid",
ExpectValidationErrors: true,
},
}
Expand Down
Loading