Browse Source

Disable String type, only allow VarChar type (#316)

Signed-off-by: yhmo <yihua.mo@zilliz.com>
groot 3 years ago
parent
commit
3176d83ec6

+ 1 - 1
docker-compose.yml

@@ -31,7 +31,7 @@ services:
 
   standalone:
     container_name: milvus-javasdk-test-standalone
-    image: milvusdb/milvus-dev:master-20220615-ea5041ae
+    image: milvusdb/milvus-dev:2.1.0-20220701-1e8e164a
     command: ["milvus", "run", "standalone"]
     environment:
       ETCD_ENDPOINTS: etcd:2379

+ 5 - 1
src/main/java/io/milvus/param/collection/FieldType.java

@@ -196,6 +196,10 @@ public class FieldType {
                 throw new ParamException("Field data type is illegal");
             }
 
+            if (dataType == DataType.String) {
+                throw new ParamException("String type is not supported, use VarChar instead");
+            }
+
             if (dataType == DataType.FloatVector || dataType == DataType.BinaryVector) {
                 if (!typeParams.containsKey(Constant.VECTOR_DIM)) {
                     throw new ParamException("Vector field dimension must be specified");
@@ -211,7 +215,7 @@ public class FieldType {
                 }
             }
 
-            if (dataType == DataType.VarChar || dataType == DataType.String) {
+            if (dataType == DataType.VarChar) {
                 if (!typeParams.containsKey(Constant.VARCHAR_MAX_LENGTH)) {
                     throw new ParamException("Varchar field max length must be specified");
                 }

+ 4 - 0
src/main/java/io/milvus/param/dml/InsertParam.java

@@ -246,6 +246,10 @@ public class InsertParam {
         private final List<?> values;
 
         public Field(String name, DataType type, List<?> values) {
+            if (type == DataType.String) {
+                throw new ParamException("String type is not supported, use VarChar instead");
+            }
+
             this.name = name;
             this.type = type;
             this.values = values;

+ 1 - 1
src/test/java/io/milvus/client/MilvusServiceClientTest.java

@@ -1415,7 +1415,7 @@ class MilvusServiceClientTest {
 
         fields.clear();
         List<Long> fakeVectors4 = Arrays.asList(1L, 2L, 3L);
-        fields.add(new InsertParam.Field("field4", DataType.String, fakeVectors4));
+        fields.add(new InsertParam.Field("field4", DataType.VarChar, fakeVectors4));
         assertThrows(ParamException.class, () -> InsertParam.newBuilder()
                 .withCollectionName("collection1")
                 .withFields(fields)