diff --git a/.gitignore b/.gitignore index 72891a4..de23460 100644 --- a/.gitignore +++ b/.gitignore @@ -20,6 +20,7 @@ runtime.trace .DS_Store data +nimo-shake-v* .cache/ diagnostic/ diff --git a/ChangeLog b/ChangeLog index ae1df51..df159dc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2021-05-18 + * VERSION: 1.0.12 + * BUGFIX: parse int value empty. + 2021-04-07 * VERSION: 1.0.11 * IMPROVE: data source support endpoint_url. diff --git a/src/nimo-shake/protocal/type_converter.go b/src/nimo-shake/protocal/type_converter.go index baa8395..0943b02 100644 --- a/src/nimo-shake/protocal/type_converter.go +++ b/src/nimo-shake/protocal/type_converter.go @@ -6,6 +6,7 @@ import ( "github.com/aws/aws-sdk-go/service/dynamodb" "github.com/vinllen/mgo/bson" + "github.com/vinllen/mongo-go-driver/bson/primitive" LOG "github.com/vinllen/log4go" "strconv" ) @@ -181,7 +182,8 @@ func (tc *TypeConverter) convertToDetail(name string, input interface{}) interfa return input.(bool) case "N": v := input.(string) - val, err := bson.ParseDecimal128(v) + // for new driver, we need to parse the value to mongo-go-driver.bson.decimal128, not mgo.bson.decimal128 + /* val, err := bson.ParseDecimal128(v) if err != nil { LOG.Error("convert N to decimal128 failed[%v]", err) val2, err := strconv.ParseFloat(v, 64) @@ -191,6 +193,17 @@ func (tc *TypeConverter) convertToDetail(name string, input interface{}) interfa val, _ = bson.ParseDecimal128(fmt.Sprintf("%v", val2)) return val + }*/ + val, err := primitive.ParseDecimal128(v) + if err != nil { + LOG.Error("convert N to decimal128 failed[%v]", err) + val2, err := strconv.ParseFloat(v, 64) + if err != nil { + LOG.Crashf("convert N to decimal128 and float64 both failed[%v]", err) + } + + val, _ = primitive.ParseDecimal128(fmt.Sprintf("%v", val2)) + return val } return val case "S": diff --git a/src/nimo-shake/writer/mongodb_community_driver.go b/src/nimo-shake/writer/mongodb_community_driver.go index 9f0a632..152bd9f 100644 --- a/src/nimo-shake/writer/mongodb_community_driver.go +++ b/src/nimo-shake/writer/mongodb_community_driver.go @@ -115,6 +115,7 @@ func (mcw *MongoCommunityWriter) WriteBulk(input []interface{}) error { models := make([]mongo.WriteModel, len(input)) for i := range models { models[i] = &mongo.InsertOneModel{Document: input[i]} + LOG.Debug("WriteBulk: %v", input[i]) } _, err := mcw.conn.Client.Database(mcw.ns.Database).Collection(mcw.ns.Collection).BulkWrite(nil, models)