For Snowflake is there any way to rename a column ...
# general
g
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
What would the syntax for that look like, adding a separate field to track the pulumi name vs the column name?
g
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
If you change multiple elements of an array, how would it know which adds / subtractions match to a rename vs add/drop?
g
You are modifying an existing column
c
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
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
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
are you a pulumi employee?
c
Nope, merely a user
g
Do you use pulumi-snowflake?
c
I have used terraform-snowflake
g
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
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
Snowflake figured it out and has a command that does it. Just saying.
c
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
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
"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.