Skip to content

Commit

Permalink
Fix warehouse validation
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-asawicki committed Oct 30, 2023
1 parent 526596a commit 9949ff6
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
2 changes: 1 addition & 1 deletion pkg/sdk/masking_policy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func TestMaskingPolicyAlter(t *testing.T) {
name: id,
}

assertOptsInvalid(t, opts, errExactlyOneOf("Set", "Unset", "NewName"))
assertOptsInvalid(t, opts, errExactlyOneOf("Set", "Unset", "SetTag", "UnsetTag", "NewName"))
})

t.Run("with set", func(t *testing.T) {
Expand Down
9 changes: 4 additions & 5 deletions pkg/sdk/warehouses.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,16 +246,15 @@ func (v *WarehouseSet) validate() error {
return fmt.Errorf("QueryAccelerationMaxScaleFactor must be between 0 and 100")
}
}
if everyValueNil(v.AutoResume, v.EnableQueryAcceleration, v.MaxClusterCount, v.MinClusterCount, v.AutoSuspend, v.QueryAccelerationMaxScaleFactor) {
return errAtLeastOneOf("AutoResume", "EnableQueryAcceleration", "MaxClusterCount", "MinClusterCount", "AutoSuspend", "QueryAccelerationMaxScaleFactor")
if everyValueNil(v.WarehouseType, v.WarehouseSize, v.WaitForCompletion, v.MaxClusterCount, v.MinClusterCount, v.ScalingPolicy, v.AutoSuspend, v.AutoResume, v.ResourceMonitor, v.Comment, v.EnableQueryAcceleration, v.QueryAccelerationMaxScaleFactor, v.MaxConcurrencyLevel, v.StatementQueuedTimeoutInSeconds, v.StatementTimeoutInSeconds) {
return errAtLeastOneOf("WarehouseType", "WarehouseSize", "WaitForCompletion", "MaxClusterCount", "MinClusterCount", "ScalingPolicy", "AutoSuspend", "AutoResume", "ResourceMonitor", "Comment", "EnableQueryAcceleration", "QueryAccelerationMaxScaleFactor", "MaxConcurrencyLevel", "StatementQueuedTimeoutInSeconds", "StatementTimeoutInSeconds")
}
return nil
}

type WarehouseUnset struct {
// Object properties
WarehouseType *bool `ddl:"keyword" sql:"WAREHOUSE_TYPE"`
WarehouseSize *bool `ddl:"keyword" sql:"WAREHOUSE_SIZE"`
WaitForCompletion *bool `ddl:"keyword" sql:"WAIT_FOR_COMPLETION"`
MaxClusterCount *bool `ddl:"keyword" sql:"MAX_CLUSTER_COUNT"`
MinClusterCount *bool `ddl:"keyword" sql:"MIN_CLUSTER_COUNT"`
Expand All @@ -274,8 +273,8 @@ type WarehouseUnset struct {
}

func (v *WarehouseUnset) validate() error {
if everyValueNil(v.AutoResume, v.EnableQueryAcceleration, v.MaxClusterCount, v.MinClusterCount, v.AutoSuspend, v.QueryAccelerationMaxScaleFactor) {
return errAtLeastOneOf("AutoResume", "EnableQueryAcceleration", "MaxClusterCount", "MinClusterCount", "AutoSuspend", "QueryAccelerationMaxScaleFactor")
if everyValueNil(v.WarehouseType, v.WaitForCompletion, v.MaxClusterCount, v.MinClusterCount, v.ScalingPolicy, v.AutoSuspend, v.AutoResume, v.ResourceMonitor, v.Comment, v.EnableQueryAcceleration, v.QueryAccelerationMaxScaleFactor, v.MaxConcurrencyLevel, v.StatementQueuedTimeoutInSeconds, v.StatementTimeoutInSeconds) {
return errAtLeastOneOf("WarehouseType", "WaitForCompletion", "MaxClusterCount", "MinClusterCount", "ScalingPolicy", "AutoSuspend", "AutoResume", "ResourceMonitor", "Comment", "EnableQueryAcceleration", "QueryAccelerationMaxScaleFactor", "MaxConcurrencyLevel", "StatementQueuedTimeoutInSeconds", "StatementTimeoutInSeconds")
}
return nil
}
Expand Down
3 changes: 1 addition & 2 deletions pkg/sdk/warehouses_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,11 @@ func TestWarehouseAlter(t *testing.T) {
opts := &AlterWarehouseOptions{
name: NewAccountObjectIdentifier("mywarehouse"),
Unset: &WarehouseUnset{
WarehouseSize: Bool(true),
MaxClusterCount: Bool(true),
AutoResume: Bool(true),
},
}
assertOptsValidAndSQLEquals(t, opts, `ALTER WAREHOUSE "mywarehouse" UNSET WAREHOUSE_SIZE, MAX_CLUSTER_COUNT, AUTO_RESUME`)
assertOptsValidAndSQLEquals(t, opts, `ALTER WAREHOUSE "mywarehouse" UNSET MAX_CLUSTER_COUNT, AUTO_RESUME`)
})

t.Run("rename", func(t *testing.T) {
Expand Down

0 comments on commit 9949ff6

Please sign in to comment.