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: Added Query Acceleration for Warehouses #1239

Merged
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
2 changes: 2 additions & 0 deletions docs/resources/warehouse.md
Original file line number Diff line number Diff line change
@@ -32,10 +32,12 @@ resource snowflake_warehouse w {
- `auto_resume` (Boolean) Specifies whether to automatically resume a warehouse when a SQL statement (e.g. query) is submitted to it.
- `auto_suspend` (Number) Specifies the number of seconds of inactivity after which a warehouse is automatically suspended.
- `comment` (String)
- `enable_query_acceleration` (Boolean) Specifies whether to enable the query acceleration service for queries that rely on this warehouse for compute resources.
- `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).
- `query_acceleration_max_scale_factor` (Number) Specifies the maximum scale factor for leasing compute resources for query acceleration. The scale factor is used as a multiplier based on warehouse size.
- `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.
23 changes: 22 additions & 1 deletion pkg/resources/warehouse.go
Original file line number Diff line number Diff line change
@@ -18,7 +18,7 @@ var warehouseProperties = []string{
"comment", "warehouse_size", "max_cluster_count", "min_cluster_count",
"scaling_policy", "auto_suspend", "auto_resume",
"resource_monitor", "max_concurrency_level", "statement_queued_timeout_in_seconds",
"statement_timeout_in_seconds",
"statement_timeout_in_seconds", "enable_query_acceleration", "query_acceleration_max_scale_factor",
}

var warehouseSchema = map[string]*schema.Schema{
@@ -121,6 +121,19 @@ var warehouseSchema = map[string]*schema.Schema{
Default: 8,
Description: "Object parameter that specifies the concurrency level for SQL statements (i.e. queries and DML) executed by a warehouse.",
},
"enable_query_acceleration": {
Type: schema.TypeBool,
Optional: true,
Default: false,
Description: "Specifies whether to enable the query acceleration service for queries that rely on this warehouse for compute resources.",
},
"query_acceleration_max_scale_factor": {
Type: schema.TypeInt,
Optional: true,
Default: 8,
ValidateFunc: validation.IntBetween(0, 100),
Description: "Specifies the maximum scale factor for leasing compute resources for query acceleration. The scale factor is used as a multiplier based on warehouse size.",
},
"tag": tagReferenceSchema,
}

@@ -207,6 +220,14 @@ func ReadWarehouse(d *schema.ResourceData, meta interface{}) error {
if err != nil {
return err
}
err = d.Set("enable_query_acceleration", w.EnableQueryAcceleration)
if err != nil {
return err
}
err = d.Set("query_acceleration_max_scale_factor", w.QueryAccelerationMaxScaleFactor)
if err != nil {
return err
}

stmt = warehouseBuilder.ShowParameters()
paramRows, err := snowflake.Query(db, stmt)
60 changes: 31 additions & 29 deletions pkg/snowflake/warehouse.go
Original file line number Diff line number Diff line change
@@ -55,35 +55,37 @@ func Warehouse(name string) *WarehouseBuilder {
// 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 sql.NullInt64 `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 sql.NullInt64 `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"`
EnableQueryAcceleration bool `db:"enable_query_acceleration"`
QueryAccelerationMaxScaleFactor int `db:"query_acceleration_max_scale_factor"`
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"`
}

// warehouseParams struct to represent a row of parameters.