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

external_table column_type uses default even if other precision is specified #2310

Closed
justin-ramirez-gametime opened this issue Jan 1, 2024 · 3 comments
Labels
bug Used to mark issues with provider's incorrect behavior

Comments

@justin-ramirez-gametime
Copy link

Terraform CLI and Provider Versions

Terraform v1.6.1
Provider version 0.82.0

Terraform Configuration

resource "snowflake_external_table" "external_table" {
  provider     = snowflake.sys_admin
  database     = var.target_database_name
  schema       = var.target_schema_name
  name         = var.external_table_name
  comment      = var.description
  file_format  = var.file_format
  location     = "@${var.source_database_name}.${var.source_schema_name}.${var.source_stage_name}/${var.file_path}"
  pattern      = var.pattern
  partition_by = var.partition_by

  dynamic "column" {
    for_each = var.columns
    content {
      name = column.value.name
      type = column.value.type
      as   = "(${column.value.as}::${column.value.type})"
    }
  }
  auto_refresh = var.auto_refresh
}

Expected Behavior

Expected the external_table column to be cast as the type described in 'type'.
{
name = "RECAPTCHA_ASSESSMENT_SCORE"
type = "NUMBER(2, 2)"
as = "GET($1, 'recaptcha_assessment_score')"
}

should become: RECAPTCHA_ASSESSMENT_SCORE NUMBER(2, 2) AS (TO_NUMBER(GET($1, 'recaptcha_assessment_score'), 2, 2))

Actual Behavior

It seems as though the precision specification is being ignored or replaced with the type default for the column type casting but not for the read expression type:
RECAPTCHA_ASSESSMENT_SCORE NUMBER(38,0) AS (TO_NUMBER(GET($1, 'recaptcha_assessment_score'), 2, 2))

We saw similar issues occur when type is:
VARCHAR(1000); It was changed to BOUNCE_REASON VARCHAR(16777216) AS (CAST(GET($1, 'bounce_reason') AS VARCHAR(1000)))

NUMBER(9,2); TRANSACTION_AMOUNT NUMBER(38,0) AS (TO_NUMBER(GET(VALUE, 'c10'), 9, 2))

Steps to Reproduce

  1. terraform apply

How much impact is this issue causing?

High

Logs

No response

Additional Information

The file_formats for each of these occurrences varied between CSV, Custom JSON_GZIP, AVRO
It only seems to be an issue when we are not using the default precision for the type cast.

@justin-ramirez-gametime justin-ramirez-gametime added the bug Used to mark issues with provider's incorrect behavior label Jan 1, 2024
@sfc-gh-jcieslak
Copy link
Collaborator

Hey @justin-ramirez-gametime
I'll take a look at it as soon as possible (probably this or next week).
Thank you for reporting an issue.

@sfc-gh-jcieslak
Copy link
Collaborator

Hey @justin-ramirez-gametime
Could you check if the issue persists in the latest version of the provider?

@justin-ramirez-gametime
Copy link
Author

The latest version fixed this issue

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
Projects
None yet
Development

No branches or pull requests

2 participants