Skip to content

Commit

Permalink
move to constant
Browse files Browse the repository at this point in the history
  • Loading branch information
Amogh-Bharadwaj committed Jan 23, 2024
1 parent 90f54a2 commit f1822a3
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
3 changes: 2 additions & 1 deletion flow/model/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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 {
Expand Down
3 changes: 3 additions & 0 deletions flow/model/numeric/scale.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package numeric

const PeerDBNumericScale = 9
3 changes: 2 additions & 1 deletion flow/model/qvalue/avro_converter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit f1822a3

Please sign in to comment.