mirror of https://github.com/milvus-io/milvus.git
fix: forbid insert array data (#28737)
- forbid Array type data inserting as v2.2.x doesn't support it - forbid creating collection with unsupported data type --------- Signed-off-by: yah01 <yah2er0ne@outlook.com>pull/28764/head
parent
301243b03d
commit
8d8fda19bd
|
@ -18,6 +18,7 @@
|
|||
#include <unordered_map>
|
||||
#include <utility>
|
||||
|
||||
#include "common/FieldMeta.h"
|
||||
#include "common/Schema.h"
|
||||
#include "common/Types.h"
|
||||
#include "segcore/AckResponder.h"
|
||||
|
@ -161,7 +162,7 @@ struct InsertRecord {
|
|||
break;
|
||||
}
|
||||
default: {
|
||||
PanicInfo("unsupported pk type");
|
||||
PanicInfo("unsupported pk type " + datatype_name(field_meta.get_data_type()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -173,7 +174,7 @@ struct InsertRecord {
|
|||
this->append_field_data<BinaryVector>(field_id, field_meta.get_dim(), size_per_chunk);
|
||||
continue;
|
||||
} else {
|
||||
PanicInfo("unsupported");
|
||||
PanicInfo("unsupported vector type " + datatype_name(field_meta.get_data_type()));
|
||||
}
|
||||
}
|
||||
switch (field_meta.get_data_type()) {
|
||||
|
@ -213,13 +214,8 @@ struct InsertRecord {
|
|||
this->append_field_data<Json>(field_id, size_per_chunk);
|
||||
break;
|
||||
}
|
||||
// case DataType::ARRAY: {
|
||||
// this->append_field_data<std::string>(field_id,
|
||||
// size_per_chunk);
|
||||
// break;
|
||||
// }
|
||||
default: {
|
||||
PanicInfo("unsupported");
|
||||
PanicInfo("unsupported data type " + datatype_name(field_meta.get_data_type()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -278,7 +274,7 @@ struct InsertRecord {
|
|||
break;
|
||||
}
|
||||
default: {
|
||||
PanicInfo("unsupported primary key data type");
|
||||
PanicInfo("unsupported pk type " + datatype_name(data_type));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -342,10 +342,28 @@ func validateDuplicatedFieldName(fields []*schemapb.FieldSchema) error {
|
|||
func validateFieldType(schema *schemapb.CollectionSchema) error {
|
||||
for _, field := range schema.GetFields() {
|
||||
switch field.GetDataType() {
|
||||
case
|
||||
// scalar types
|
||||
schemapb.DataType_Bool,
|
||||
schemapb.DataType_Int8,
|
||||
schemapb.DataType_Int16,
|
||||
schemapb.DataType_Int32,
|
||||
schemapb.DataType_Int64,
|
||||
schemapb.DataType_Float,
|
||||
schemapb.DataType_Double,
|
||||
schemapb.DataType_VarChar,
|
||||
schemapb.DataType_JSON,
|
||||
// vector types
|
||||
schemapb.DataType_FloatVector,
|
||||
schemapb.DataType_BinaryVector:
|
||||
continue
|
||||
|
||||
// unsupported types
|
||||
case schemapb.DataType_String:
|
||||
return errors.New("string data type not supported yet, please use VarChar type instead")
|
||||
case schemapb.DataType_None:
|
||||
return errors.New("data type None is not valid")
|
||||
|
||||
default:
|
||||
return fmt.Errorf("%s data type not supported", field.GetDataType().String())
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
|
|
@ -136,7 +136,6 @@ func (v *validateUtil) checkAligned(data []*schemapb.FieldData, schema *typeutil
|
|||
}
|
||||
|
||||
default:
|
||||
// error won't happen here.
|
||||
n, err := funcutil.GetNumRowOfFieldData(field)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
|
@ -343,8 +343,6 @@ func GetNumRowOfFieldData(fieldData *schemapb.FieldData) (uint64, error) {
|
|||
fieldNumRows = getNumRowsOfScalarField(scalarField.GetDoubleData().Data)
|
||||
case *schemapb.ScalarField_StringData:
|
||||
fieldNumRows = getNumRowsOfScalarField(scalarField.GetStringData().Data)
|
||||
case *schemapb.ScalarField_ArrayData:
|
||||
fieldNumRows = getNumRowsOfScalarField(scalarField.GetArrayData().Data)
|
||||
case *schemapb.ScalarField_JsonData:
|
||||
fieldNumRows = getNumRowsOfScalarField(scalarField.GetJsonData().Data)
|
||||
default:
|
||||
|
|
Loading…
Reference in New Issue