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

[Bug]: snowflake_external_function resource Error: return_type VARCHAR not recognized #3392

Open
ddorchehVisa opened this issue Feb 12, 2025 · 3 comments · Fixed by #3400
Open
Assignees
Labels
bug Used to mark issues with provider's incorrect behavior category:preview Topics connected with preview features resource:external_function Issue connected to the snowflake_external_function resource

Comments

@ddorchehVisa
Copy link

ddorchehVisa commented Feb 12, 2025

Terraform CLI Version

1.9.4

Terraform Provider Version

1.0.2

Company Name

No response

Terraform Configuration

resource "snowflake_external_function" "my_external_functions" {
  for_each = var.snowflake_fle_external_functions

  name     = each.value.function_name
  database = each.value.database
  schema   = snowflake_schema.my_schemas_schemas[each.key].name
  arg {
    name = "CIPHER"
    type = "binary"
  }
  return_type               = "varchar"
  return_behavior           = "VOLATILE"
  api_integration           = snowflake_api_integration.my_api_integrations[each.key].fully_qualified_name
  url_of_proxy_and_resource = each.value.url_of_proxy_and_resource
  return_null_allowed       = false
}

import {
  for_each = var.my_external_functions

  to = snowflake_external_function.my_external_functions[each.key]
  id = "\"${each.value.database}\".\"${each.value.schema}\".\"${each.value.function_name}\"(BINARY)" 
}

Category

category:resource

Object type(s)

resource:external_function

Expected Behavior

I first import an existing external function in the data warehouse into terraform. The existing external function returns varchar data. This is confirmed working in the UI.
The external function object can then be managed by terraform.
The plan is generated successfully and can be applied successfully.

Actual Behavior

The plan is initially generated successfully:

# snowflake_external_function.fle_external_functions["demo"] must be replaced
  # (imported from ""MY_DB".""."MY_FUNC"(BINARY)")
  # Warning: this will destroy the imported resource
-/+ resource "snowflake_external_function" "my_external_functions" {
      + api_integration           = "\"MY_API_INTEGRATION\"" # forces replacement
        comment                   = "user-defined function"
        compression               = "AUTO"
      ~ created_on                = "2025-02-11T08:45:51.028-08:00" -> (known after apply)
        database                  = "MY_DB"
      ~ fully_qualified_name      = "\"MY_DB\".\"MY_SCHEMA\".\"MY_FUNC\"(BINARY)" -> (known after apply)
      ~ id                        = "\"MY_DB\".\"MY_SCHEMA\".\"MY_FUNC\"(BINARY)" -> (known after apply)
        name                      = "MY_FUNC"
        null_input_behavior       = "CALLED ON NULL INPUT"
        return_behavior           = "VOLATILE"
      + return_null_allowed       = false # forces replacement
        return_type               = "VARCHAR"
        schema                    = "MY_SCHEMA"
        url_of_proxy_and_resource = "https://abcdef1234.execute-api.eu-west-1.amazonaws.com/placeholder"

        arg {
            name = "CIPHER"
            type = "BINARY"
        }
    }

On apply, I get the following error and the object is not created:

Error: return_type VARCHAR not recognized

with snowflake_external_function.my_external_functions["demo"],
on my_objects.tf line 149, in resource "snowflake_external_function" "my_external_functions":
149: resource "snowflake_external_function" "my_external_functions" {

When reverting the change, the plan to remove the resource generates the same error.

Steps to Reproduce

  1. Manually create an external function object in Snowflake that returns a VARCHAR.
  2. Add the configuration like above that imports the object and creates the resource in terraform.
  3. Generate the plan and apply the plan.

How much impact is this issue causing?

High

Logs

No response

Additional Information

The same error is returned when setting return_type = "VARCHAR" vs return_type = "varchar".
Since the object was imported successfully, the error is only returned when loading the object from the tfstate file.

Would you like to implement a fix?

@ddorchehVisa ddorchehVisa added the bug Used to mark issues with provider's incorrect behavior label Feb 12, 2025
@sfc-gh-jmichalak sfc-gh-jmichalak added the resource:external_function Issue connected to the snowflake_external_function resource label Feb 12, 2025
@sfc-gh-jmichalak
Copy link
Collaborator

Hi @ddorchehVisa 👋

This resource is still in the preview, and we will rework it after GA (see roadmap). This will include reworked data types.

@nijave
Copy link
Contributor

nijave commented Feb 14, 2025

Tested this locally and it seems to fix the issue for us #3400

@sfc-gh-jmichalak sfc-gh-jmichalak added the category:preview Topics connected with preview features label Feb 17, 2025
sfc-gh-jmichalak added a commit that referenced this issue Feb 19, 2025
References #3392

Signed-off-by: Nick Venenga <nick.venenga@15five.com>
Co-authored-by: Jakub Michalak <jakub.michalak@snowflake.com>
@sfc-gh-jmichalak sfc-gh-jmichalak self-assigned this Feb 19, 2025
@sfc-gh-jmichalak
Copy link
Collaborator

Hi @nijave ,

We've released v1.0.4 (release, migration guide) with the fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Used to mark issues with provider's incorrect behavior category:preview Topics connected with preview features resource:external_function Issue connected to the snowflake_external_function resource
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants