Skip to content

Commit 0ab30da

Browse files
authored
feat(bigquery): support mutable clustering configuration (#3950)
* feat(bigquery): support mutable clustering configuration internal issue 185493320
1 parent 9f6b648 commit 0ab30da

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

Diff for: bigquery/table.go

+10-1
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ func (rpr *RangePartitioningRange) toBQ() *bq.RangePartitioningRange {
356356
}
357357
}
358358

359-
// Clustering governs the organization of data within a partitioned table.
359+
// Clustering governs the organization of data within a managed table.
360360
// For more information, see https://cloud.google.com/bigquery/docs/clustered-tables
361361
type Clustering struct {
362362
Fields []string
@@ -681,6 +681,10 @@ func (tm *TableMetadataToUpdate) toBQ() (*bq.Table, error) {
681681
t.EncryptionConfiguration = tm.EncryptionConfig.toBQ()
682682
}
683683

684+
if tm.Clustering != nil {
685+
t.Clustering = tm.Clustering.toBQ()
686+
}
687+
684688
if !validExpiration(tm.ExpirationTime) {
685689
return nil, invalidTimeError(tm.ExpirationTime)
686690
}
@@ -750,6 +754,11 @@ type TableMetadataToUpdate struct {
750754
// When updating a schema, you can add columns but not remove them.
751755
Schema Schema
752756

757+
// The table's clustering configuration.
758+
// For more information on how modifying clustering affects the table, see:
759+
// https://cloud.google.com/bigquery/docs/creating-clustered-tables#modifying-cluster-spec
760+
Clustering *Clustering
761+
753762
// The table's encryption configuration.
754763
EncryptionConfig *EncryptionConfig
755764

Diff for: bigquery/table_test.go

+6
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,12 @@ func TestTableMetadataToUpdateToBQ(t *testing.T) {
399399
ForceSendFields: []string{"RequirePartitionFilter"},
400400
},
401401
},
402+
{
403+
tm: TableMetadataToUpdate{Clustering: &Clustering{Fields: []string{"foo", "bar"}}},
404+
want: &bq.Table{
405+
Clustering: &bq.Clustering{Fields: []string{"foo", "bar"}},
406+
},
407+
},
402408
} {
403409
got, _ := test.tm.toBQ()
404410
if !testutil.Equal(got, test.want) {

0 commit comments

Comments
 (0)