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

feat(bigquery): support mutable clustering configuration #3950

Merged
merged 7 commits into from Apr 27, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 8 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,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

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