-
Notifications
You must be signed in to change notification settings - Fork 420
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
feat: Stream on table resource #3109
Conversation
Integration tests failure for 66bd22b103e4ff516a40f9da7ce174abf8a78629 |
Integration tests failure for c67968c20a4f56b0c6e02df2909021f83c8e5041 |
pkg/acceptance/bettertestspoc/assert/objectassert/stream_snowflake_ext.go
Outdated
Show resolved
Hide resolved
pkg/acceptance/bettertestspoc/assert/resourceshowoutputassert/stream_show_output_ext.go
Show resolved
Hide resolved
pkg/resources/stream_on_table.go
Outdated
} | ||
|
||
if v := d.Get("copy_grants"); v.(bool) { | ||
req.WithCopyGrants(true).WithOrReplace(true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is OrReplace needed here? It allows for possible overriding of already existing stream, without it the task will use OrReplace only when modified attribute cannot be altered.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's needed because otherwise when you have COPY GRANTS without OR REPLACE, Snowflake fails.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right about the need for orReplace needed with copy grants but I am with @sfc-gh-jcieslak here: we should steer the copy grants logic, and use it only when we need to replace the stream and not by default in create
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't use OR REPLACE by default. It's used when the stream is already in the state, and detect changes on fields that can't be updated, because ForceNew drops the grants. In the second case, when it's not in the state, and the user wants COPY GRANTS to preserve old grants. In other cases, we don't use OR REPLACE.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I disagree with the second case. IMO a new create should be done without copy grants and without or replace. Thge assumption should be, that if we are creating a new object, the copy grants do not matter. Copy grants should be used only in the first scenario you mentioned (so the object is already managed and we discover changes).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed again.
Integration tests cancelled for d61356336d2253d924befc0e47db4006421c81b4 |
Integration tests failure for c1f7c234fcd8962531b2672c8f10191f471b0ae3 |
pkg/acceptance/bettertestspoc/assert/resourceshowoutputassert/stream_show_output_ext.go
Show resolved
Hide resolved
pkg/resources/stream_on_table.go
Outdated
} | ||
|
||
if v := d.Get("copy_grants"); v.(bool) { | ||
req.WithCopyGrants(true).WithOrReplace(true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right about the need for orReplace needed with copy grants but I am with @sfc-gh-jcieslak here: we should steer the copy grants logic, and use it only when we need to replace the stream and not by default in create
table, cleanupTable := acc.TestClient().Table.CreateWithChangeTracking(t) | ||
t.Cleanup(cleanupTable) | ||
|
||
baseModel := func() *model.StreamOnTableModel { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: this could be added as Base(id, table_id) func in _ext.go
file for model
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but I'll leave this for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why? For consistency we should have a way of defining a default/common base for model.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Next PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I'll do this in the next pr.
Integration tests failure for bb56ac99ba21c82519f5a5a17a498893f2acc4cf |
Integration tests failure for 5ba98dd58fa3be86e55c8e4bfcb4061d2eaded4a |
Integration tests failure for 72e29d3f49ebc019e54bac1384b9e203210b15d9 |
Integration tests failure for 7cb18a96e580feb3bd49e1734ade447c8f735ae3 |
Integration tests failure for 08c9c852fe81b9a76f4d76583ed4ea66cf195f10 |
Integration tests failure for 81dec99a87740624ce17a68afb3914dc5f43a9a3 |
Integration tests failure for 5a16dd94cdd87b082fcb66aede700b9bed79e0da |
@@ -63,7 +63,7 @@ resource "snowflake_stream_on_table" "stream" { | |||
- `at` (Block List, Max: 1) This field specifies that the request is inclusive of any changes made by a statement or transaction with a timestamp equal to the specified parameter. Due to Snowflake limitations, the provider does not detect external changes on this field. External changes for this field won't be detected. In case you want to apply external changes, you can re-create the resource manually using "terraform taint". (see [below for nested schema](#nestedblock--at)) | |||
- `before` (Block List, Max: 1) This field specifies that the request refers to a point immediately preceding the specified parameter. This point in time is just before the statement, identified by its query ID, is completed. Due to Snowflake limitations, the provider does not detect external changes on this field. External changes for this field won't be detected. In case you want to apply external changes, you can re-create the resource manually using "terraform taint". (see [below for nested schema](#nestedblock--before)) | |||
- `comment` (String) Specifies a comment for the stream. | |||
- `copy_grants` (Boolean) Retains the access permissions from the original stream when a new stream is created using the OR REPLACE clause. Use only if the resource is already managed by Terraform. | |||
- `copy_grants` (Boolean) Retains the access permissions from the original stream when a new stream is created using the OR REPLACE clause. Use only if the resource is already managed by Terraform. Otherwise, this field is skipped. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would change the description of this field to something similar to:
Retains the access permissions from the original stream when a new stream is created using the OR REPLACE clause that is sometimes used when updating the stream. The value won't have any effect when creating a new stream.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I'll rephrase this in the next pr.
🤖 I have created a release *beep* *boop* --- ## [0.97.0](v0.96.0...v0.97.0) (2024-10-10) ### 🎉 **What's new:** * Add secret to sdk ([#3091](#3091)) ([7430aee](7430aee)) * Add service user and legacy service user resources ([#3119](#3119)) ([0e88e08](0e88e08)) * Handle all Task parameters in SDK ([#3103](#3103)) ([08ae072](08ae072)) * Stream on external table resource ([#3122](#3122)) ([d837341](d837341)) * Stream on table resource ([#3109](#3109)) ([97fa9b4](97fa9b4)) * Tasks v1 readiness - SDK part ([#3086](#3086)) ([0a77383](0a77383)) * Upgrade stream sdk ([#3105](#3105)) ([ad5fa11](ad5fa11)) ### 🔧 **Misc** * Add pre check to each datasource ([#3065](#3065)) ([560ab6b](560ab6b)) * Bump golang-ci lint to 1.61 ([#3112](#3112)) ([f23e085](f23e085)) * Secret Validation change ([#3111](#3111)) ([666630e](666630e)) ### 🐛 **Bug fixes:** * Fix parsing text in view, check parenthesis in ParseSchemaObjectIdentifierWithArguments ([#3102](#3102)) ([b0a67e6](b0a67e6)) * Try to reproduce 2679 and 3117 ([#3124](#3124)) ([ccdbc30](ccdbc30)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: snowflake-release-please[bot] <105954990+snowflake-release-please[bot]@users.noreply.github.com>
snowflake_stream_on_table
resourceLastQueryId
to the context clientTest Plan
References
https://docs.snowflake.com/en/sql-reference/sql/create-stream
TODO
Add remaining resources (external table, stage, view). Rework data source.