Skip to content

Commit

Permalink
Clean up.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tang8330 committed Oct 7, 2024
1 parent 2036650 commit ac863e6
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions clients/redshift/cast_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,53 @@ func (r *RedshiftTestSuite) TestReplaceExceededValues() {
}
}
}
{
// expandStringPrecision = true
{
// Irrelevant data type
{
// Integer
result := replaceExceededValues("123", typing.Integer, false, true)
assert.Equal(r.T(), "123", result.Value)
assert.Zero(r.T(), result.NewLength)
}
{
// Returns the full value since it's not a struct or string
// This is invalid and should not happen, but it's here to ensure we're only checking for structs and strings.
value := stringutil.Random(int(maxRedshiftLength + 1))
result := replaceExceededValues(value, typing.Integer, false, true)
assert.Equal(r.T(), value, result.Value)
assert.Zero(r.T(), result.NewLength)
}
}
{
// Exceeded the column string precision but not Redshift's max length
{
stringKd := typing.KindDetails{
Kind: typing.String.Kind,
OptionalStringPrecision: typing.ToPtr(int32(3)),
}

result := replaceExceededValues("hello", stringKd, true, true)
assert.Equal(r.T(), "hello", result.Value)
assert.Equal(r.T(), int32(5), result.NewLength)
}
}
{
// Exceeded both column and Redshift precision, so the value got replaced with an exceeded placeholder.
{
stringKd := typing.KindDetails{
Kind: typing.String.Kind,
OptionalStringPrecision: typing.ToPtr(maxRedshiftLength),
}

superLongString := stringutil.Random(int(maxRedshiftLength) + 1)
result := replaceExceededValues(superLongString, stringKd, false, true)
assert.Equal(r.T(), constants.ExceededValueMarker, result.Value)
assert.Zero(r.T(), result.NewLength)
}
}
}
}

func (r *RedshiftTestSuite) TestCastColValStaging() {
Expand Down

0 comments on commit ac863e6

Please sign in to comment.