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

chore: Update docs and migration guide #3313

Merged
merged 10 commits into from
Dec 20, 2024
142 changes: 93 additions & 49 deletions MIGRATION_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,61 +52,101 @@ We added non-negative validations for the following parameters:

Note that enum parameters are still not validated by the provider - they are only validated in Snowflake. We will handle this during a small rework of the parameters in the future.

### Add missing preview features to config

Values:
- `snowflake_functions_datasource`
- `snowflake_procedures_datasource`
- `snowflake_tables_datasource`
were missing in the `preview_features_enabled` attribute in the provider's config. They were added.

References: #3302

### functions and procedures docs updated

Argument names are automatically wrapped in double quotes, so:
- uppercase names should be used or
- argument name should be quoted in the procedure/function definition.

Updated the docs and the previous migration guide entry.

References: #3298

### python procedure docs updated

Importing python procedure is currently limited to procedures with snowflake-snowpark-python version explicitly set in Snowflake. Docs were updated.

References: #3303

## v0.100.0 ➞ v1.0.0

### Preview features flag
All of the preview features objects are now disabled by default. This includes:
- Resources
- `snowflake_account_password_policy_attachment`
- `snowflake_alert`
- `snowflake_api_integration`
- `snowflake_cortex_search_service`
- `snowflake_dynamic_table`
- `snowflake_external_function`
- `snowflake_external_table`
- `snowflake_external_volume`
- `snowflake_failover_group`
- `snowflake_file_format`
- `snowflake_managed_account`
- `snowflake_materialized_view`
- `snowflake_network_policy_attachment`
- `snowflake_network_rule`
- `snowflake_email_notification_integration`
- `snowflake_notification_integration`
- `snowflake_object_parameter`
- `snowflake_password_policy`
- `snowflake_pipe`
- `snowflake_sequence`
- `snowflake_share`
- `snowflake_stage`
- `snowflake_storage_integration`
- `snowflake_table_column_masking_policy_application`
- `snowflake_table_constraint`
- `snowflake_user_public_keys`
- `snowflake_user_password_policy_attachment`
- `snowflake_account_password_policy_attachment`
- `snowflake_alert`
- `snowflake_api_integration`
- `snowflake_cortex_search_service`
- `snowflake_dynamic_table`
- `snowflake_external_function`
- `snowflake_external_table`
- `snowflake_external_volume`
- `snowflake_failover_group`
- `snowflake_file_format`
- `snowflake_function_java`
- `snowflake_function_javascript`
- `snowflake_function_python`
- `snowflake_function_scala`
- `snowflake_function_sql`
- `snowflake_managed_account`
- `snowflake_materialized_view`
- `snowflake_network_policy_attachment`
- `snowflake_network_rule`
- `snowflake_email_notification_integration`
- `snowflake_notification_integration`
- `snowflake_object_parameter`
- `snowflake_password_policy`
- `snowflake_pipe`
- `snowflake_procedure_java`
- `snowflake_procedure_javascript`
- `snowflake_procedure_python`
- `snowflake_procedure_scala`
- `snowflake_procedure_sql`
- `snowflake_sequence`
- `snowflake_share`
- `snowflake_stage`
- `snowflake_storage_integration`
- `snowflake_table`
- `snowflake_table_column_masking_policy_application`
- `snowflake_table_constraint`
- `snowflake_user_public_keys`
- `snowflake_user_password_policy_attachment`
- Data sources
- `snowflake_current_account`
- `snowflake_alerts`
- `snowflake_cortex_search_services`
- `snowflake_database`
- `snowflake_database_role`
- `snowflake_dynamic_tables`
- `snowflake_external_functions`
- `snowflake_external_tables`
- `snowflake_failover_groups`
- `snowflake_file_formats`
- `snowflake_materialized_views`
- `snowflake_pipes`
- `snowflake_current_role`
- `snowflake_sequences`
- `snowflake_shares`
- `snowflake_parameters`
- `snowflake_stages`
- `snowflake_storage_integrations`
- `snowflake_system_generate_scim_access_token`
- `snowflake_system_get_aws_sns_iam_policy`
- `snowflake_system_get_privatelink_config`
- `snowflake_system_get_snowflake_platform_info`
- `snowflake_current_account`
- `snowflake_alerts`
- `snowflake_cortex_search_services`
- `snowflake_database`
- `snowflake_database_role`
- `snowflake_dynamic_tables`
- `snowflake_external_functions`
- `snowflake_external_tables`
- `snowflake_failover_groups`
- `snowflake_file_formats`
- `snowflake_functions`
- `snowflake_materialized_views`
- `snowflake_pipes`
- `snowflake_procedures`
- `snowflake_current_role`
- `snowflake_sequences`
- `snowflake_shares`
- `snowflake_parameters`
- `snowflake_stages`
- `snowflake_storage_integrations`
- `snowflake_system_generate_scim_access_token`
- `snowflake_system_get_aws_sns_iam_policy`
- `snowflake_system_get_privatelink_config`
- `snowflake_system_get_snowflake_platform_info`
- `snowflake_tables`

If you want to have them enabled, add the feature name to the provider configuration (with `_datasource` or `_resource` suffix), like this:
```terraform
Expand Down Expand Up @@ -170,6 +210,8 @@ The new resources are more aligned with current features like:
- secrets support
- argument default values

**Note**: argument names are now quoted automatically by the provider so remember about this while writing the function definition (argument name should be quoted or uppercase should be used for the argument name).

`snowflake_procedure` is now deprecated in favor of 5 new preview resources:

- `snowflake_procedure_java`
Expand All @@ -186,6 +228,8 @@ The new resources are more aligned with current features like:
- secrets support
- argument default values

**Note**: argument names are now quoted automatically by the provider so remember about this while writing the procedure definition (argument name should be quoted or uppercase should be used for the argument name).

### *(new feature)* Account role data source
Added a new `snowflake_account_roles` data source for account roles. Now it reflects It's based on `snowflake_roles` data source.
`account_roles` field now organizes output of show under `show_output` field.
Expand Down
10 changes: 8 additions & 2 deletions docs/resources/function_java.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,13 @@ resource "snowflake_function_java" "w" {
}
return_type = "VARCHAR(100)"
handler = "TestFunc.echoVarchar"
function_definition = "\n\tclass TestFunc {\n\t\tpublic static String echoVarchar(String x) {\n\t\t\treturn x;\n\t\t}\n\t}\n"
function_definition = <<EOT
class TestFunc {
public static String echoVarchar(String x) {
return x;
}
}
EOT
}
```
-> **Note** Instead of using fully_qualified_name, you can reference objects managed outside Terraform by constructing a correct ID, consult [identifiers guide](https://registry.terraform.io/providers/Snowflake-Labs/snowflake/latest/docs/guides/identifiers#new-computed-fully-qualified-name-field-in-resources).
Expand Down Expand Up @@ -90,7 +96,7 @@ resource "snowflake_function_java" "w" {
Required:

- `arg_data_type` (String) The argument type.
- `arg_name` (String) The argument name.
- `arg_name` (String) The argument name. The provider wraps it in double quotes by default, so be aware of that while referencing the argument in the function definition.

Optional:

Expand Down
12 changes: 8 additions & 4 deletions docs/resources/function_javascript.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,14 @@ resource "snowflake_function_javascript" "minimal" {
arg_data_type = "VARIANT"
arg_name = "x"
}
function_definition = <<EOF
return x;
EOF
return_type = "VARIANT"
function_definition = <<EOT
if (x == 0) {
return 1;
} else {
return 2;
}
EOT
}
```
-> **Note** Instead of using fully_qualified_name, you can reference objects managed outside Terraform by constructing a correct ID, consult [identifiers guide](https://registry.terraform.io/providers/Snowflake-Labs/snowflake/latest/docs/guides/identifiers#new-computed-fully-qualified-name-field-in-resources).
Expand Down Expand Up @@ -85,7 +89,7 @@ resource "snowflake_function_javascript" "minimal" {
Required:

- `arg_data_type` (String) The argument type.
- `arg_name` (String) The argument name.
- `arg_name` (String) The argument name. The provider wraps it in double quotes by default, so be aware of that while referencing the argument in the function definition.

Optional:

Expand Down
15 changes: 9 additions & 6 deletions docs/resources/function_python.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,15 @@ resource "snowflake_function_python" "minimal" {
arg_data_type = "NUMBER(36, 2)"
arg_name = "x"
}
function_definition = <<EOF
def some_function(x):
return x
EOF
handler = "some_function"
return_type = "NUMBER(36, 2)"
handler = "some_function"
function_definition = <<EOT
def some_function(x):
result = ''
for a in range(5):
result += x
return result
EOT
}
```
-> **Note** Instead of using fully_qualified_name, you can reference objects managed outside Terraform by constructing a correct ID, consult [identifiers guide](https://registry.terraform.io/providers/Snowflake-Labs/snowflake/latest/docs/guides/identifiers#new-computed-fully-qualified-name-field-in-resources).
Expand Down Expand Up @@ -97,7 +100,7 @@ resource "snowflake_function_python" "minimal" {
Required:

- `arg_data_type` (String) The argument type.
- `arg_name` (String) The argument name.
- `arg_name` (String) The argument name. The provider wraps it in double quotes by default, so be aware of that while referencing the argument in the function definition.

Optional:

Expand Down
16 changes: 8 additions & 8 deletions docs/resources/function_scala.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,16 @@ resource "snowflake_function_scala" "minimal" {
arg_data_type = "VARCHAR(100)"
arg_name = "x"
}
function_definition = <<EOF
return_type = "VARCHAR(100)"
runtime_version = "2.12"
handler = "TestFunc.echoVarchar"
function_definition = <<EOT
class TestFunc {
def echoVarchar(x : String): String = {
return x
}
}
EOF
runtime_version = "2.12"
handler = "TestFunc.echoVarchar"
return_type = "VARCHAR(100)"
EOT
}

# Complete
Expand All @@ -61,13 +61,13 @@ resource "snowflake_function_scala" "complete" {
}
comment = "some comment"
external_access_integrations = ["external_access_integration_name", "external_access_integration_name_2"]
function_definition = <<EOF
function_definition = <<EOT
class TestFunc {
def echoVarchar(x : String): String = {
return x
}
}
EOF
EOT
handler = "TestFunc.echoVarchar"
null_input_behavior = "CALLED ON NULL INPUT"
return_results_behavior = "VOLATILE"
Expand Down Expand Up @@ -143,7 +143,7 @@ resource "snowflake_function_scala" "complete" {
Required:

- `arg_data_type` (String) The argument type.
- `arg_name` (String) The argument name.
- `arg_name` (String) The argument name. The provider wraps it in double quotes by default, so be aware of that while referencing the argument in the function definition.

Optional:

Expand Down
14 changes: 7 additions & 7 deletions docs/resources/function_sql.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ resource "snowflake_function_sql" "minimal" {
arg_data_type = "FLOAT"
arg_name = "arg_name"
}
function_definition = <<EOF
arg_name
EOF
return_type = "FLOAT"
function_definition = <<EOT
arg_name
EOT
}

# Complete
Expand All @@ -55,10 +55,10 @@ resource "snowflake_function_sql" "complete" {
arg_data_type = "FLOAT"
arg_name = "arg_name"
}
function_definition = <<EOF
arg_name
EOF
return_type = "FLOAT"
function_definition = <<EOT
arg_name
EOT
return_results_behavior = "VOLATILE"
comment = "some comment"
}
Expand Down Expand Up @@ -102,7 +102,7 @@ resource "snowflake_function_sql" "complete" {
Required:

- `arg_data_type` (String) The argument type.
- `arg_name` (String) The argument name.
- `arg_name` (String) The argument name. The provider wraps it in double quotes by default, so be aware of that while referencing the argument in the function definition.

Optional:

Expand Down
20 changes: 17 additions & 3 deletions docs/resources/procedure_java.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,14 @@ resource "snowflake_procedure_java" "basic" {
}
return_type = "VARCHAR(100)"
handler = "TestFunc.echoVarchar"
procedure_definition = "\n\timport com.snowflake.snowpark_java.*;\n\tclass TestFunc {\n\t\tpublic static String echoVarchar(Session session, String x) {\n\t\t\treturn x;\n\t\t}\n\t}\n"
procedure_definition = <<EOT
import com.snowflake.snowpark_java.*;
class TestFunc {
public static String echoVarchar(Session session, String x) {
return x;
}
}
EOT
runtime_version = "11"
snowpark_package = "1.14.0"
}
Expand All @@ -57,7 +64,14 @@ resource "snowflake_procedure_java" "full" {
}
return_type = "VARCHAR(100)"
handler = "TestFunc.echoVarchar"
procedure_definition = "\n\timport com.snowflake.snowpark_java.*;\n\tclass TestFunc {\n\t\tpublic static String echoVarchar(Session session, String x) {\n\t\t\treturn x;\n\t\t}\n\t}\n"
procedure_definition = <<EOT
import com.snowflake.snowpark_java.*;
class TestFunc {
public static String echoVarchar(Session session, String x) {
return x;
}
}
EOT
runtime_version = "11"
snowpark_package = "1.14.0"

Expand Down Expand Up @@ -139,7 +153,7 @@ resource "snowflake_procedure_java" "full" {
Required:

- `arg_data_type` (String) The argument type.
- `arg_name` (String) The argument name.
- `arg_name` (String) The argument name. The provider wraps it in double quotes by default, so be aware of that while referencing the argument in the procedure definition.

Optional:

Expand Down
10 changes: 8 additions & 2 deletions docs/resources/procedure_javascript.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,13 @@ resource "snowflake_procedure_javascript" "basic" {
arg_name = "x"
}
return_type = "VARCHAR(100)"
procedure_definition = "\n\tif (x \u003c= 0) {\n\t\treturn 1;\n\t} else {\n\t\tvar result = 1;\n\t\tfor (var i = 2; i \u003c= x; i++) {\n\t\t\tresult = result * i;\n\t\t}\n\t\treturn result;\n\t}\n"
procedure_definition = <<EOT
if (x == 0) {
return 1;
} else {
return 2;
}
EOT
}
```
-> **Note** Instead of using fully_qualified_name, you can reference objects managed outside Terraform by constructing a correct ID, consult [identifiers guide](https://registry.terraform.io/providers/Snowflake-Labs/snowflake/latest/docs/guides/identifiers#new-computed-fully-qualified-name-field-in-resources).
Expand Down Expand Up @@ -83,7 +89,7 @@ resource "snowflake_procedure_javascript" "basic" {
Required:

- `arg_data_type` (String) The argument type.
- `arg_name` (String) The argument name.
- `arg_name` (String) The argument name. The provider wraps it in double quotes by default, so be aware of that while referencing the argument in the procedure definition.

Optional:

Expand Down
Loading
Loading