Skip to content

Commit

Permalink
feat: Tasks v1 readiness part3 (#3202)
Browse files Browse the repository at this point in the history
- [x] Apply comments from
#3113
- [x] Cron
#3113 (comment)
- [x] Resource logic
#3113 (comment)
- [x] Refactor SDK suspend root logic for tasks (and overall suspend
logic in SDK/resource)
#3113 (comment)
- [x] Tests
- [x] External changes -
#3113 (comment)
- [x] Add more complicated DAG structures to show the resource can
handle more complex structures
- [x] Calling (`as` field) -
#3113 (comment)
- [x] Check in one acceptance test why the finalizer task in show_output
is not set (is that Snowflake or mapping error).
- [x] Data source
- [x] Examples, documentation, and migration guide
- [x] Keep manually changed files after regeneration
#3113 (comment)
- [x] Make config without $$ escapes needed
- [x] Support session parameters (I think it's already done, but check
https://docs.snowflake.com/en/sql-reference/parameters#label-session-parameters)
- [x] Refactor task resuming in task resource (most likely with the use
of defer) because currently, there may be cases that error can cause
tasks to be not resumed.
- [x] Analyze non-deterministic test cases (All tests seem to be
deterministic, only object_parameter resource tests are causing the
AllParameters test to fail)
- [x] Check test tasks_gen_integration_test.go:937 (and see why it's
non-deterministic).
- [x] Move some of the logic to SDK (if possible)
- [x]
#3170 (comment)
- [x] Apply comments
#3170
- [ ] Re-generate and list all the issues with asserts and models
  • Loading branch information
sfc-gh-jcieslak authored Nov 25, 2024
1 parent 6c9dc49 commit 57e99f4
Show file tree
Hide file tree
Showing 18 changed files with 1,287 additions and 214 deletions.
80 changes: 65 additions & 15 deletions MIGRATION_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@ across different versions.
## v0.98.0 ➞ v0.99.0

### snowflake_task resource changes

new fields:
- `config`

### snowflake_tasks data source changes

New filtering options:
Expand Down Expand Up @@ -65,22 +60,41 @@ output "simple_output" {
}
```

Please adjust your Terraform configuration files.

## v0.98.0 ➞ v0.99.0

### snowflake_task resource changes
New fields:
- `config` - enables to specify JSON-formatted metadata that can be retrieved in the `sql_statement` by using [SYSTEM$GET_TASK_GRAPH_CONFIG](https://docs.snowflake.com/en/sql-reference/functions/system_get_task_graph_config).
- `show_output` and `parameters` fields added for holding SHOW and SHOW PARAMETERS output (see [raw Snowflake output](./v1-preparations/CHANGES_BEFORE_V1.md#raw-snowflake-output)).
- Added support for finalizer tasks with `finalize` field. It conflicts with `after` and `schedule` (see [finalizer tasks](https://docs.snowflake.com/en/user-guide/tasks-graphs#release-and-cleanup-of-task-graphs)).

Changes:
- `enabled` field changed to `started` and type changed to string with only boolean values available (see ["empty" values](./v1-preparations/CHANGES_BEFORE_V1.md#empty-values))
- `shedule` field changed from single value to nested object that allows for specifying either minutes or cron
- `enabled` field changed to `started` and type changed to string with only boolean values available (see ["empty" values](./v1-preparations/CHANGES_BEFORE_V1.md#empty-values)). It is also now required field, so make sure it's explicitly set (previously it was optional with the default value set to `false`).
- `allow_overlapping_execution` type was changed to string with only boolean values available (see ["empty" values](./v1-preparations/CHANGES_BEFORE_V1.md#empty-values)). Previously, it had the default set to `false` which will be migrated. If nothing will be set the provider will plan the change to `default` value. If you want to make sure it's turned off, set it explicitly to `false`.

Before:
```terraform
resource "snowflake_task" "example" {
# ...
enabled = true
# ...
}
```
After:
```terraform
resource "snowflake_task" "example" {
# ...
started = true
# ...
}
```
- `schedule` field changed from single value to a nested object that allows for specifying either minutes or cron

Before:
```terraform
resource "snowflake_task" "example" {
# ...
schedule = "5 MINUTES"
# or
schedule = "USING SCHEDULE * * * * * UTC"
schedule = "USING CRON * * * * * UTC"
# ...
}
```
Expand All @@ -96,9 +110,45 @@ resource "snowflake_task" "example" {
# ...
}
```
- All task parameters defined in [the Snowflake documentation](https://docs.snowflake.com/en/sql-reference/parameters) added into the top-level schema and removed `session_paramters` map.
- `show_output` and `paramters` fields added for holding SHOW and SHOW PARAMETERS output (see [raw Snowflake output](./v1-preparations/CHANGES_BEFORE_V1.md#raw-snowflake-output)).
- Added support for finalizer tasks with `finalize` field. It conflicts with `after` and `schedule` (see [finalizer tasks](https://docs.snowflake.com/en/user-guide/tasks-graphs#release-and-cleanup-of-task-graphs)).
- All task parameters defined in [the Snowflake documentation](https://docs.snowflake.com/en/sql-reference/parameters) added into the top-level schema and removed `session_parameters` map.

Before:
```terraform
resource "snowflake_task" "example" {
# ...
session_parameters = {
QUERY_TAG = "<query_tag>"
}
# ...
}
```
After:
```terraform
resource "snowflake_task" "example" {
# ...
query_tag = "<query_tag>"
# ...
}
```

- `after` field type was changed from `list` to `set` and the values were changed from names to fully qualified names.

Before:
```terraform
resource "snowflake_task" "example" {
# ...
after = ["<task_name>", snowflake_task.some_task.name]
# ...
}
```
After:
```terraform
resource "snowflake_task" "example" {
# ...
after = ["<database_name>.<schema_name>.<task_name>", snowflake_task.some_task.fully_qualified_name]
# ...
}
```

## v0.98.0 ➞ v0.99.0

Expand Down
2 changes: 1 addition & 1 deletion docs/data-sources/tasks.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ check "task_check" {
- `limit` (Block List, Max: 1) Limits the number of rows returned. If the `limit.from` is set, then the limit wll start from the first element matched by the expression. The expression is only used to match with the first element, later on the elements are not matched by the prefix, but you can enforce a certain pattern with `starts_with` or `like`. (see [below for nested schema](#nestedblock--limit))
- `root_only` (Boolean) Filters the command output to return only root tasks (tasks with no predecessors).
- `starts_with` (String) Filters the output with **case-sensitive** characters indicating the beginning of the object name.
- `with_parameters` (Boolean) Runs SHOW PARAMETERS FOR TASK for each user returned by SHOW TASK. The output of describe is saved to the parameters field as a map. By default this value is set to true.
- `with_parameters` (Boolean) Runs SHOW PARAMETERS FOR TASK for each task returned by SHOW TASK and saves the output to the parameters field as a map. By default this value is set to true.

### Read-Only

Expand Down
Loading

0 comments on commit 57e99f4

Please sign in to comment.