mirror of
https://gitee.com/milvus-io/milvus.git
synced 2025-12-07 01:28:27 +08:00
issue: https://github.com/milvus-io/milvus/issues/46056 master pr: https://github.com/milvus-io/milvus/pull/46058 Signed-off-by: Cai Zhang <cai.zhang@zilliz.com>
This commit is contained in:
parent
e70e70699c
commit
6ce2df9944
@ -1594,6 +1594,18 @@ func convertDefaultValue(value interface{}, dataType schemapb.DataType) (*schema
|
|||||||
}
|
}
|
||||||
return data, nil
|
return data, nil
|
||||||
|
|
||||||
|
case schemapb.DataType_Geometry:
|
||||||
|
v, ok := value.(string)
|
||||||
|
if !ok {
|
||||||
|
return nil, merr.WrapErrParameterInvalidMsg(`cannot use "%v"(type: %T) as geometry default value`, value, value)
|
||||||
|
}
|
||||||
|
data := &schemapb.ValueField{
|
||||||
|
Data: &schemapb.ValueField_StringData{
|
||||||
|
StringData: v,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
return data, nil
|
||||||
|
|
||||||
case schemapb.DataType_String, schemapb.DataType_VarChar:
|
case schemapb.DataType_String, schemapb.DataType_VarChar:
|
||||||
v, ok := value.(string)
|
v, ok := value.(string)
|
||||||
if !ok {
|
if !ok {
|
||||||
|
|||||||
@ -6,7 +6,6 @@ import (
|
|||||||
"reflect"
|
"reflect"
|
||||||
|
|
||||||
"github.com/twpayne/go-geom/encoding/wkb"
|
"github.com/twpayne/go-geom/encoding/wkb"
|
||||||
"github.com/twpayne/go-geom/encoding/wkbcommon"
|
|
||||||
"github.com/twpayne/go-geom/encoding/wkt"
|
"github.com/twpayne/go-geom/encoding/wkt"
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
|
|
||||||
@ -715,16 +714,11 @@ func (v *validateUtil) checkGeometryFieldData(field *schemapb.FieldData, fieldSc
|
|||||||
msg := fmt.Sprintf("geometry field '%v' is illegal, array type mismatch", field.GetFieldName())
|
msg := fmt.Sprintf("geometry field '%v' is illegal, array type mismatch", field.GetFieldName())
|
||||||
return merr.WrapErrParameterInvalid("need geometry array", "got nil", msg)
|
return merr.WrapErrParameterInvalid("need geometry array", "got nil", msg)
|
||||||
}
|
}
|
||||||
|
var err error
|
||||||
for index, wktdata := range geometryArray {
|
for index, wktdata := range geometryArray {
|
||||||
// ignore parsed geom, the check is during insert task pre execute,so geo data became wkb
|
// ignore parsed geom, the check is during insert task pre execute,so geo data became wkb
|
||||||
// fmt.Println(strings.Trim(string(wktdata), "\""))
|
// fmt.Println(strings.Trim(string(wktdata), "\""))
|
||||||
geomT, err := wkt.Unmarshal(wktdata)
|
wkbArray[index], err = common.ConvertWKTToWKB(wktdata)
|
||||||
if err != nil {
|
|
||||||
log.Warn("insert invalid Geometry data!! The wkt data has errors", zap.Error(err))
|
|
||||||
return merr.WrapErrIoFailedReason(err.Error())
|
|
||||||
}
|
|
||||||
wkbArray[index], err = wkb.Marshal(geomT, wkb.NDR, wkbcommon.WKBOptionEmptyPointHandling(wkbcommon.EmptyPointHandlingNaN))
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Warn("insert invalid Geometry data!! Transform to wkb failed, has errors", zap.Error(err))
|
log.Warn("insert invalid Geometry data!! Transform to wkb failed, has errors", zap.Error(err))
|
||||||
return merr.WrapErrIoFailedReason(err.Error())
|
return merr.WrapErrIoFailedReason(err.Error())
|
||||||
|
|||||||
@ -23,8 +23,6 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/cockroachdb/errors"
|
"github.com/cockroachdb/errors"
|
||||||
"github.com/twpayne/go-geom/encoding/wkb"
|
|
||||||
"github.com/twpayne/go-geom/encoding/wkt"
|
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
|
|
||||||
@ -156,13 +154,7 @@ func (t *createCollectionTask) checkMaxCollectionsPerDB(ctx context.Context, db2
|
|||||||
}
|
}
|
||||||
|
|
||||||
func checkGeometryDefaultValue(value string) error {
|
func checkGeometryDefaultValue(value string) error {
|
||||||
geomT, err := wkt.Unmarshal(value)
|
if _, err := common.ConvertWKTToWKB(value); err != nil {
|
||||||
if err != nil {
|
|
||||||
log.Warn("invalid default value for geometry field", zap.Error(err))
|
|
||||||
return merr.WrapErrParameterInvalidMsg("invalid default value for geometry field")
|
|
||||||
}
|
|
||||||
_, err = wkb.Marshal(geomT, wkb.NDR)
|
|
||||||
if err != nil {
|
|
||||||
log.Warn("invalid default value for geometry field", zap.Error(err))
|
log.Warn("invalid default value for geometry field", zap.Error(err))
|
||||||
return merr.WrapErrParameterInvalidMsg("invalid default value for geometry field")
|
return merr.WrapErrParameterInvalidMsg("invalid default value for geometry field")
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user