From 9d5d1e8d776496a035b66a996e857084f4c4a900 Mon Sep 17 00:00:00 2001 From: bhchnadr Date: Fri, 12 May 2023 23:43:01 +0530 Subject: [PATCH 1/2] sort infer_fields and temp_fields --- pymilvus/orm/schema.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pymilvus/orm/schema.py b/pymilvus/orm/schema.py index 0de5d2e48..ce8fd50c9 100644 --- a/pymilvus/orm/schema.py +++ b/pymilvus/orm/schema.py @@ -325,7 +325,11 @@ def check_insert_or_upsert_data_schema(schema: CollectionSchema, data: Union[Lis i_name = [f.name for f in infer_fields] t_name = [f.name for f in tmp_fields] raise DataNotMatchException(message=f"The fields don't match with schema fields, expected: {t_name}, got {i_name}") - + + # We need to sort the field object to insert data without maintaing order of fields. + infer_fields.sort(key=lambda x: x.name) + tmp_fields.sort(key=lambda x: x.name) + for x, y in zip(infer_fields, tmp_fields): if x.dtype != y.dtype: raise DataNotMatchException(message=f"The data type of field {y.name} doesn't match, expected: {y.dtype.name}, got {x.dtype.name}") From ab8801b678f017f7a241bc6fc870406d81f05cca Mon Sep 17 00:00:00 2001 From: bhchnadr Date: Fri, 12 May 2023 23:43:01 +0530 Subject: [PATCH 2/2] sort infer_fields and temp_fields Signed-off-by: geekychandraul --- pymilvus/orm/schema.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pymilvus/orm/schema.py b/pymilvus/orm/schema.py index 0de5d2e48..ce8fd50c9 100644 --- a/pymilvus/orm/schema.py +++ b/pymilvus/orm/schema.py @@ -325,7 +325,11 @@ def check_insert_or_upsert_data_schema(schema: CollectionSchema, data: Union[Lis i_name = [f.name for f in infer_fields] t_name = [f.name for f in tmp_fields] raise DataNotMatchException(message=f"The fields don't match with schema fields, expected: {t_name}, got {i_name}") - + + # We need to sort the field object to insert data without maintaing order of fields. + infer_fields.sort(key=lambda x: x.name) + tmp_fields.sort(key=lambda x: x.name) + for x, y in zip(infer_fields, tmp_fields): if x.dtype != y.dtype: raise DataNotMatchException(message=f"The data type of field {y.name} doesn't match, expected: {y.dtype.name}, got {x.dtype.name}")