From d57db14bfd82b622d45c0c3895455c14c02f0512 Mon Sep 17 00:00:00 2001 From: Robin Tang Date: Thu, 5 Sep 2024 10:39:24 -0700 Subject: [PATCH] Upgrade Deps + update references (#484) --- go.mod | 2 +- go.sum | 4 ++-- lib/debezium/converters/decimal.go | 7 ++++--- lib/debezium/converters/decimal_test.go | 9 ++++++--- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/go.mod b/go.mod index e4250d70..b32a4849 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.23.0 require ( github.com/DataDog/datadog-go/v5 v5.5.0 - github.com/artie-labs/transfer v1.26.25 + github.com/artie-labs/transfer v1.26.28 github.com/aws/aws-sdk-go-v2 v1.30.3 github.com/aws/aws-sdk-go-v2/config v1.27.27 github.com/aws/aws-sdk-go-v2/credentials v1.17.27 diff --git a/go.sum b/go.sum index 831969da..9130c731 100644 --- a/go.sum +++ b/go.sum @@ -93,8 +93,8 @@ github.com/apache/thrift v0.0.0-20181112125854-24918abba929/go.mod h1:cp2SuWMxlE github.com/apache/thrift v0.14.2/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ= github.com/apache/thrift v0.17.0 h1:cMd2aj52n+8VoAtvSvLn4kDC3aZ6IAkBuqWQ2IDu7wo= github.com/apache/thrift v0.17.0/go.mod h1:OLxhMRJxomX+1I/KUw03qoV3mMz16BwaKI+d4fPBx7Q= -github.com/artie-labs/transfer v1.26.25 h1:NnZ0eV7kpIDjf2jajJYuJksQl3B8Uy0ev7huSeeEP28= -github.com/artie-labs/transfer v1.26.25/go.mod h1:+a/UhlQVRIpdz3muS1yhSvyX42RQL0LHOdovGZfEsDE= +github.com/artie-labs/transfer v1.26.28 h1:xNPSc08jqaRa3Rrtk1kYeiC8NolngWv1o/fqXrCsKzc= +github.com/artie-labs/transfer v1.26.28/go.mod h1:+a/UhlQVRIpdz3muS1yhSvyX42RQL0LHOdovGZfEsDE= github.com/aws/aws-sdk-go v1.30.19/go.mod h1:5zCpMtNQVjRREroY7sYe8lOMRSxkhG6MZveU8YkpAk0= github.com/aws/aws-sdk-go-v2 v1.16.12/go.mod h1:C+Ym0ag2LIghJbXhfXZ0YEEp49rBWowxKzJLUoob0ts= github.com/aws/aws-sdk-go-v2 v1.30.3 h1:jUeBtG0Ih+ZIFH0F4UkmL9w3cSpaMv9tYYDbzILP8dY= diff --git a/lib/debezium/converters/decimal.go b/lib/debezium/converters/decimal.go index ce2bd0b8..22b5de1d 100644 --- a/lib/debezium/converters/decimal.go +++ b/lib/debezium/converters/decimal.go @@ -5,6 +5,7 @@ import ( "log/slog" "github.com/artie-labs/transfer/lib/debezium" + "github.com/artie-labs/transfer/lib/debezium/converters" "github.com/artie-labs/transfer/lib/typing" "github.com/cockroachdb/apd/v3" ) @@ -51,7 +52,7 @@ func encodeDecimalWithScale(decimal *apd.Decimal, scale int32) []byte { decimal = decimalWithNewExponent(decimal, targetExponent) } - bytes, _ := debezium.EncodeDecimal(decimal) + bytes, _ := converters.EncodeDecimal(decimal) return bytes } @@ -116,9 +117,9 @@ func (VariableNumericConverter) Convert(value any) (any, error) { return nil, fmt.Errorf(`unable to use %q as a decimal: %w`, stringValue, err) } - bytes, scale := debezium.EncodeDecimal(decimal) + bytes, scale := converters.EncodeDecimal(decimal) return map[string]any{ - "scale": int32(scale), + "scale": scale, "value": bytes, }, nil } diff --git a/lib/debezium/converters/decimal_test.go b/lib/debezium/converters/decimal_test.go index a82d605e..b16d7a79 100644 --- a/lib/debezium/converters/decimal_test.go +++ b/lib/debezium/converters/decimal_test.go @@ -5,8 +5,10 @@ import ( "testing" "github.com/artie-labs/transfer/lib/debezium" + "github.com/artie-labs/transfer/lib/debezium/converters" "github.com/artie-labs/transfer/lib/numbers" "github.com/artie-labs/transfer/lib/ptr" + "github.com/artie-labs/transfer/lib/typing/decimal" "github.com/cockroachdb/apd/v3" "github.com/stretchr/testify/assert" ) @@ -34,7 +36,7 @@ func TestDecimalWithNewExponent(t *testing.T) { func TestEncodeDecimalWithScale(t *testing.T) { mustEncodeAndDecodeDecimal := func(value string, scale int32) string { bytes := encodeDecimalWithScale(numbers.MustParseDecimal(value), scale) - return debezium.DecodeDecimal(bytes, scale).String() + return converters.DecodeDecimal(bytes, scale).String() } // Whole numbers: @@ -252,8 +254,9 @@ func TestVariableNumericConverter_Convert(t *testing.T) { converted, err := converter.Convert("12.34") assert.NoError(t, err) assert.Equal(t, map[string]any{"scale": int32(2), "value": []byte{0x4, 0xd2}}, converted) - actualValue, err := converter.ToField("").DecodeDebeziumVariableDecimal(converted) + + actualValue, err := converters.NewVariableDecimal().Convert(converted) assert.NoError(t, err) - assert.Equal(t, "12.34", actualValue.String()) + assert.Equal(t, "12.34", actualValue.(*decimal.Decimal).String()) } }