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

Feature/table clustering #548

Merged
merged 15 commits into from
May 21, 2021
Prev Previous commit
Next Next commit
Drop clustering if keys removed
berosen committed May 18, 2021
commit cf1ea25e8541db6f1fd22d305423a334f4422ef6
11 changes: 9 additions & 2 deletions pkg/resources/table.go
Original file line number Diff line number Diff line change
@@ -320,8 +320,15 @@ func UpdateTable(d *schema.ResourceData, meta interface{}) error {

if d.HasChange("cluster_by") {
cb := expandStringList(d.Get("cluster_by").([]interface{}))
builder.WithClustering(cb)
q := builder.ChangeClusterBy(builder.GetClusterKeyString())

var q string
if len(cb) != 0 {
builder.WithClustering(cb)
q = builder.ChangeClusterBy(builder.GetClusterKeyString())
} else {
q = builder.DropClustering()
}

err := snowflake.Exec(db, q)
if err != nil {
return errors.Wrapf(err, "error updating table clustering on %v", d.Id())