Skip to content

Commit

Permalink
feat: Tasks v1 readiness (#3222)
Browse files Browse the repository at this point in the history
Pr that collects all the changes to tasks from previous prs:
-
#3202
-
#3170
-
#3113

**Note**: look at the last commit, added very small changes to
documentation and code (around 8 lines)
  • Loading branch information
sfc-gh-jcieslak authored Nov 26, 2024
1 parent a3a44ae commit e2284d9
Show file tree
Hide file tree
Showing 70 changed files with 9,519 additions and 1,692 deletions.
143 changes: 142 additions & 1 deletion MIGRATION_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,150 @@ across different versions.

> [!TIP]
> We highly recommend upgrading the versions one by one instead of bulk upgrades.
## v0.98.0 ➞ v0.99.0

### snowflake_tasks data source changes

New filtering options:
- `with_parameters`
- `like`
- `in`
- `starts_with`
- `root_only`
- `limit`

New output fields
- `show_output`
- `parameters`

Breaking changes:
- `database` and `schema` are right now under `in` field

Before:
```terraform
data "snowflake_tasks" "old_tasks" {
database = "<database_name>"
schema = "<schema_name>"
}
```
After:
```terraform
data "snowflake_tasks" "new_tasks" {
in {
# for IN SCHEMA specify:
schema = "<database_name>.<schema_name>"
# for IN DATABASE specify:
database = "<database_name>"
}
}
```
- `tasks` field now organizes output of show under `show_output` field and the output of show parameters under `parameters` field.

Before:
```terraform
output "simple_output" {
value = data.snowflake_tasks.test.tasks[0].name
}
```
After:
```terraform
output "simple_output" {
value = data.snowflake_tasks.test.tasks[0].show_output[0].name
}
```

### 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)). 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 CRON * * * * * UTC"
# ...
}
```
After:
```terraform
resource "snowflake_task" "example" {
# ...
schedule {
minutes = 5
# or
using_cron = "* * * * * UTC"
}
# ...
}
```
- 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]
# ...
}
```

### *(new feature)* snowflake_tags datasource
Added a new datasource enabling querying and filtering tags. Notes:
- all results are stored in `tags` field.
Expand Down
Loading

0 comments on commit e2284d9

Please sign in to comment.