From efee709870e284aaa65f3488bf99e5c48d09e1fe Mon Sep 17 00:00:00 2001 From: Seth Hollyman Date: Thu, 15 Apr 2021 18:43:13 +0000 Subject: [PATCH 1/3] feat(bigquery): support mutable clustering configuration internal issue 185493320 --- bigquery/table.go | 7 +++++++ bigquery/table_test.go | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/bigquery/table.go b/bigquery/table.go index bc969227c7b..25ea4511376 100644 --- a/bigquery/table.go +++ b/bigquery/table.go @@ -681,6 +681,10 @@ func (tm *TableMetadataToUpdate) toBQ() (*bq.Table, error) { t.EncryptionConfiguration = tm.EncryptionConfig.toBQ() } + if tm.Clustering != nil { + t.Clustering = tm.Clustering.toBQ() + } + if !validExpiration(tm.ExpirationTime) { return nil, invalidTimeError(tm.ExpirationTime) } @@ -750,6 +754,9 @@ type TableMetadataToUpdate struct { // When updating a schema, you can add columns but not remove them. Schema Schema + // The table's clustering configuration. + Clustering *Clustering + // The table's encryption configuration. EncryptionConfig *EncryptionConfig diff --git a/bigquery/table_test.go b/bigquery/table_test.go index cc5ed3007b3..1ce48fdfca8 100644 --- a/bigquery/table_test.go +++ b/bigquery/table_test.go @@ -399,6 +399,12 @@ func TestTableMetadataToUpdateToBQ(t *testing.T) { ForceSendFields: []string{"RequirePartitionFilter"}, }, }, + { + tm: TableMetadataToUpdate{Clustering: &Clustering{Fields: []string{"foo", "bar"}}}, + want: &bq.Table{ + Clustering: &bq.Clustering{Fields: []string{"foo", "bar"}}, + }, + }, } { got, _ := test.tm.toBQ() if !testutil.Equal(got, test.want) { From 1713fb8d3a3cc215daf9f6285d04b6901c3b5dff Mon Sep 17 00:00:00 2001 From: Seth Hollyman Date: Thu, 15 Apr 2021 19:46:54 +0000 Subject: [PATCH 2/3] doc nit --- bigquery/table.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bigquery/table.go b/bigquery/table.go index 25ea4511376..af13b07be33 100644 --- a/bigquery/table.go +++ b/bigquery/table.go @@ -356,7 +356,7 @@ func (rpr *RangePartitioningRange) toBQ() *bq.RangePartitioningRange { } } -// Clustering governs the organization of data within a partitioned table. +// Clustering governs the organization of data within a managed table. // For more information, see https://cloud.google.com/bigquery/docs/clustered-tables type Clustering struct { Fields []string From 0a2f750bf814361ed19a41e5bf7c0dfe14592de0 Mon Sep 17 00:00:00 2001 From: Seth Hollyman Date: Thu, 15 Apr 2021 20:45:27 +0000 Subject: [PATCH 3/3] push one more doc update --- bigquery/table.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bigquery/table.go b/bigquery/table.go index af13b07be33..f3493aed7ba 100644 --- a/bigquery/table.go +++ b/bigquery/table.go @@ -755,6 +755,8 @@ type TableMetadataToUpdate struct { Schema Schema // The table's clustering configuration. + // For more information on how modifying clustering affects the table, see: + // https://cloud.google.com/bigquery/docs/creating-clustered-tables#modifying-cluster-spec Clustering *Clustering // The table's encryption configuration.