-
Notifications
You must be signed in to change notification settings - Fork 427
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Removed incorrect validation on procedure resources that were causing failure of the following tests: - `TestAcc_Procedure_Java` - `TestAcc_Procedure_Scala` - Removed incorrect deprecation from table resource (#2488) - Fixed ShowByID for views (#2506) - Fixed notification_integration resource warnings for deprecated parameters (#2501) - Fixed external functions and procedure - state migrations similar to functions (#2490) References: #2501 #2506 #2488 #2490
- Loading branch information
1 parent
dfa52b2
commit a836871
Showing
14 changed files
with
459 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
package resources | ||
|
||
import ( | ||
"context" | ||
"encoding/csv" | ||
"strings" | ||
|
||
"github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk" | ||
) | ||
|
||
type v085ExternalFunctionId struct { | ||
DatabaseName string | ||
SchemaName string | ||
ExternalFunctionName string | ||
ExternalFunctionArgTypes string | ||
} | ||
|
||
func parseV085ExternalFunctionId(stringID string) (*v085ExternalFunctionId, error) { | ||
reader := csv.NewReader(strings.NewReader(stringID)) | ||
reader.Comma = '|' | ||
lines, err := reader.ReadAll() | ||
if err != nil { | ||
return nil, sdk.NewError("not CSV compatible") | ||
} | ||
|
||
if len(lines) != 1 { | ||
return nil, sdk.NewError("1 line at a time") | ||
} | ||
if len(lines[0]) != 4 { | ||
return nil, sdk.NewError("4 fields allowed") | ||
} | ||
|
||
return &v085ExternalFunctionId{ | ||
DatabaseName: lines[0][0], | ||
SchemaName: lines[0][1], | ||
ExternalFunctionName: lines[0][2], | ||
ExternalFunctionArgTypes: lines[0][3], | ||
}, nil | ||
} | ||
|
||
func v085ExternalFunctionStateUpgrader(ctx context.Context, rawState map[string]interface{}, meta interface{}) (map[string]interface{}, error) { | ||
if rawState == nil { | ||
return rawState, nil | ||
} | ||
|
||
oldId := rawState["id"].(string) | ||
parsedV085ExternalFunctionId, err := parseV085ExternalFunctionId(oldId) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
argDataTypes := make([]sdk.DataType, 0) | ||
if parsedV085ExternalFunctionId.ExternalFunctionArgTypes != "" { | ||
for _, argType := range strings.Split(parsedV085ExternalFunctionId.ExternalFunctionArgTypes, "-") { | ||
argDataType, err := sdk.ToDataType(argType) | ||
if err != nil { | ||
return nil, err | ||
} | ||
argDataTypes = append(argDataTypes, argDataType) | ||
} | ||
} | ||
|
||
schemaObjectIdentifierWithArguments := sdk.NewSchemaObjectIdentifierWithArguments(parsedV085ExternalFunctionId.DatabaseName, parsedV085ExternalFunctionId.SchemaName, parsedV085ExternalFunctionId.ExternalFunctionName, argDataTypes) | ||
rawState["id"] = schemaObjectIdentifierWithArguments.FullyQualifiedName() | ||
|
||
oldDatabase := rawState["database"].(string) | ||
oldSchema := rawState["schema"].(string) | ||
|
||
rawState["database"] = strings.Trim(oldDatabase, "\"") | ||
rawState["schema"] = strings.Trim(oldSchema, "\"") | ||
|
||
if old, isPresent := rawState["return_null_allowed"]; !isPresent || old == nil || old.(string) == "" { | ||
rawState["return_null_allowed"] = "true" | ||
} | ||
|
||
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
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
Oops, something went wrong.