Skip to content

Commit df00c22

Browse files
chore: Adjust to 2025_07 BCR part 1 (#4171)
- Adjust handling show output in warehouses. - Add entries to the BCR migration guide. ## References https://docs.snowflake.com/en/release-notes/bcr-bundles/2025_07
1 parent 3832a34 commit df00c22

7 files changed

+205
-56
lines changed

MIGRATION_GUIDE.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,17 @@ Now, this behavior is fixed. Here's the list of affected resources:
119119

120120
No changes in configuration and state are required.
121121

122+
### *(improvement)* Handling show_output in warehouses
123+
124+
In v2.7.0 ([migration guide](./MIGRATION_GUIDE.md#new-feature-added-support-for-generation-2-standard-warehouses-and-resource-constraints-for-snowpark-optimized-warehouses)),
125+
we added support for gen2 warehouses. In this change, we added new fields to `show_output`: `generation`, and `resource_constraint`. Before the 2025_07 bundle, the `generation` column was not available in `SHOW WAREHOUSES`. Internally, we dispatched
126+
`resource_constraint` value based on the warehouse type, and filled the values in the resource state.
127+
128+
The 2025_07 bundle adds the `generation` column (read our [BCR Migration Guide](./SNOWFLAKE_BCR_MIGRATION_GUIDE.md#new-generation-column-in-output-in-show-warehouses)). Now, instead of dispatching the `resource_constraint` value, the provider simply passes the `generation` field from Snowflake to the `show_output`.
129+
If the bundle is disabled, then the `generation` column is not present in Snowflake, and the providers behaves in the old way.
130+
131+
No changes in the configuration are necessary.
132+
122133
## v2.9.x ➞ v2.10.0
123134

124135
### *(improvement)* Features promoted to stable

SNOWFLAKE_BCR_MIGRATION_GUIDE.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,21 @@ To use the provider with the bundles containing this change:
3232

3333
Reference: [BCR-1944](https://docs.snowflake.com/release-notes/bcr-bundles/un-bundled/bcr-1944)
3434

35+
## [Bundle 2025_07](https://docs.snowflake.com/en/release-notes/bcr-bundles/2025_07_bundle)
36+
37+
### USAGE privilege on CATALOG INTEGRATION and EXTERNAL VOLUME required for database owner role for all operations
38+
39+
In certain scenarios, new privileges would be required to perform operations on catalog integrations and external volumes. You can manage these in Terraform with [grant_privileges_to_account_role](https://registry.terraform.io/providers/snowflakedb/snowflake/latest/docs/resources/grant_privileges_to_account_role)
40+
and [grant_privileges_to_database_role](https://registry.terraform.io/providers/snowflakedb/snowflake/latest/docs/resources/grant_privileges_to_database_role).
41+
42+
Reference: [BCR-2114](https://docs.snowflake.com/en/release-notes/bcr-bundles/2025_07/bcr-2114)
43+
44+
### New `generation` column in output in SHOW WAREHOUSES
45+
46+
This bundle adds the `generation` column. The values in `resource_constraint` column remain the same. The provider has been adjusted in [v2.10.1](./MIGRATION_GUIDE.md#improvement-handling-show_output-in-warehouses).
47+
48+
Reference: [BCR-2110](https://docs.snowflake.com/en/release-notes/bcr-bundles/2025_07/bcr-2110)
49+
3550
## [Bundle 2025_06](https://docs.snowflake.com/en/release-notes/bcr-bundles/2025_06_bundle)
3651

3752
### Changes in authentication policies

pkg/sdk/testint/warehouses_integration_test.go

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717

1818
func TestInt_Warehouses(t *testing.T) {
1919
client := testClient(t)
20+
secondaryClient := testSecondaryClient(t)
2021
ctx := testContext(t)
2122

2223
prefix := random.StringN(6)
@@ -217,6 +218,23 @@ func TestInt_Warehouses(t *testing.T) {
217218
assert.Equal(t, sdk.Pointer("v2"), tag2Value)
218219
})
219220

221+
t.Run("create: with generation - BCR 2025_07", func(t *testing.T) {
222+
secondaryTestClientHelper().BcrBundles.EnableBcrBundle(t, "2025_07")
223+
id := secondaryTestClientHelper().Ids.RandomAccountObjectIdentifier()
224+
225+
err := secondaryClient.Warehouses.Create(ctx, id, &sdk.CreateWarehouseOptions{
226+
Generation: sdk.Pointer(sdk.WarehouseGenerationStandardGen1),
227+
})
228+
require.NoError(t, err)
229+
230+
result, err := secondaryClient.Warehouses.ShowByID(ctx, id)
231+
require.NoError(t, err)
232+
assertThatObject(t, objectassert.WarehouseFromObject(t, result).
233+
HasGeneration(sdk.WarehouseGenerationStandardGen1).
234+
HasNoResourceConstraint(),
235+
)
236+
})
237+
220238
t.Run("create: no options", func(t *testing.T) {
221239
id := testClientHelper().Ids.RandomAccountObjectIdentifier()
222240
err := client.Warehouses.Create(ctx, id, nil)
@@ -500,7 +518,7 @@ func TestInt_Warehouses(t *testing.T) {
500518
assert.Equal(t, sdk.WarehouseResourceConstraintMemory16X, *returnedWarehouse.ResourceConstraint)
501519
})
502520

503-
t.Run("alter: set and unset generation (old resource constraint syntax)", func(t *testing.T) {
521+
setAndUnsetGenerationOld := func(t *testing.T, client *sdk.Client, testClientHelper func() *helpers.TestClient) {
504522
id := testClientHelper().Ids.RandomAccountObjectIdentifier()
505523
// new warehouse created on purpose
506524
warehouse, warehouseCleanup := testClientHelper().Warehouse.CreateWarehouseWithOptions(t, id, &sdk.CreateWarehouseOptions{})
@@ -537,9 +555,18 @@ func TestInt_Warehouses(t *testing.T) {
537555
require.NoError(t, err)
538556
assert.NotNil(t, returnedWarehouse.Generation)
539557
assert.Equal(t, sdk.WarehouseGenerationStandardGen1, *returnedWarehouse.Generation)
558+
}
559+
560+
t.Run("alter: set and unset generation (old resource constraint syntax)", func(t *testing.T) {
561+
setAndUnsetGenerationOld(t, client, testClientHelper)
540562
})
541563

542-
t.Run("alter: set and unset generation (new generation syntax)", func(t *testing.T) {
564+
t.Run("alter: set and unset generation (old resource constraint syntax) - BCR 2025_07", func(t *testing.T) {
565+
secondaryTestClientHelper().BcrBundles.EnableBcrBundle(t, "2025_07")
566+
setAndUnsetGenerationOld(t, secondaryClient, secondaryTestClientHelper)
567+
})
568+
569+
setAndUnsetGeneration := func(t *testing.T, client *sdk.Client, testClientHelper func() *helpers.TestClient) {
543570
id := testClientHelper().Ids.RandomAccountObjectIdentifier()
544571
// new warehouse created on purpose
545572
warehouse, warehouseCleanup := testClientHelper().Warehouse.CreateWarehouseWithOptions(t, id, &sdk.CreateWarehouseOptions{})
@@ -576,6 +603,15 @@ func TestInt_Warehouses(t *testing.T) {
576603
require.NoError(t, err)
577604
assert.NotNil(t, returnedWarehouse.Generation)
578605
assert.Equal(t, sdk.WarehouseGenerationStandardGen1, *returnedWarehouse.Generation)
606+
}
607+
608+
t.Run("alter: set and unset generation (new generation syntax)", func(t *testing.T) {
609+
setAndUnsetGeneration(t, client, testClientHelper)
610+
})
611+
612+
t.Run("alter: set and unset generation (new generation syntax) - BCR 2025_07", func(t *testing.T) {
613+
testClientHelper().BcrBundles.EnableBcrBundle(t, "2025_07")
614+
setAndUnsetGeneration(t, secondaryClient, secondaryTestClientHelper)
579615
})
580616

581617
t.Run("alter: set and unset generation (both at the same time)", func(t *testing.T) {

pkg/sdk/warehouses.go

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -643,6 +643,7 @@ type warehouseDBRow struct {
643643
ScalingPolicy string `db:"scaling_policy"`
644644
OwnerRoleType sql.NullString `db:"owner_role_type"`
645645
ResourceConstraint sql.NullString `db:"resource_constraint"`
646+
Generation sql.NullString `db:"generation"`
646647
}
647648

648649
func (row warehouseDBRow) convert() (*Warehouse, error) {
@@ -709,23 +710,29 @@ func (row warehouseDBRow) convert() (*Warehouse, error) {
709710
if row.ResourceMonitor != "null" {
710711
wh.ResourceMonitor = NewAccountObjectIdentifierFromFullyQualifiedName(row.ResourceMonitor)
711712
}
713+
if row.Generation.Valid {
714+
generation, err := ToWarehouseGeneration(row.Generation.String)
715+
if err != nil {
716+
return nil, err
717+
}
718+
wh.Generation = &generation
719+
}
712720
if row.ResourceConstraint.Valid {
721+
resourceConstraint, err := ToWarehouseResourceConstraint(row.ResourceConstraint.String)
722+
if err != nil {
723+
return nil, err
724+
}
713725
switch wh.Type {
714726
case WarehouseTypeStandard:
715-
resourceConstraint, err := ToWarehouseResourceConstraint(row.ResourceConstraint.String)
716-
if err != nil {
717-
return nil, err
718-
}
719-
generation, err := resourceConstraint.ToWarehouseGeneration()
720-
if err != nil {
721-
return nil, err
727+
// Before BCR 2025_07, the generation column was not present, so we converted the resource constraint to generation.
728+
if wh.Generation == nil {
729+
generation, err := resourceConstraint.ToWarehouseGeneration()
730+
if err != nil {
731+
return nil, err
732+
}
733+
wh.Generation = &generation
722734
}
723-
wh.Generation = &generation
724735
case WarehouseTypeSnowparkOptimized:
725-
resourceConstraint, err := ToWarehouseResourceConstraint(row.ResourceConstraint.String)
726-
if err != nil {
727-
return nil, err
728-
}
729736
wh.ResourceConstraint = &resourceConstraint
730737
default:
731738
return nil, fmt.Errorf("invalid warehouse type: %s", wh.Type)

pkg/testacc/1_setup_provider_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ import (
1818
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
1919
)
2020

21+
type ProviderFactory = map[string]func() (tfprotov6.ProviderServer, error)
22+
2123
var (
2224
// TODO [SNOW-2661409]: check all the places using TestAccProvider directly
2325
TestAccProvider *schema.Provider

0 commit comments

Comments
 (0)