mirror of https://github.com/milvus-io/milvus.git
issue: https://github.com/milvus-io/milvus/issues/33074 pr: #33114 --------- Signed-off-by: sunby <sunbingyi1992@gmail.com>pull/33360/head
parent
e8c9bdfa5c
commit
e3f1331c47
|
@ -525,6 +525,9 @@ func (v *validateUtil) checkArrayElement(array *schemapb.ArrayArray, field *sche
|
||||||
switch field.GetElementType() {
|
switch field.GetElementType() {
|
||||||
case schemapb.DataType_Bool:
|
case schemapb.DataType_Bool:
|
||||||
for _, row := range array.GetData() {
|
for _, row := range array.GetData() {
|
||||||
|
if row.GetData() == nil {
|
||||||
|
return merr.WrapErrParameterInvalid("bool array", "nil array", "insert data does not match")
|
||||||
|
}
|
||||||
actualType := reflect.TypeOf(row.GetData())
|
actualType := reflect.TypeOf(row.GetData())
|
||||||
if actualType != reflect.TypeOf((*schemapb.ScalarField_BoolData)(nil)) {
|
if actualType != reflect.TypeOf((*schemapb.ScalarField_BoolData)(nil)) {
|
||||||
return merr.WrapErrParameterInvalid("bool array",
|
return merr.WrapErrParameterInvalid("bool array",
|
||||||
|
@ -533,6 +536,9 @@ func (v *validateUtil) checkArrayElement(array *schemapb.ArrayArray, field *sche
|
||||||
}
|
}
|
||||||
case schemapb.DataType_Int8, schemapb.DataType_Int16, schemapb.DataType_Int32:
|
case schemapb.DataType_Int8, schemapb.DataType_Int16, schemapb.DataType_Int32:
|
||||||
for _, row := range array.GetData() {
|
for _, row := range array.GetData() {
|
||||||
|
if row.GetData() == nil {
|
||||||
|
return merr.WrapErrParameterInvalid("int array", "nil array", "insert data does not match")
|
||||||
|
}
|
||||||
actualType := reflect.TypeOf(row.GetData())
|
actualType := reflect.TypeOf(row.GetData())
|
||||||
if actualType != reflect.TypeOf((*schemapb.ScalarField_IntData)(nil)) {
|
if actualType != reflect.TypeOf((*schemapb.ScalarField_IntData)(nil)) {
|
||||||
return merr.WrapErrParameterInvalid("int array",
|
return merr.WrapErrParameterInvalid("int array",
|
||||||
|
@ -553,6 +559,9 @@ func (v *validateUtil) checkArrayElement(array *schemapb.ArrayArray, field *sche
|
||||||
}
|
}
|
||||||
case schemapb.DataType_Int64:
|
case schemapb.DataType_Int64:
|
||||||
for _, row := range array.GetData() {
|
for _, row := range array.GetData() {
|
||||||
|
if row.GetData() == nil {
|
||||||
|
return merr.WrapErrParameterInvalid("int64 array", "nil array", "insert data does not match")
|
||||||
|
}
|
||||||
actualType := reflect.TypeOf(row.GetData())
|
actualType := reflect.TypeOf(row.GetData())
|
||||||
if actualType != reflect.TypeOf((*schemapb.ScalarField_LongData)(nil)) {
|
if actualType != reflect.TypeOf((*schemapb.ScalarField_LongData)(nil)) {
|
||||||
return merr.WrapErrParameterInvalid("int64 array",
|
return merr.WrapErrParameterInvalid("int64 array",
|
||||||
|
@ -561,6 +570,9 @@ func (v *validateUtil) checkArrayElement(array *schemapb.ArrayArray, field *sche
|
||||||
}
|
}
|
||||||
case schemapb.DataType_Float:
|
case schemapb.DataType_Float:
|
||||||
for _, row := range array.GetData() {
|
for _, row := range array.GetData() {
|
||||||
|
if row.GetData() == nil {
|
||||||
|
return merr.WrapErrParameterInvalid("float array", "nil array", "insert data does not match")
|
||||||
|
}
|
||||||
actualType := reflect.TypeOf(row.GetData())
|
actualType := reflect.TypeOf(row.GetData())
|
||||||
if actualType != reflect.TypeOf((*schemapb.ScalarField_FloatData)(nil)) {
|
if actualType != reflect.TypeOf((*schemapb.ScalarField_FloatData)(nil)) {
|
||||||
return merr.WrapErrParameterInvalid("float array",
|
return merr.WrapErrParameterInvalid("float array",
|
||||||
|
@ -569,6 +581,9 @@ func (v *validateUtil) checkArrayElement(array *schemapb.ArrayArray, field *sche
|
||||||
}
|
}
|
||||||
case schemapb.DataType_Double:
|
case schemapb.DataType_Double:
|
||||||
for _, row := range array.GetData() {
|
for _, row := range array.GetData() {
|
||||||
|
if row.GetData() == nil {
|
||||||
|
return merr.WrapErrParameterInvalid("double array", "nil array", "insert data does not match")
|
||||||
|
}
|
||||||
actualType := reflect.TypeOf(row.GetData())
|
actualType := reflect.TypeOf(row.GetData())
|
||||||
if actualType != reflect.TypeOf((*schemapb.ScalarField_DoubleData)(nil)) {
|
if actualType != reflect.TypeOf((*schemapb.ScalarField_DoubleData)(nil)) {
|
||||||
return merr.WrapErrParameterInvalid("double array",
|
return merr.WrapErrParameterInvalid("double array",
|
||||||
|
@ -577,6 +592,9 @@ func (v *validateUtil) checkArrayElement(array *schemapb.ArrayArray, field *sche
|
||||||
}
|
}
|
||||||
case schemapb.DataType_VarChar, schemapb.DataType_String:
|
case schemapb.DataType_VarChar, schemapb.DataType_String:
|
||||||
for _, row := range array.GetData() {
|
for _, row := range array.GetData() {
|
||||||
|
if row.GetData() == nil {
|
||||||
|
return merr.WrapErrParameterInvalid("string array", "nil array", "insert data does not match")
|
||||||
|
}
|
||||||
actualType := reflect.TypeOf(row.GetData())
|
actualType := reflect.TypeOf(row.GetData())
|
||||||
if actualType != reflect.TypeOf((*schemapb.ScalarField_StringData)(nil)) {
|
if actualType != reflect.TypeOf((*schemapb.ScalarField_StringData)(nil)) {
|
||||||
return merr.WrapErrParameterInvalid("string array",
|
return merr.WrapErrParameterInvalid("string array",
|
||||||
|
|
|
@ -11,6 +11,7 @@ import (
|
||||||
"github.com/milvus-io/milvus-proto/go-api/v2/commonpb"
|
"github.com/milvus-io/milvus-proto/go-api/v2/commonpb"
|
||||||
"github.com/milvus-io/milvus-proto/go-api/v2/schemapb"
|
"github.com/milvus-io/milvus-proto/go-api/v2/schemapb"
|
||||||
"github.com/milvus-io/milvus/pkg/common"
|
"github.com/milvus-io/milvus/pkg/common"
|
||||||
|
"github.com/milvus-io/milvus/pkg/util/merr"
|
||||||
"github.com/milvus-io/milvus/pkg/util/paramtable"
|
"github.com/milvus-io/milvus/pkg/util/paramtable"
|
||||||
"github.com/milvus-io/milvus/pkg/util/testutils"
|
"github.com/milvus-io/milvus/pkg/util/testutils"
|
||||||
"github.com/milvus-io/milvus/pkg/util/typeutil"
|
"github.com/milvus-io/milvus/pkg/util/typeutil"
|
||||||
|
@ -3960,3 +3961,19 @@ func Test_validateUtil_checkDoubleFieldData(t *testing.T) {
|
||||||
},
|
},
|
||||||
}, nil))
|
}, nil))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestCheckArrayElementNilData(t *testing.T) {
|
||||||
|
data := &schemapb.ArrayArray{
|
||||||
|
Data: []*schemapb.ScalarField{nil},
|
||||||
|
}
|
||||||
|
|
||||||
|
fieldSchema := &schemapb.FieldSchema{
|
||||||
|
Name: "test",
|
||||||
|
DataType: schemapb.DataType_Array,
|
||||||
|
ElementType: schemapb.DataType_Int64,
|
||||||
|
}
|
||||||
|
|
||||||
|
v := newValidateUtil()
|
||||||
|
err := v.checkArrayElement(data, fieldSchema)
|
||||||
|
assert.True(t, merr.ErrParameterInvalid.Is(err))
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue