Skip to content

Commit d078862

Browse files
author
Rohit Gupta
committed
add array data type for milvus vector store collection create
1 parent 1dc200d commit d078862

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

pymilvus/orm/types.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,11 @@ def is_float_datatype(data_type: DataType):
7070
def is_numeric_datatype(data_type: DataType):
7171
return is_float_datatype(data_type) or is_integer_datatype(data_type)
7272

73+
def is_varchar_datatype(data_type: DataType):
74+
return data_type in (DataType.VARCHAR,)
75+
76+
def is_bool_datatype(data_type: DataType):
77+
return data_type in (DataType.BOOL,)
7378

7479
# pylint: disable=too-many-return-statements
7580
def infer_dtype_by_scalar_data(data: Any):
@@ -105,7 +110,7 @@ def infer_dtype_by_scalar_data(data: Any):
105110
return DataType.UNKNOWN
106111

107112

108-
def infer_dtype_bydata(data: Any):
113+
def infer_dtype_bydata(data: Any, **kargs):
109114
d_type = DataType.UNKNOWN
110115
if is_scalar(data):
111116
return infer_dtype_by_scalar_data(data)
@@ -121,7 +126,17 @@ def infer_dtype_bydata(data: Any):
121126
failed = True
122127
if not failed:
123128
d_type = dtype_str_map.get(type_str, DataType.UNKNOWN)
124-
return DataType.FLOAT_VECTOR if is_numeric_datatype(d_type) else DataType.ARRAY
129+
if is_varchar_datatype(d_type) or is_bool_datatype(d_type):
130+
return DataType.ARRAY
131+
if kargs is None or len(kargs) == 0:
132+
return DataType.FLOAT_VECTOR if \
133+
is_numeric_datatype(d_type) else DataType.UNKNOWN
134+
else:
135+
if kargs["type"] is not None and kargs["type"] == "vector":
136+
return DataType.FLOAT_VECTOR \
137+
if is_numeric_datatype(d_type) else DataType.UNKNOWN
138+
else:
139+
return DataType.ARRAY
125140

126141
if d_type == DataType.UNKNOWN:
127142
try:

0 commit comments

Comments
 (0)