diff --git a/flow/model/model.go b/flow/model/model.go index b3bd44b0ed..20f90af3ee 100644 --- a/flow/model/model.go +++ b/flow/model/model.go @@ -12,6 +12,7 @@ import ( "github.com/PeerDB-io/peer-flow/generated/protos" hstore_util "github.com/PeerDB-io/peer-flow/hstore" + "github.com/PeerDB-io/peer-flow/model/numeric" "github.com/PeerDB-io/peer-flow/model/qvalue" "github.com/PeerDB-io/peer-flow/peerdbenv" ) @@ -215,7 +216,7 @@ func (r *RecordItems) toMap(hstoreAsJSON bool) (map[string]interface{}, error) { if !ok { return nil, errors.New("expected *big.Rat value") } - jsonStruct[col] = bigRat.FloatString(9) + jsonStruct[col] = bigRat.FloatString(numeric.PeerDBNumericScale) case qvalue.QValueKindFloat64: floatVal, ok := v.Value.(float64) if !ok { diff --git a/flow/model/numeric/scale.go b/flow/model/numeric/scale.go new file mode 100644 index 0000000000..5ce1ecd024 --- /dev/null +++ b/flow/model/numeric/scale.go @@ -0,0 +1,3 @@ +package numeric + +const PeerDBNumericScale = 9 diff --git a/flow/model/qvalue/avro_converter.go b/flow/model/qvalue/avro_converter.go index c3912ecd98..f404df7e73 100644 --- a/flow/model/qvalue/avro_converter.go +++ b/flow/model/qvalue/avro_converter.go @@ -7,6 +7,7 @@ import ( "time" hstore_util "github.com/PeerDB-io/peer-flow/hstore" + "github.com/PeerDB-io/peer-flow/model/numeric" "github.com/google/uuid" "github.com/linkedin/goavro/v2" ) @@ -323,7 +324,7 @@ func (c *QValueAvroConverter) processNumeric() (interface{}, error) { return nil, fmt.Errorf("invalid Numeric value: expected *big.Rat, got %T", c.Value.Value) } - scale := 9 + scale := numeric.PeerDBNumericScale decimalValue := num.FloatString(scale) num.SetString(decimalValue) if c.Nullable {