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

fix: Warehouse create and alter properties #598

Merged
merged 4 commits into from
Jul 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions docs/data-sources/system_get_snowflake_platform_info.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "snowflake_system_get_snowflake_platform_info Data Source - terraform-provider-snowflake"
subcategory: ""
description: |-

---

# snowflake_system_get_snowflake_platform_info (Data Source)





<!-- schema generated by tfplugindocs -->
## Schema

### Optional

- **id** (String) The ID of this resource.

### Read-Only

- **aws_vpc_ids** (List of String) Snowflake AWS Virtual Private Cloud IDs
- **azure_vnet_subnet_ids** (List of String) Snowflake Azure Virtual Network Subnet IDs


2 changes: 2 additions & 0 deletions docs/resources/warehouse.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,11 @@ resource snowflake_warehouse w {
- **id** (String) The ID of this resource.
- **initially_suspended** (Boolean) Specifies whether the warehouse is created initially in the ‘Suspended’ state.
- **max_cluster_count** (Number) Specifies the maximum number of server clusters for the warehouse.
- **max_concurrency_level** (Number) Object parameter that specifies the concurrency level for SQL statements (i.e. queries and DML) executed by a warehouse.
- **min_cluster_count** (Number) Specifies the minimum number of server clusters for the warehouse (only applies to multi-cluster warehouses).
- **resource_monitor** (String) Specifies the name of a resource monitor that is explicitly assigned to the warehouse.
- **scaling_policy** (String) Specifies the policy for automatically starting and shutting down clusters in a multi-cluster warehouse running in Auto-scale mode.
- **statement_queued_timeout_in_seconds** (Number) Object parameter that specifies the time, in seconds, a SQL statement (query, DDL, DML, etc.) can be queued on a warehouse before it is canceled by the system.
- **statement_timeout_in_seconds** (Number) Specifies the time, in seconds, after which a running SQL statement (query, DDL, DML, etc.) is canceled by the system
- **wait_for_provisioning** (Boolean) Specifies whether the warehouse, after being resized, waits for all the servers to provision before executing any queued or new queries.
- **warehouse_size** (String)
Expand Down
32 changes: 29 additions & 3 deletions pkg/resources/warehouse.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@ import (
)

// warehouseCreateProperties are only available via the CREATE statement
var warehouseCreateProperties = []string{"initially_suspended", "wait_for_provisioning", "statement_timeout_in_seconds"}
var warehouseCreateProperties = []string{"initially_suspended", "wait_for_provisioning"}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these should probably ForceNew


var warehouseProperties = []string{
"comment", "warehouse_size", "max_cluster_count", "min_cluster_count",
"scaling_policy", "auto_suspend", "auto_resume",
"resource_monitor",
"resource_monitor", "max_concurrency_level", "statement_queued_timeout_in_seconds",
"statement_timeout_in_seconds",
}

var warehouseSchema = map[string]*schema.Schema{
Expand Down Expand Up @@ -84,6 +85,7 @@ var warehouseSchema = map[string]*schema.Schema{
Type: schema.TypeBool,
Description: "Specifies whether the warehouse is created initially in the ‘Suspended’ state.",
Optional: true,
ForceNew: true,
},
"resource_monitor": {
Type: schema.TypeString,
Expand All @@ -95,14 +97,26 @@ var warehouseSchema = map[string]*schema.Schema{
Type: schema.TypeBool,
Description: "Specifies whether the warehouse, after being resized, waits for all the servers to provision before executing any queued or new queries.",
Optional: true,
ForceNew: true,
},
"statement_timeout_in_seconds": {
Type: schema.TypeInt,
Optional: true,
Default: 0,
ForceNew: false,
Description: "Specifies the time, in seconds, after which a running SQL statement (query, DDL, DML, etc.) is canceled by the system",
},
"statement_queued_timeout_in_seconds": {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need to add these to Read+Update

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe just Read actually

Type: schema.TypeInt,
Optional: true,
Default: 0,
Description: "Object parameter that specifies the time, in seconds, a SQL statement (query, DDL, DML, etc.) can be queued on a warehouse before it is canceled by the system.",
},
"max_concurrency_level": {
Type: schema.TypeInt,
Optional: true,
Default: 0,
Description: "Object parameter that specifies the concurrency level for SQL statements (i.e. queries and DML) executed by a warehouse.",
},
}

// Warehouse returns a pointer to the resource representing a warehouse
Expand Down Expand Up @@ -175,6 +189,18 @@ func ReadWarehouse(d *schema.ResourceData, meta interface{}) error {
if err != nil {
return err
}
err = d.Set("statement_timeout_in_seconds", w.StatementTimeoutInSeconds)
if err != nil {
return err
}
err = d.Set("statement_queued_timeout_in_seconds", w.StatementQueuedTimeoutInSeconds)
if err != nil {
return err
}
err = d.Set("max_concurrency_level", w.MaxConcurrencyLevel)
if err != nil {
return err
}
err = d.Set("resource_monitor", w.ResourceMonitor)

return err
Expand Down
2 changes: 1 addition & 1 deletion pkg/resources/warehouse_acceptance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func TestAcc_Warehouse(t *testing.T) {
ResourceName: "snowflake_warehouse.w",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"initially_suspended", "wait_for_provisioning", "statement_timeout_in_seconds"},
ImportStateVerifyIgnore: []string{"initially_suspended", "wait_for_provisioning"},
},
},
})
Expand Down
61 changes: 32 additions & 29 deletions pkg/snowflake/warehouse.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,35 +16,38 @@ func Warehouse(name string) *Builder {
// warehouse is a go representation of a grant that can be used in conjunction
// with github.com/jmoiron/sqlx
type warehouse struct {
Name string `db:"name"`
State string `db:"state"`
Type string `db:"type"`
Size string `db:"size"`
MinClusterCount int64 `db:"min_cluster_count"`
MaxClusterCount int64 `db:"max_cluster_count"`
StartedClusters int64 `db:"started_clusters"`
Running int64 `db:"running"`
Queued int64 `db:"queued"`
IsDefault string `db:"is_default"`
IsCurrent string `db:"is_current"`
AutoSuspend int64 `db:"auto_suspend"`
AutoResume bool `db:"auto_resume"`
Available string `db:"available"`
Provisioning string `db:"provisioning"`
Quiescing string `db:"quiescing"`
Other string `db:"other"`
CreatedOn time.Time `db:"created_on"`
ResumedOn time.Time `db:"resumed_on"`
UpdatedOn time.Time `db:"updated_on"`
Owner string `db:"owner"`
Comment string `db:"comment"`
ResourceMonitor string `db:"resource_monitor"`
Actives int64 `db:"actives"`
Pendings int64 `db:"pendings"`
Failed int64 `db:"failed"`
Suspended int64 `db:"suspended"`
UUID string `db:"uuid"`
ScalingPolicy string `db:"scaling_policy"`
Name string `db:"name"`
State string `db:"state"`
Type string `db:"type"`
Size string `db:"size"`
MinClusterCount int64 `db:"min_cluster_count"`
MaxClusterCount int64 `db:"max_cluster_count"`
StartedClusters int64 `db:"started_clusters"`
Running int64 `db:"running"`
Queued int64 `db:"queued"`
IsDefault string `db:"is_default"`
IsCurrent string `db:"is_current"`
AutoSuspend int64 `db:"auto_suspend"`
AutoResume bool `db:"auto_resume"`
Available string `db:"available"`
Provisioning string `db:"provisioning"`
Quiescing string `db:"quiescing"`
Other string `db:"other"`
CreatedOn time.Time `db:"created_on"`
ResumedOn time.Time `db:"resumed_on"`
UpdatedOn time.Time `db:"updated_on"`
Owner string `db:"owner"`
Comment string `db:"comment"`
ResourceMonitor string `db:"resource_monitor"`
StatementTimeoutInSeconds int64 `db:"statement_timeout_in_seconds"`
StatementQueuedTimeoutInSeconds int64 `db:"statement_queued_timeout_in_seconds"`
MaxConcurrencyLevel int64 `db:"max_concurrency_level"`
Actives int64 `db:"actives"`
Pendings int64 `db:"pendings"`
Failed int64 `db:"failed"`
Suspended int64 `db:"suspended"`
UUID string `db:"uuid"`
ScalingPolicy string `db:"scaling_policy"`
}

func ScanWarehouse(row *sqlx.Row) (*warehouse, error) {
Expand Down