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
44 changes: 44 additions & 0 deletions MIGRATION_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,32 @@ 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
Expand All @@ -67,6 +93,11 @@ All of the preview features objects are now disabled by default. This includes:
- `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`
Expand All @@ -76,10 +107,16 @@ All of the preview features objects are now disabled by default. This includes:
- `snowflake_object_parameter`
- `snowflake_password_policy`
- `snowflake_pipe`
- `snowflake_procedure_java`
- `snowflake_procedure_javascript`
- `snowflake_procedure_python`
- `snowflake_procedure_scala`
- `snowflake_procedure_sql`
sfc-gh-jmichalak marked this conversation as resolved.
Show resolved Hide resolved
- `snowflake_sequence`
- `snowflake_share`
- `snowflake_stage`
- `snowflake_storage_integration`
- `snowflake_table`
- `snowflake_table_column_masking_policy_application`
- `snowflake_table_constraint`
- `snowflake_user_public_keys`
Expand All @@ -95,8 +132,10 @@ All of the preview features objects are now disabled by default. This includes:
- `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`
Expand All @@ -107,6 +146,7 @@ All of the preview features objects are now disabled by default. This includes:
- `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
12 changes: 10 additions & 2 deletions docs/resources/procedure_python.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ description: |-

!> **Caution: Preview Feature** This feature is considered a preview feature in the provider, regardless of the state of the resource in Snowflake. We do not guarantee its stability. It will be reworked and marked as a stable feature in future releases. Breaking changes are expected, even without bumping the major version. To use this feature, add the relevant feature name to `preview_features_enabled field` in the [provider configuration](https://registry.terraform.io/providers/Snowflake-Labs/snowflake/latest/docs#schema). Please always refer to the [Getting Help](https://github.com/Snowflake-Labs/terraform-provider-snowflake?tab=readme-ov-file#getting-help) section in our Github repo to best determine how to get help for your questions.

!> **Caution: Import limitation** To import the python procedure, snowflake-snowpark-python version must be explicitly set in Snowflake (i.e. `snowflake-snowpark-python==1.14.0`). You can verify it by running `DESCRIBE PROCEDURE <your_procedure>` and checking the `packages`. Check [#3303](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/3303) for reference.

-> **Note** External changes to `is_secure` and `null_input_behavior` are not currently supported. They will be handled in the following versions of the provider which may still affect this resource.

-> **Note** `COPY GRANTS` and `OR REPLACE` are not currently supported.
Expand Down Expand Up @@ -42,7 +44,13 @@ resource "snowflake_procedure_python" "w" {
}
return_type = "VARCHAR(100)"
handler = "echoVarchar"
procedure_definition = "\ndef echoVarchar(x):\n\tresult = \"\"\n\tfor a in range(5):\n\t\tresult += x\n\treturn result\n"
procedure_definition = <<EOT
def echoVarchar(x):
result = ''
for a in range(5):
result += x
return result
EOT
runtime_version = "3.8"
snowpark_package = "1.14.0"
}
Expand Down Expand Up @@ -94,7 +102,7 @@ resource "snowflake_procedure_python" "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 procedure definition.

Optional:

Expand Down
11 changes: 9 additions & 2 deletions docs/resources/procedure_scala.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,14 @@ resource "snowflake_procedure_scala" "w" {
}
return_type = "VARCHAR(100)"
handler = "TestFunc.echoVarchar"
procedure_definition = "\n\timport com.snowflake.snowpark_java.Session\n\n\tclass TestFunc {\n\t\tdef echoVarchar(session : Session, x : String): String = {\n\t\t\treturn x\n\t\t}\n\t}\n"
procedure_definition = <<EOT
import com.snowflake.snowpark_java.Session
class TestFunc {
def echoVarchar(session : Session, x : String): String = {
return x
}
}
EOT
runtime_version = "2.12"
snowpark_package = "1.14.0"
}
Expand Down Expand Up @@ -91,7 +98,7 @@ resource "snowflake_procedure_scala" "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 procedure definition.

Optional:

Expand Down
Loading
Loading