From ba0454b942974ad6e2649d8e2bd0aedd5da79bc7 Mon Sep 17 00:00:00 2001 From: wayblink Date: Tue, 23 Jul 2024 14:21:24 +0800 Subject: [PATCH] fix: remove limitation clustering key can not be primary key Signed-off-by: wayblink --- pymilvus/exceptions.py | 1 - pymilvus/orm/schema.py | 12 +++--------- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/pymilvus/exceptions.py b/pymilvus/exceptions.py index 6d2e1c7d2..4ae6e54d7 100644 --- a/pymilvus/exceptions.py +++ b/pymilvus/exceptions.py @@ -220,7 +220,6 @@ class ExceptionsMessage: "Ambiguous parameter, either ids or filter should be specified, cannot support both." ) JSONKeyMustBeStr = "JSON key must be str." - ClusteringKeyNotPrimary = "Clustering key field should not be primary field" ClusteringKeyType = ( "Clustering key field type must be DataType.INT8, DataType.INT16, " "DataType.INT32, DataType.INT64, DataType.FLOAT, DataType.DOUBLE, " diff --git a/pymilvus/orm/schema.py b/pymilvus/orm/schema.py index 89e08dd27..3729a40bd 100644 --- a/pymilvus/orm/schema.py +++ b/pymilvus/orm/schema.py @@ -62,12 +62,8 @@ def validate_partition_key( ) -def validate_clustering_key( - clustering_key_field_name: Any, clustering_key_field: Any, primary_field_name: Any -): +def validate_clustering_key(clustering_key_field_name: Any, clustering_key_field: Any): if clustering_key_field is not None: - if clustering_key_field.name == primary_field_name: - raise ClusteringKeyException(message=ExceptionsMessage.ClusteringKeyNotPrimary) if clustering_key_field.dtype not in [ DataType.INT8, DataType.INT16, @@ -81,7 +77,7 @@ def validate_clustering_key( raise ClusteringKeyException(message=ExceptionsMessage.ClusteringKeyType) elif clustering_key_field_name is not None: raise ClusteringKeyException( - message=ExceptionsMessage.PartitionKeyFieldNotExist % clustering_key_field_name + message=ExceptionsMessage.ClusteringKeyFieldNotExist % clustering_key_field_name ) @@ -170,9 +166,7 @@ def _check_fields(self): validate_partition_key( partition_key_field_name, self._partition_key_field, self._primary_field.name ) - validate_clustering_key( - clustering_key_field_name, self._clustering_key_field, self._primary_field.name - ) + validate_clustering_key(clustering_key_field_name, self._clustering_key_field) auto_id = self._kwargs.get("auto_id", False) if auto_id: