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

snowflake_table: Add support for virtual columns #2418

Open
heldersepu opened this issue Jan 25, 2024 · 1 comment
Open

snowflake_table: Add support for virtual columns #2418

heldersepu opened this issue Jan 25, 2024 · 1 comment
Labels
category:resource feature-request Used to mark issues with provider's missing functionalities resource:table Issue connected to the snowflake_table resource

Comments

@heldersepu
Copy link

heldersepu commented Jan 25, 2024

Terraform CLI and Provider Versions

Latest

Use Cases or Problem Statement

Closest "documentation" I found is this:
https://medium.com/@babak4/virtual-columns-in-snowflake-549d984c9492

Snowflake doesn’t loudly and proudly talk about this feature. The documentation references “virtual columns” when it talks about external tables, but you won’t find a heading or chapter about it in the documentation. The “virtual column” is a phrase borrowed from Oracle and MySQL that implements a similar concept. In PostgreSQL, they are known as “generated columns” and DB practitioners commonly refer to them as calculated or computed fields/columns.

A table with a calculated columns looks like

create or replace temp table tmp_daily_temperature(
  day_dt        date
  , temp_c_min  number(4, 2)
  , temp_c_max  number(4, 2)
  , temp_c_avg  number(4, 2) as (round( (temp_c_min + temp_c_max)/2, 2))
);

or something simpler:

create table foo (id bigint, id2 bigint, id3 bigint as (id + id2));

I see no way to create that using the snowflake_table resource...
As a test I created the table manually in snowflake then did a terraform import and the virtual column is invisible like it does not exist, after import the terraform plan sees no changes in a table without that column

Proposal

Ideally there should be a way to add these columns that are supported by snowflake

How much impact is this issue causing?

High

Additional Information

image

@heldersepu heldersepu added the feature-request Used to mark issues with provider's missing functionalities label Jan 25, 2024
@heldersepu heldersepu changed the title snowflake_table: Add support for calculated columns snowflake_table: Add support for calculated/virtual columns Jan 25, 2024
@heldersepu heldersepu changed the title snowflake_table: Add support for calculated/virtual columns snowflake_table: Add support for virtual columns Jan 25, 2024
@sfc-gh-asawicki
Copy link
Collaborator

Hey @heldersepu. Thanks for reaching out to us.

We have existing resources redesign on our roadmap (https://github.com/Snowflake-Labs/terraform-provider-snowflake/blob/main/ROADMAP.md#our-roadmap). I will add it to our topics list for the table resource. I don't think it will make the high or even medium prio, though; there are more essential issues we have to deal with first.

What we can do, is discuss internally how we want to support these virtual columns, and after that, we will be open for contributions. I should get back with an answer in a couple of weeks.

@sfc-gh-jcieslak sfc-gh-jcieslak added resource:table Issue connected to the snowflake_table resource category:resource labels May 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category:resource feature-request Used to mark issues with provider's missing functionalities resource:table Issue connected to the snowflake_table resource
Projects
None yet
Development

No branches or pull requests

3 participants