mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-12 17:39:03 +08:00
fix: typecase support added for float to int (#5408)
This commit is contained in:
parent
2e0ddc7c7f
commit
1b0ec8ac43
@ -91,6 +91,10 @@ func ValidateAndCastValue(v interface{}, dataType v3.AttributeKeyDataType) (inte
|
||||
return x, nil
|
||||
case int, int64:
|
||||
return x, nil
|
||||
case float32:
|
||||
return int64(x), nil
|
||||
case float64:
|
||||
return int64(x), nil
|
||||
case string:
|
||||
int64val, err := strconv.ParseInt(x, 10, 64)
|
||||
if err != nil {
|
||||
|
@ -275,6 +275,24 @@ var testValidateAndCastValueData = []struct {
|
||||
want: nil,
|
||||
wantErr: true,
|
||||
},
|
||||
{
|
||||
name: "v3.AttributeKeyDataTypeInt64: valid float32",
|
||||
args: args{
|
||||
v: float32(1000),
|
||||
dataType: v3.AttributeKeyDataTypeInt64,
|
||||
},
|
||||
want: int64(1000),
|
||||
wantErr: false,
|
||||
},
|
||||
{
|
||||
name: "v3.AttributeKeyDataTypeInt64: valid float64",
|
||||
args: args{
|
||||
v: float64(1000),
|
||||
dataType: v3.AttributeKeyDataTypeInt64,
|
||||
},
|
||||
want: int64(1000),
|
||||
wantErr: false,
|
||||
},
|
||||
}
|
||||
|
||||
// Test cases for ValidateAndCastValue function in pkg/query-service/utils/format.go
|
||||
|
Loading…
x
Reference in New Issue
Block a user