Skip to content

Commit 229a6b9

Browse files
authored
test: add check for partition key for import test (milvus-io#33253)
see milvus-io#33237 Signed-off-by: zhuwenxing <wenxing.zhu@zilliz.com>
1 parent 32d3e22 commit 229a6b9

1 file changed

Lines changed: 35 additions & 10 deletions

File tree

tests/python_client/testcases/test_bulk_insert.py

Lines changed: 35 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -828,7 +828,8 @@ def test_with_all_field_json(self, auto_id, dim, entities, enable_dynamic_field)
828828
@pytest.mark.parametrize("dim", [128]) # 128
829829
@pytest.mark.parametrize("entities", [1000]) # 1000
830830
@pytest.mark.parametrize("enable_dynamic_field", [True])
831-
def test_bulk_insert_all_field_with_new_json_format(self, auto_id, dim, entities, enable_dynamic_field):
831+
@pytest.mark.parametrize("enable_partition_key", [True, False])
832+
def test_bulk_insert_all_field_with_new_json_format(self, auto_id, dim, entities, enable_dynamic_field, enable_partition_key):
832833
"""
833834
collection schema 1: [pk, int64, float64, string float_vector]
834835
data file: vectors.npy and uid.npy,
@@ -841,7 +842,7 @@ def test_bulk_insert_all_field_with_new_json_format(self, auto_id, dim, entities
841842
cf.gen_int64_field(name=df.pk_field, is_primary=True, auto_id=auto_id),
842843
cf.gen_int64_field(name=df.int_field),
843844
cf.gen_float_field(name=df.float_field),
844-
cf.gen_string_field(name=df.string_field),
845+
cf.gen_string_field(name=df.string_field, is_partition_key=enable_partition_key),
845846
cf.gen_json_field(name=df.json_field),
846847
cf.gen_array_field(name=df.array_int_field, element_type=DataType.INT64),
847848
cf.gen_array_field(name=df.array_float_field, element_type=DataType.FLOAT),
@@ -945,16 +946,23 @@ def test_bulk_insert_all_field_with_new_json_format(self, auto_id, dim, entities
945946
if enable_dynamic_field:
946947
assert "name" in fields_from_search
947948
assert "address" in fields_from_search
948-
949-
949+
# query data
950+
res, _ = self.collection_wrap.query(expr=f"{df.string_field} >= '0'", output_fields=[df.string_field])
951+
assert len(res) == entities
952+
query_data = [r[df.string_field] for r in res][:len(self.collection_wrap.partitions)]
953+
res, _ = self.collection_wrap.query(expr=f"{df.string_field} in {query_data}", output_fields=[df.string_field])
954+
assert len(res) == len(query_data)
955+
if enable_partition_key:
956+
assert len(self.collection_wrap.partitions) > 1
950957

951958
@pytest.mark.tags(CaseLabel.L3)
952959
@pytest.mark.parametrize("auto_id", [True, False])
953960
@pytest.mark.parametrize("dim", [128]) # 128
954961
@pytest.mark.parametrize("entities", [1000]) # 1000
955962
@pytest.mark.parametrize("enable_dynamic_field", [True, False])
963+
@pytest.mark.parametrize("enable_partition_key", [True, False])
956964
@pytest.mark.parametrize("include_meta", [True, False])
957-
def test_bulk_insert_all_field_with_numpy(self, auto_id, dim, entities, enable_dynamic_field, include_meta):
965+
def test_bulk_insert_all_field_with_numpy(self, auto_id, dim, entities, enable_dynamic_field, enable_partition_key, include_meta):
958966
"""
959967
collection schema 1: [pk, int64, float64, string float_vector]
960968
data file: vectors.npy and uid.npy,
@@ -970,7 +978,7 @@ def test_bulk_insert_all_field_with_numpy(self, auto_id, dim, entities, enable_d
970978
cf.gen_int64_field(name=df.pk_field, is_primary=True, auto_id=auto_id),
971979
cf.gen_int64_field(name=df.int_field),
972980
cf.gen_float_field(name=df.float_field),
973-
cf.gen_string_field(name=df.string_field),
981+
cf.gen_string_field(name=df.string_field, is_partition_key=enable_partition_key),
974982
cf.gen_json_field(name=df.json_field),
975983
cf.gen_float_vec_field(name=df.float_vec_field, dim=dim),
976984
# cf.gen_float_vec_field(name=df.image_float_vec_field, dim=dim),
@@ -1072,14 +1080,25 @@ def test_bulk_insert_all_field_with_numpy(self, auto_id, dim, entities, enable_d
10721080
if enable_dynamic_field and include_meta:
10731081
assert "name" in fields_from_search
10741082
assert "address" in fields_from_search
1083+
# query data
1084+
res, _ = self.collection_wrap.query(expr=f"{df.string_field} >= '0'", output_fields=[df.string_field])
1085+
assert len(res) == entities
1086+
query_data = [r[df.string_field] for r in res][:len(self.collection_wrap.partitions)]
1087+
res, _ = self.collection_wrap.query(expr=f"{df.string_field} in {query_data}", output_fields=[df.string_field])
1088+
assert len(res) == len(query_data)
1089+
if enable_partition_key:
1090+
assert len(self.collection_wrap.partitions) > 1
1091+
1092+
10751093

10761094
@pytest.mark.tags(CaseLabel.L3)
10771095
@pytest.mark.parametrize("auto_id", [True, False])
10781096
@pytest.mark.parametrize("dim", [128]) # 128
10791097
@pytest.mark.parametrize("entities", [1000]) # 1000
10801098
@pytest.mark.parametrize("enable_dynamic_field", [True, False])
1099+
@pytest.mark.parametrize("enable_partition_key", [True, False])
10811100
@pytest.mark.parametrize("include_meta", [True, False])
1082-
def test_bulk_insert_all_field_with_parquet(self, auto_id, dim, entities, enable_dynamic_field, include_meta):
1101+
def test_bulk_insert_all_field_with_parquet(self, auto_id, dim, entities, enable_dynamic_field, enable_partition_key, include_meta):
10831102
"""
10841103
collection schema 1: [pk, int64, float64, string float_vector]
10851104
data file: vectors.parquet and uid.parquet,
@@ -1094,15 +1113,13 @@ def test_bulk_insert_all_field_with_parquet(self, auto_id, dim, entities, enable
10941113
cf.gen_int64_field(name=df.pk_field, is_primary=True, auto_id=auto_id),
10951114
cf.gen_int64_field(name=df.int_field),
10961115
cf.gen_float_field(name=df.float_field),
1097-
cf.gen_string_field(name=df.string_field),
1116+
cf.gen_string_field(name=df.string_field, is_partition_key=enable_partition_key),
10981117
cf.gen_json_field(name=df.json_field),
10991118
cf.gen_array_field(name=df.array_int_field, element_type=DataType.INT64),
11001119
cf.gen_array_field(name=df.array_float_field, element_type=DataType.FLOAT),
11011120
cf.gen_array_field(name=df.array_string_field, element_type=DataType.VARCHAR, max_length=100),
11021121
cf.gen_array_field(name=df.array_bool_field, element_type=DataType.BOOL),
11031122
cf.gen_float_vec_field(name=df.float_vec_field, dim=dim),
1104-
# cf.gen_float_vec_field(name=df.image_float_vec_field, dim=dim),
1105-
# cf.gen_float_vec_field(name=df.text_float_vec_field, dim=dim),
11061123
cf.gen_binary_vec_field(name=df.binary_vec_field, dim=dim),
11071124
cf.gen_bfloat16_vec_field(name=df.bf16_vec_field, dim=dim),
11081125
cf.gen_float16_vec_field(name=df.fp16_vec_field, dim=dim)
@@ -1199,6 +1216,14 @@ def test_bulk_insert_all_field_with_parquet(self, auto_id, dim, entities, enable
11991216
if enable_dynamic_field and include_meta:
12001217
assert "name" in fields_from_search
12011218
assert "address" in fields_from_search
1219+
# query data
1220+
res, _ = self.collection_wrap.query(expr=f"{df.string_field} >= '0'", output_fields=[df.string_field])
1221+
assert len(res) == entities
1222+
query_data = [r[df.string_field] for r in res][:len(self.collection_wrap.partitions)]
1223+
res, _ = self.collection_wrap.query(expr=f"{df.string_field} in {query_data}", output_fields=[df.string_field])
1224+
assert len(res) == len(query_data)
1225+
if enable_partition_key:
1226+
assert len(self.collection_wrap.partitions) > 1
12021227

12031228
@pytest.mark.tags(CaseLabel.L3)
12041229
@pytest.mark.parametrize("auto_id", [True])

0 commit comments

Comments
 (0)