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

SQL Compilation Errors not propagated as ERROR #1823

Open
csbain opened this issue May 22, 2023 · 1 comment
Open

SQL Compilation Errors not propagated as ERROR #1823

csbain opened this issue May 22, 2023 · 1 comment
Labels
bug Used to mark issues with provider's incorrect behavior category:other resource:table Issue connected to the snowflake_table resource

Comments

@csbain
Copy link

csbain commented May 22, 2023

Provider Version

v0.62.0

Terraform Version

v1.4.6 (Deployed through CDKTF @latest - tested manually as well)

Describe the bug

SQL compilation errors are returned as DEBUG messages and not relayed to a terraform deploy unless TF_LOG=TRACE/DEBUG is set
Errors encountered are as follows:
Bad data type for column.
Table already exists.

Expected behavior

Terraform error with deploy is thrown, proper snowflake errors are propagated through without the need for TF_LOG=TRACE/DEBUG being set.

Code samples and commands

Please add code examples and commands that were run to cause the problem.

-------------------------- DEBUG MESSAGE --------------------------

2023/05/22 11:15:36 [DEBUG] sql-conn-exec [query CREATE TABLE "#######"."#######"."#######" ("#######" NUMBER(38,0) COMMENT '', "#######" NUMBER(38,0) COMMENT '', "#######" VARCHAR(50) COMMENT '', "#######" VARCHAR(150) COMMENT '', "#######" TIMESTAMP_NTZ(9) COMMENT '', "#######" TIMESTAMP_NTZ(9) COMMENT '', "#######" VARCHAR(50) COMMENT '', "#######" VARCHAR(50) COMMENT '', "#######" NUMBER(38,0) COMMENT '', "#######" NUMBER(38,0) COMMENT '', "#######" NUMBER(38,0) COMMENT '', "#######" VARCHAR(1) COMMENT '', "#######" TIMESTAMP_NTZ(9) NOT NULL COMMENT '', "#######" NUMBER(38,0) COMMENT '', "#######" VARCHAR(500) COMMENT '', "#######" TIMESTAMP_NTZ(9) COMMENT '', "#######" TIMESTAMP_NTZ(9) COMMENT '', "#######" VARCHAR(50) COMMENT '', "#######" VARCHAR(100) NOT NULL COMMENT '', "#######" VARCHAR(500) NOT NULL COMMENT '', "#######" VARCHAR(500) NOT NULL COMMENT '', "#######" VARCHAR(500) NOT NULL COMMENT '', "#######" NUMBER(20,0) NOT NULL COMMENT '', "#######" VARCHAR(500) NOT NULL COMMENT '', "#######" TIMESTAMP_NTZ(9) NOT NULL COMMENT '', "#######" TIMESTAMP_NTZ(9) NOT NULL COMMENT '', "#######" TIMESTAMP_NTZ(9) NOT NULL COMMENT '', "#######" NUMBER(20,0) NOT NULL COMMENT '', "#######" NUMBER(20,0) NOT NULL COMMENT '') COMMENT = '####### FROM #######.#######.####### - ' DATA_RETENTION_TIME_IN_DAYS = 1 CHANGE_TRACKING = true err 002002 (42710): SQL compilation error: Object '#######.#######.#######' already exists. duration 283.504778ms args {}]: timestamp=2023-05-22T11:15:36.400Z

-------------------------- END DEBUG MESSAGE --------------------------

-------------------------- ERROR WITHOUT TF_LOG=TRACE/DEBUG --------------------------

Error: error creating table #######

with module.snowflake_table_group.module.snowflake_table["#######"].snowflake_table.main,
on assets/local-module-snowflake_table_group/330C88A764715C45B6D0937FBCE47A66/snowflake_table/main_table.tf line 1, in resource "snowflake_table" "main":
1: resource "snowflake_table" "main" {

-------------------------- END ERROR WITHOUT TF_LOG=TRACE/DEBUG --------------------------

Add any other context about the problem here.

@csbain csbain added the bug Used to mark issues with provider's incorrect behavior label May 22, 2023
@sfc-gh-jcieslak
Copy link
Collaborator

Hey @csbain
As we started to introduce the new SDK underneath the errors from Snowflake should be propagated to the user without additional TF_LOG=DEBUG/TRACE flags. Unfortunately, not all resources are using the new SDK, but soon we should take care of most of them in the resources refactor (for reference). The issue will be fully fixed as we'll be refactoring resource-by-resource during the refactoring.

@sfc-gh-jcieslak sfc-gh-jcieslak added the resource:table Issue connected to the snowflake_table resource label Jul 11, 2024
sfc-gh-jcieslak added a commit that referenced this issue Jul 12, 2024
## Changes
Applied changes from
https://github.com/Snowflake-Labs/terraform-provider-snowflake/pull/2046/files.
Applied changes from
https://github.com/Snowflake-Labs/terraform-provider-snowflake/pull/2854/files.
Addressed comment
#2912 (comment).
Added a note about object cloning and design decisions about them.
Assigned one issue to tables (it's a general one, but mostly points to
the table's implementation; it's #1823).
Added two common issues to our commonly known issues section in
CREATING_ISSUES.md.
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:other resource:table Issue connected to the snowflake_table resource
Projects
None yet
Development

No branches or pull requests

2 participants