Skip to content

Commit

Permalink
Add more tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tang8330 committed Sep 25, 2024
1 parent cbc00a2 commit 69b6600
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
19 changes: 19 additions & 0 deletions clients/redshift/dialect/dialect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,25 @@ func TestRedshiftDialect_DataTypeForKind(t *testing.T) {
assert.Equal(t, "VARCHAR(12345)", RedshiftDialect{}.DataTypeForKind(typing.KindDetails{Kind: typing.String.Kind, OptionalStringPrecision: typing.ToPtr(int32(12345))}, false))
}
}
{
// Integers
{
// Small int
assert.Equal(t, "INT2", RedshiftDialect{}.DataTypeForKind(typing.KindDetails{Kind: typing.Integer.Kind, OptionalIntKind: typing.SmallIntegerKind}, false))
}
{
// Integer
assert.Equal(t, "INT4", RedshiftDialect{}.DataTypeForKind(typing.KindDetails{Kind: typing.Integer.Kind, OptionalIntKind: typing.IntegerKind}, false))
}
{
// Big integer
assert.Equal(t, "INT8", RedshiftDialect{}.DataTypeForKind(typing.KindDetails{Kind: typing.Integer.Kind, OptionalIntKind: typing.BigIntegerKind}, false))
}
{
// Not specified
assert.Equal(t, "INT8", RedshiftDialect{}.DataTypeForKind(typing.Integer, false))
}
}
}

func TestRedshiftDialect_KindForDataType(t *testing.T) {
Expand Down
3 changes: 3 additions & 0 deletions lib/optimization/table_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,9 @@ func (t *TableData) MergeColumnsFromDestination(destCols ...columns.Column) erro
inMemoryCol.KindDetails.OptionalStringPrecision = foundColumn.KindDetails.OptionalStringPrecision
}

// Copy over optional integer kind
inMemoryCol.KindDetails.OptionalIntKind = foundColumn.KindDetails.OptionalIntKind

// Copy over the time details
if foundColumn.KindDetails.ExtendedTimeDetails != nil {
if inMemoryCol.KindDetails.ExtendedTimeDetails == nil {
Expand Down

0 comments on commit 69b6600

Please sign in to comment.