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

The snowflake_functions data source (v0.53) does not return functions that it did in V0.52 #1479

Closed
liamjamesfoley opened this issue Jan 17, 2023 · 5 comments
Labels
bug Used to mark issues with provider's incorrect behavior category:data_source data_source:functions Issue connected to the snowflake_functions data source

Comments

@liamjamesfoley
Copy link
Contributor

Provider Version

0.53

Terraform Version

v0.13.5

Describe the bug

The snowflake_functions data source does not return functions that it did in V0.52

Expected behavior

The snowflake_functions data source should return the functions in the given database/schema.

Code samples and commands

The function TERRAFORM_POC_2.IMPORT_TEST.TEST_FUNC() exists:
image

image

The data source returns the function using V0.52:

Apply complete! Resources: 0 added, 0 changed, 0 destroyed.

Outputs:

functions_test = [
  {
    "argument_types" = [
      "",
    ]
    "comment" = "user-defined function"
    "database" = ""
    "name" = "TEST_FUNC"
    "return_type" = "FLOAT"
    "schema" = "IMPORT_TEST"
  },
]

But not in V0.53 (no outputs):

➜  terraform-test terraform apply
data.snowflake_functions.current_functions: Refreshing state... [id=TERRAFORM_POC_2|IMPORT_TEST]

An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:

Terraform will perform the following actions:

Plan: 0 to add, 0 to change, 0 to destroy.

Changes to Outputs:
  - functions_test = [
      - {
          - argument_types = [
              - "",
            ]
          - comment        = "user-defined function"
          - database       = ""
          - name           = "TEST_FUNC"
          - return_type    = "FLOAT"
          - schema         = "IMPORT_TEST"
        },
    ] -> null

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes


Apply complete! Resources: 0 added, 0 changed, 0 destroyed.

Terraform config:

terraform {
  required_providers {
    snowflake = {
      source  = "Snowflake-Labs/snowflake"
      version = "0.52"  # changed this to "0.53" for testing.
    }
  }
}

provider "snowflake" {
  username    = "tf-snow"
  account     = "{REDACTED}"
  role        = "{REDACTED}"
  private_key = var.SNOWFLAKE["private_key"]
}

variable "SNOWFLAKE" {
  type = map(any)
}

data "snowflake_functions" "current_functions" {
  database = "TERRAFORM_POC_2"
  schema   = "IMPORT_TEST"
}

output "functions_test" {
  value = data.snowflake_functions.current_functions.functions
}

Using Debug produces error unable to scan row for SHOW USER FUNCTIONS IN SCHEMA "TERRAFORM_POC_2"."IMPORT_TEST" err = %!w(<nil>): timestamp=2023-01-17T14:15:48.431-0800 :
TF_LOG=DEBUG terraform apply
...

data.snowflake_functions.current_functions: Refreshing state... [id=functions]
2023-01-17T14:15:47.793-0800 [INFO]  plugin.terraform-provider-snowflake_v0.53.0: 2023/01/17 14:15:47 [DEBUG] query stmt SHOW USER FUNCTIONS IN SCHEMA "TERRAFORM_POC_2"."IMPORT_TEST": timestamp=2023-01-17T14:15:47.793-0800
2023-01-17T14:15:48.293-0800 [INFO]  plugin.terraform-provider-snowflake_v0.53.0: 2023/01/17 14:15:48 [DEBUG] sql-connector-connect [err <nil> duration 500.055606ms]: timestamp=2023-01-17T14:15:48.293-0800
2023-01-17T14:15:48.423-0800 [INFO]  plugin.terraform-provider-snowflake_v0.53.0: 2023/01/17 14:15:48 [DEBUG] sql-conn-query [query SHOW USER FUNCTIONS IN SCHEMA "TERRAFORM_POC_2"."IMPORT_TEST" err <nil> duration 130.055428ms args {}]: timestamp=2023-01-17T14:15:48.423-0800
2023-01-17T14:15:48.431-0800 [INFO]  plugin.terraform-provider-snowflake_v0.53.0: 2023/01/17 14:15:48 [DEBUG] sql-rows-next [err <nil> duration 7.524103ms]: timestamp=2023-01-17T14:15:48.431-0800
2023-01-17T14:15:48.431-0800 [INFO]  plugin.terraform-provider-snowflake_v0.53.0: 2023/01/17 14:15:48 [DEBUG] sql-rows-next [err EOF duration 1.59µs]: timestamp=2023-01-17T14:15:48.431-0800
2023-01-17T14:15:48.431-0800 [INFO]  plugin.terraform-provider-snowflake_v0.53.0: 2023/01/17 14:15:48 [DEBUG] error listing functions: unable to scan row for SHOW USER FUNCTIONS IN SCHEMA "TERRAFORM_POC_2"."IMPORT_TEST" err = %!w(<nil>): timestamp=2023-01-17T14:15:48.431-0800
2023-01-17T14:15:48.433-0800 [WARN]  plugin.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = transport is closing"
2023-01-17T14:15:48.436-0800 [DEBUG] plugin: plugin process exited: path=.terraform/plugins/registry.terraform.io/snowflake-labs/snowflake/0.53.0/darwin_amd64/terraform-provider-snowflake_v0.53.0 pid=7832
2023-01-17T14:15:48.436-0800 [DEBUG] plugin: plugin exited

Additional context

// todo: fix this. ListUserFunctions isn't using the right struct right now and also the signature of this doesn't support all the features it could for example, database and schema should be optional, and you could also list by account.

This comment looks suspect/relevant:
https://github.com/Snowflake-Labs/terraform-provider-snowflake/blob/main/pkg/datasources/functions.go#L68

@liamjamesfoley liamjamesfoley added the bug Used to mark issues with provider's incorrect behavior label Jan 17, 2023
@liamjamesfoley
Copy link
Contributor Author

FYI @mnagaa as author of that comment ⏫ 🙏

@mnagaa
Copy link
Contributor

mnagaa commented Feb 1, 2023

@liamjamesfoley
Thanks! But, this is not my comment. Please check git blame.

@sfc-gh-jcieslak sfc-gh-jcieslak added category:data_source data_source:functions Issue connected to the snowflake_functions data source labels May 20, 2024
@sfc-gh-asawicki
Copy link
Collaborator

Hey @liamjamesfoley.

Datasources were not reworked as part of v0.100.0 (and v1) but we will shortly address them. However, I think that this problem is already solved after moving functions to our SDK in https://github.com/Snowflake-Labs/terraform-provider-snowflake/releases/tag/v0.86.0. Can you verify if they work now for you?

@liamjamesfoley
Copy link
Contributor Author

Hey @sfc-gh-asawicki we actually stopped using this data source so I don't mind if you close this issue.

@sfc-gh-asawicki
Copy link
Collaborator

Thanks! I will close it then.

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:data_source data_source:functions Issue connected to the snowflake_functions data source
Projects
None yet
Development

No branches or pull requests

4 participants