Skip to content

Commit

Permalink
feat(bigquery): support mutable clustering configuration (#3950)
Browse files Browse the repository at this point in the history
* feat(bigquery): support mutable clustering configuration

internal issue 185493320
  • Loading branch information
shollyman committed Apr 27, 2021
1 parent 9f6b648 commit 0ab30da
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
11 changes: 10 additions & 1 deletion bigquery/table.go
Expand Up @@ -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
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -750,6 +754,11 @@ type TableMetadataToUpdate struct {
// When updating a schema, you can add columns but not remove them.
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.
EncryptionConfig *EncryptionConfig

Expand Down
6 changes: 6 additions & 0 deletions bigquery/table_test.go
Expand Up @@ -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) {
Expand Down

0 comments on commit 0ab30da

Please sign in to comment.