Skip to content

Commit

Permalink
Fix minor stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-asawicki committed Nov 20, 2023
1 parent 06ae64c commit cb1ea66
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 14 deletions.
3 changes: 3 additions & 0 deletions pkg/sdk/external_tables_dto.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ func (v *ColumnInlineConstraintRequest) toOpts() *ColumnInlineConstraint {
}

func (v *InlineForeignKeyRequest) toOpts() *InlineForeignKey {
if v == nil {
return nil
}
return &InlineForeignKey{
TableName: v.TableName,
ColumnName: v.ColumnName,
Expand Down
10 changes: 5 additions & 5 deletions pkg/sdk/parameters.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,12 +266,12 @@ func (parameters *parameters) SetObjectParameterOnAccount(ctx context.Context, p
}

type setParameterOnObject struct {
alter bool `ddl:"static" sql:"ALTER"` //lint:ignore U1000 This is used in the ddl tag
alter bool `ddl:"static" sql:"ALTER"`
objectType ObjectType `ddl:"keyword"`
objectIdentifier ObjectIdentifier `ddl:"identifier"`
set bool `ddl:"static" sql:"SET"` //lint:ignore U1000 This is used in the ddl tag
set bool `ddl:"static" sql:"SET"`
parameterKey ObjectParameter `ddl:"keyword"`
equals bool `ddl:"static" sql:"="` //lint:ignore U1000 This is used in the ddl tag
equals bool `ddl:"static" sql:"="`
parameterValue string `ddl:"keyword"`
}

Expand Down Expand Up @@ -829,8 +829,8 @@ type UserParametersUnset struct {

// ShowParametersOptions is based on https://docs.snowflake.com/en/sql-reference/sql/show-parameters.
type ShowParametersOptions struct {
show bool `ddl:"static" sql:"SHOW"` //lint:ignore U1000 This is used in the ddl tag
parameters bool `ddl:"static" sql:"PARAMETERS"` //lint:ignore U1000 This is used in the ddl tag
show bool `ddl:"static" sql:"SHOW"`
parameters bool `ddl:"static" sql:"PARAMETERS"`
Like *Like `ddl:"keyword" sql:"LIKE"`
In *ParametersIn `ddl:"keyword" sql:"IN"`
}
Expand Down
14 changes: 14 additions & 0 deletions pkg/sdk/table_dto.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ type ColumnIdentityRequest struct {
Start int // required
Increment int // required
}

type ColumnMaskingPolicyRequest struct {
with *bool
name SchemaObjectIdentifier // required
Expand Down Expand Up @@ -326,6 +327,7 @@ type TableClusteringActionRequest struct {
ChangeReclusterState *ReclusterState
DropClusteringKey *bool
}

type TableReclusterActionRequest struct {
MaxSize *int
Condition *string
Expand Down Expand Up @@ -363,6 +365,7 @@ type TableColumnAddInlineConstraintRequest struct {
Type ColumnConstraintType
ForeignKey *ColumnAddForeignKey
}

type ColumnAddForeignKeyRequest struct {
TableName string
ColumnName string
Expand All @@ -385,15 +388,18 @@ type TableColumnAlterActionRequest struct {
Comment *string
UnsetComment *bool
}

type TableColumnAlterSetMaskingPolicyActionRequest struct {
ColumnName string // required
MaskingPolicyName SchemaObjectIdentifier // required
Using []string // required
Force *bool
}

type TableColumnAlterUnsetMaskingPolicyActionRequest struct {
ColumnName string // required
}

type TableColumnAlterSetTagsActionRequest struct {
ColumnName string // required
Tags []TagAssociation // required
Expand All @@ -408,16 +414,19 @@ type TableColumnNotNullConstraintRequest struct {
Set *bool
Drop *bool
}

type TableConstraintActionRequest struct {
Add *OutOfLineConstraintRequest
Rename *TableConstraintRenameActionRequest
Alter *TableConstraintAlterActionRequest
Drop *TableConstraintDropActionRequest
}

type TableConstraintRenameActionRequest struct {
OldName string
NewName string
}

type TableConstraintAlterActionRequest struct {
// One of
ConstraintName *string
Expand All @@ -434,6 +443,7 @@ type TableConstraintAlterActionRequest struct {
Rely *bool
NoRely *bool
}

type TableConstraintDropActionRequest struct {
// One of
ConstraintName *string
Expand Down Expand Up @@ -477,6 +487,7 @@ type TableExternalTableColumnAddActionRequest struct {
Type DataType
Expression []string
}

type TableExternalTableColumnRenameActionRequest struct {
OldName string
NewName string
Expand All @@ -485,6 +496,7 @@ type TableExternalTableColumnRenameActionRequest struct {
type TableExternalTableColumnDropActionRequest struct {
Columns []string
}

type ShowTableByIdRequest struct {
Terse *bool
History *bool
Expand All @@ -493,6 +505,7 @@ type ShowTableByIdRequest struct {
StartsWith *string
LimitFrom *LimitFrom
}

type ShowTableRequest struct {
Terse *bool
History *bool
Expand All @@ -501,6 +514,7 @@ type ShowTableRequest struct {
StartsWith *string
LimitFrom *LimitFrom
}

type ShowTableInRequest struct {
Account *bool
Database AccountObjectIdentifier
Expand Down
18 changes: 9 additions & 9 deletions pkg/sdk/tables.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,8 @@ type StageCopyOptionsInnerValue struct {
}

type alterTableOptions struct {
alter bool `ddl:"static" sql:"ALTER"` //lint:ignore U1000 This is used in the ddl tag
table bool `ddl:"static" sql:"TABLE"` //lint:ignore U1000 This is used in the ddl tag
alter bool `ddl:"static" sql:"ALTER"`
table bool `ddl:"static" sql:"TABLE"`
IfExists *bool `ddl:"keyword" sql:"IF EXISTS"`
name SchemaObjectIdentifier `ddl:"identifier"`

Expand Down Expand Up @@ -264,7 +264,7 @@ type TableReclusterAction struct {

type TableReclusterChangeState struct {
State *ReclusterState `ddl:"keyword"`
recluster bool `ddl:"static" sql:"RECLUSTER"` //lint:ignore U1000 This is used in the ddl tag
recluster bool `ddl:"static" sql:"RECLUSTER"`
}

type ReclusterState string
Expand Down Expand Up @@ -343,22 +343,22 @@ type TableColumnAlterUnsetMaskingPolicyAction struct {
}

type TableColumnAlterSetTagsAction struct {
alter bool `ddl:"static" sql:"ALTER COLUMN"` //lint:ignore U1000 This is used in the ddl tag
alter bool `ddl:"static" sql:"ALTER COLUMN"`
ColumnName string `ddl:"keyword"`
set bool `ddl:"static" sql:"SET"` //lint:ignore U1000 This is used in the ddl tag
set bool `ddl:"static" sql:"SET"`
Tags []TagAssociation `ddl:"keyword" sql:"TAG"`
}

type TableColumnAlterUnsetTagsAction struct {
alter bool `ddl:"static" sql:"ALTER COLUMN"` //lint:ignore U1000 This is used in the ddl tag
alter bool `ddl:"static" sql:"ALTER COLUMN"`
ColumnName string `ddl:"keyword"`
unset bool `ddl:"static" sql:"UNSET"` //lint:ignore U1000 This is used in the ddl tag
unset bool `ddl:"static" sql:"UNSET"`
Tags []ObjectIdentifier `ddl:"keyword" sql:"TAG"`
}

type TableColumnAlterDropColumns struct {
dropColumn bool `ddl:"static" sql:"DROP COLUMN"` //lint:ignore U1000 This is used in the ddl tag
Columns []string `ddl:"keyword"` //lint:ignore U1000 This is used in the ddl tag
dropColumn bool `ddl:"static" sql:"DROP COLUMN"`
Columns []string `ddl:"keyword"`
}

type TableColumnAlterSequenceName interface {
Expand Down
7 changes: 7 additions & 0 deletions pkg/sdk/testint/tables_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ func TestInt_Table(t *testing.T) {

assert.Equal(t, table.Name, name)
})

t.Run("create table: complete optionals", func(t *testing.T) {
maskingPolicy, _ := createMaskingPolicyWithOptions(t, client, database, schema, []sdk.TableColumnSignature{
{
Expand Down Expand Up @@ -204,6 +205,7 @@ func TestInt_Table(t *testing.T) {
assert.True(t, sourceTableColumns[i] == likeTableColumns[i])
}
})

t.Run("create table clone", func(t *testing.T) {
sourceTable, _ := createTable(t, client, database, schema)
name := random.String()
Expand Down Expand Up @@ -419,6 +421,7 @@ func TestInt_Table(t *testing.T) {
err = client.Tables.Alter(ctx, alterRequest)
require.NoError(t, err)
})

t.Run("alter table: set tags", func(t *testing.T) {
name := random.String()
id := sdk.NewSchemaObjectIdentifier(database.Name, schema.Name, name)
Expand All @@ -444,6 +447,7 @@ func TestInt_Table(t *testing.T) {
err = client.Tables.Alter(ctx, alterRequest)
require.NoError(t, err)
})

t.Run("alter table: unset tags", func(t *testing.T) {
columnTags := []sdk.TagAssociationRequest{
{
Expand Down Expand Up @@ -546,6 +550,7 @@ func TestInt_Table(t *testing.T) {
err = client.Tables.Alter(ctx, alterRequest)
require.NoError(t, err)
})

t.Run("alter constraint: alter", func(t *testing.T) {
name := random.String()
id := sdk.NewSchemaObjectIdentifier(database.Name, schema.Name, name)
Expand Down Expand Up @@ -826,6 +831,7 @@ func TestInt_Table(t *testing.T) {
assert.Empty(t, table2.Owner)
require.NoError(t, err)
})

t.Run("with starts with", func(t *testing.T) {
table, tableCleanup := createTable(t, client, database, schema)
t.Cleanup(tableCleanup)
Expand All @@ -837,6 +843,7 @@ func TestInt_Table(t *testing.T) {
assert.NotEmpty(t, table2.Owner)
require.NoError(t, err)
})

t.Run("when searching a non-existent table", func(t *testing.T) {
tables, err := client.Tables.Show(ctx, sdk.NewShowTableRequest().WithLikePattern("non-existent"))
require.NoError(t, err)
Expand Down

0 comments on commit cb1ea66

Please sign in to comment.