Skip to content

Commit

Permalink
fix: remove limitation clustering key can not be primary key
Browse files Browse the repository at this point in the history
Signed-off-by: wayblink <[email protected]>
  • Loading branch information
wayblink committed Jul 23, 2024
1 parent 2a76769 commit ba0454b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 10 deletions.
1 change: 0 additions & 1 deletion pymilvus/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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, "
Expand Down
12 changes: 3 additions & 9 deletions pymilvus/orm/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
)


Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit ba0454b

Please sign in to comment.