https://pulumi.com logo
#general
Title
# general
g

great-receptionist-19570

02/13/2024, 4:00 AM
For Snowflake is there any way to rename a column in a table using pulumi-snowflake that does not cause a
DROP COLUMN
-
ADD COLUMN
instead of what is actually desired - that being this (which is in Snowflake SQL):
Copy code
ALTER TABLE <table> RENAME COLUMN <old-name> TO <new-name>
? I know the Terraform provider does not support this and that’s going to be invariably why it’s not in pulumi, but you Pulumi are providing an API - how about adding some value on top of TF?
c

cuddly-computer-18851

02/13/2024, 4:52 AM
What would the syntax for that look like, adding a separate field to track the pulumi name vs the column name?
g

great-receptionist-19570

02/13/2024, 5:26 AM
You specify an array of Columns as per the current API - why does a change to one of the name fields in the Column object require more than issuing the ALTER command I referenced above?
I feel like I’m talking to some AI - your profile is very minimalistic.
c

cuddly-computer-18851

02/13/2024, 5:31 AM
If you change multiple elements of an array, how would it know which adds / subtractions match to a rename vs add/drop?
g

great-receptionist-19570

02/13/2024, 5:32 AM
You are modifying an existing column
c

cuddly-computer-18851

02/13/2024, 5:33 AM
Right - but lets say you modify an existing column, and also add a new one. Which is a rename and which is an add?
You could have special rules in place to deal with only allowing a single column add/drop to be a rename, but the behaviour would be inconsistent and therefore hard to guarantee safety I think.
g

great-receptionist-19570

02/13/2024, 5:36 AM
Ah well Pulumi does apparently honor column ordering. If you’ve ever tried to reorder column names by alpha, you’d see the folly in doing that. So given that constraint, the answer is obvious. But mostly as someone who’s been doing this for more than a couple of months, trying a unique identifier in your API might help. I think that’s what your resource name is about, but that is not used for columns.
@cuddly-computer-18851 do you work on the pulumi-snowflake api?
c

cuddly-computer-18851

02/13/2024, 5:38 AM
Yep, the issue here is columns are not resources w/ identifiers but merely table properties. If the snowflake API allows treating columns as first order resources, I think that would be the solution. Doing diffs by order is still risky, any number of botched Git PRs can attest to that 😃
Nope
g

great-receptionist-19570

02/13/2024, 5:38 AM
are you a pulumi employee?
c

cuddly-computer-18851

02/13/2024, 5:39 AM
Nope, merely a user
g

great-receptionist-19570

02/13/2024, 5:39 AM
Do you use pulumi-snowflake?
c

cuddly-computer-18851

02/13/2024, 5:40 AM
I have used terraform-snowflake
g

great-receptionist-19570

02/13/2024, 5:41 AM
Do you generally like APIs that try to do more than being a gateway between a system that the API owner is trying to replace and the API?
Honestly I don’t care how the solution is coded. That is not my job. I use the API to save time, and things like the lack of a rename column do not save my time.
c

cuddly-computer-18851

02/13/2024, 5:43 AM
Sorry not sure I understand the point - implementing this particular feature in a safe and consistent way requires a change in either the syntax or structure of the definition, ideally not some magic handwaving.
g

great-receptionist-19570

02/13/2024, 5:54 AM
Snowflake figured it out and has a command that does it. Just saying.
c

cuddly-computer-18851

02/13/2024, 5:57 AM
They didn't figure it out though - they require you specify the column you want to rename. In this case, there may be more than one pending operation.
g

great-receptionist-19570

02/13/2024, 6:51 AM
When I hear more than one pending operation, that sounds like an ordering dependency issue. It’s a column rename, and as an end user I should not have to mediate this. In Snowflake , column names are unique and so the rename operation just works. So, yes that means that pulumi or terraform has to do something to honor that. That or Terraform’s state cache is not a good abstract for Snowflake. My point is that we all should strive to add value with APIs and that is very true here.
c

cuddly-computer-18851

02/13/2024, 7:23 AM
"that sounds like an ordering dependency issue" - yep, that's why you need a way to tell the computer the dependency order you want - or it will make decisions that quite often be will counter to what the user wants. "as an end user I should not have to mediate this" - if as an end user you don't want to be precise in what column gets renamed to what, that's quite a worry.