-
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.
adds sequences to sdk https://docs.snowflake.com/en/sql-reference/sql/create-sequence
- Loading branch information
1 parent
8c03ffb
commit d2e5ffd
Showing
12 changed files
with
1,049 additions
and
0 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,124 @@ | ||
package sdk | ||
|
||
import g "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk/poc/generator" | ||
|
||
//go:generate go run ./poc/main.go | ||
|
||
var sequenceSet = g.NewQueryStruct("SequenceSet"). | ||
PredefinedQueryStructField("ValuesBehavior", "*ValuesBehavior", g.KeywordOptions()). | ||
OptionalTextAssignment("COMMENT", g.ParameterOptions().SingleQuotes()) | ||
|
||
var sequenceConstraint = g.NewQueryStruct("SequenceConstraint"). | ||
OptionalSQL("CASCADE"). | ||
OptionalSQL("RESTRICT"). | ||
WithValidation(g.ExactlyOneValueSet, "Cascade", "Restrict") | ||
|
||
var SequencesDef = g.NewInterface( | ||
"Sequences", | ||
"Sequence", | ||
g.KindOfT[SchemaObjectIdentifier](), | ||
).CreateOperation( | ||
"https://docs.snowflake.com/en/sql-reference/sql/create-sequence", | ||
g.NewQueryStruct("CreateSequence"). | ||
Create(). | ||
OrReplace(). | ||
SQL("SEQUENCE"). | ||
IfNotExists(). | ||
Name(). | ||
OptionalNumberAssignment("START", g.ParameterOptions().NoQuotes()). | ||
OptionalNumberAssignment("INCREMENT", g.ParameterOptions().NoQuotes()). | ||
PredefinedQueryStructField("ValuesBehavior", "*ValuesBehavior", g.KeywordOptions()). | ||
OptionalTextAssignment("COMMENT", g.ParameterOptions().SingleQuotes()). | ||
WithValidation(g.ValidIdentifier, "name"). | ||
WithValidation(g.ConflictingFields, "OrReplace", "IfNotExists"), | ||
).AlterOperation( | ||
"https://docs.snowflake.com/en/sql-reference/sql/alter-sequence", | ||
g.NewQueryStruct("AlterSequence"). | ||
Alter(). | ||
SQL("SEQUENCE"). | ||
IfExists(). | ||
Name(). | ||
Identifier("RenameTo", g.KindOfTPointer[SchemaObjectIdentifier](), g.IdentifierOptions().SQL("RENAME TO")). | ||
OptionalNumberAssignment("SET INCREMENT", g.ParameterOptions().NoQuotes()). | ||
OptionalQueryStructField( | ||
"Set", | ||
sequenceSet, | ||
g.KeywordOptions().SQL("SET"), | ||
). | ||
OptionalSQL("UNSET COMMENT"). | ||
WithValidation(g.ValidIdentifier, "name"). | ||
WithValidation(g.ValidIdentifierIfSet, "RenameTo"). | ||
WithValidation(g.ExactlyOneValueSet, "RenameTo", "SetIncrement", "Set", "UnsetComment"), | ||
).ShowOperation( | ||
"https://docs.snowflake.com/en/sql-reference/sql/show-sequences", | ||
g.DbStruct("sequenceRow"). | ||
Field("created_on", "string"). | ||
Field("name", "string"). | ||
Field("schema_name", "string"). | ||
Field("database_name", "string"). | ||
Field("next_value", "int"). | ||
Field("interval", "int"). | ||
Field("owner", "string"). | ||
Field("owner_role_type", "string"). | ||
Field("comment", "string"). | ||
Field("ordered", "string"), | ||
g.PlainStruct("Sequence"). | ||
Field("CreatedOn", "string"). | ||
Field("Name", "string"). | ||
Field("SchemaName", "string"). | ||
Field("DatabaseName", "string"). | ||
Field("NextValue", "int"). | ||
Field("Interval", "int"). | ||
Field("Owner", "string"). | ||
Field("OwnerRoleType", "string"). | ||
Field("Comment", "string"). | ||
Field("Ordered", "bool"), | ||
g.NewQueryStruct("ShowSequences"). | ||
Show(). | ||
SQL("SEQUENCES"). | ||
OptionalLike(). | ||
OptionalIn(), | ||
).ShowByIdOperation().DescribeOperation( | ||
g.DescriptionMappingKindSingleValue, | ||
"https://docs.snowflake.com/en/sql-reference/sql/desc-sequence", | ||
g.DbStruct("sequenceDetailRow"). | ||
Field("created_on", "string"). | ||
Field("name", "string"). | ||
Field("schema_name", "string"). | ||
Field("database_name", "string"). | ||
Field("next_value", "int"). | ||
Field("interval", "int"). | ||
Field("owner", "string"). | ||
Field("owner_role_type", "string"). | ||
Field("comment", "string"). | ||
Field("ordered", "string"), | ||
g.PlainStruct("SequenceDetail"). | ||
Field("CreatedOn", "string"). | ||
Field("Name", "string"). | ||
Field("SchemaName", "string"). | ||
Field("DatabaseName", "string"). | ||
Field("NextValue", "int"). | ||
Field("Interval", "int"). | ||
Field("Owner", "string"). | ||
Field("OwnerRoleType", "string"). | ||
Field("Comment", "string"). | ||
Field("Ordered", "bool"), | ||
g.NewQueryStruct("DescribeSequence"). | ||
Describe(). | ||
SQL("SEQUENCE"). | ||
Name(). | ||
WithValidation(g.ValidIdentifier, "name"), | ||
).DropOperation( | ||
"https://docs.snowflake.com/en/sql-reference/sql/drop-sequence", | ||
g.NewQueryStruct("DropSequence"). | ||
Drop(). | ||
SQL("SEQUENCE"). | ||
IfExists(). | ||
Name(). | ||
OptionalQueryStructField( | ||
"Constraint", | ||
sequenceConstraint, | ||
g.KeywordOptions(), | ||
). | ||
WithValidation(g.ValidIdentifier, "name"), | ||
) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,55 @@ | ||
package sdk | ||
|
||
//go:generate go run ./dto-builder-generator/main.go | ||
|
||
var ( | ||
_ optionsProvider[CreateSequenceOptions] = new(CreateSequenceRequest) | ||
_ optionsProvider[AlterSequenceOptions] = new(AlterSequenceRequest) | ||
_ optionsProvider[ShowSequenceOptions] = new(ShowSequenceRequest) | ||
_ optionsProvider[DescribeSequenceOptions] = new(DescribeSequenceRequest) | ||
_ optionsProvider[DropSequenceOptions] = new(DropSequenceRequest) | ||
) | ||
|
||
type CreateSequenceRequest struct { | ||
OrReplace *bool | ||
IfNotExists *bool | ||
name SchemaObjectIdentifier // required | ||
Start *int | ||
Increment *int | ||
ValuesBehavior *ValuesBehavior | ||
Comment *string | ||
} | ||
|
||
type AlterSequenceRequest struct { | ||
IfExists *bool | ||
name SchemaObjectIdentifier // required | ||
RenameTo *SchemaObjectIdentifier | ||
SetIncrement *int | ||
Set *SequenceSetRequest | ||
UnsetComment *bool | ||
} | ||
|
||
type SequenceSetRequest struct { | ||
ValuesBehavior *ValuesBehavior | ||
Comment *string | ||
} | ||
|
||
type ShowSequenceRequest struct { | ||
Like *Like | ||
In *In | ||
} | ||
|
||
type DescribeSequenceRequest struct { | ||
name SchemaObjectIdentifier // required | ||
} | ||
|
||
type DropSequenceRequest struct { | ||
IfExists *bool | ||
name SchemaObjectIdentifier // required | ||
Constraint *SequenceConstraintRequest | ||
} | ||
|
||
type SequenceConstraintRequest struct { | ||
Cascade *bool | ||
Restrict *bool | ||
} |
Oops, something went wrong.