-
Notifications
You must be signed in to change notification settings - Fork 426
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Fix functions and small other fixes (#2503)
- change parallel test in task - run pre-push (because main was not pre-pushed: docs and reformat) - fix materialized view datasource test - add state upgrader to function resource's id - add test utilizing older provider version References: #2490
- Loading branch information
1 parent
d301b20
commit 0d4aba4
Showing
22 changed files
with
214 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package resources | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"strings" | ||
|
||
"github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk" | ||
) | ||
|
||
type v085FunctionId struct { | ||
DatabaseName string | ||
SchemaName string | ||
FunctionName string | ||
ArgTypes []string | ||
} | ||
|
||
func parseV085FunctionId(v string) (*v085FunctionId, error) { | ||
arr := strings.Split(v, "|") | ||
if len(arr) != 4 { | ||
return nil, fmt.Errorf("ID %v is invalid", v) | ||
} | ||
|
||
return &v085FunctionId{ | ||
DatabaseName: arr[0], | ||
SchemaName: arr[1], | ||
FunctionName: arr[2], | ||
ArgTypes: strings.Split(arr[3], "-"), | ||
}, nil | ||
} | ||
|
||
func v085FunctionIdStateUpgrader(ctx context.Context, rawState map[string]interface{}, meta interface{}) (map[string]interface{}, error) { | ||
if rawState == nil { | ||
return rawState, nil | ||
} | ||
|
||
oldId := rawState["id"].(string) | ||
parsedV085FunctionId, err := parseV085FunctionId(oldId) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
argDataTypes := make([]sdk.DataType, len(parsedV085FunctionId.ArgTypes)) | ||
for i, argType := range parsedV085FunctionId.ArgTypes { | ||
argDataType, err := sdk.ToDataType(argType) | ||
if err != nil { | ||
return nil, err | ||
} | ||
argDataTypes[i] = argDataType | ||
} | ||
|
||
schemaObjectIdentifierWithArguments := sdk.NewSchemaObjectIdentifierWithArguments(parsedV085FunctionId.DatabaseName, parsedV085FunctionId.SchemaName, parsedV085FunctionId.FunctionName, argDataTypes) | ||
rawState["id"] = schemaObjectIdentifierWithArguments.FullyQualifiedName() | ||
|
||
return rawState, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
pkg/resources/testdata/TestAcc_GrantPrivilegesToShare/OnAllTablesInSchema/test.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
pkg/resources/testdata/TestAcc_GrantPrivilegesToShare/OnAllTablesInSchema_NoGrant/test.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
pkg/resources/testdata/TestAcc_GrantPrivilegesToShare/OnDatabase/test.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.