Skip to content

Commit

Permalink
fix: fix field schema type conversion (#605)
Browse files Browse the repository at this point in the history
* fix: fix field schema type conversion

* fix: fix names

* fix: fix payload schema type datetime call
  • Loading branch information
joein committed Apr 22, 2024
1 parent bbe0131 commit a7a798c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
8 changes: 8 additions & 0 deletions qdrant_client/conversions/conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ def grpc_payload_schema_to_field_type(model: grpc.PayloadSchemaType) -> grpc.Fie
return grpc.FieldType.FieldTypeGeo
if model == grpc.PayloadSchemaType.Text:
return grpc.FieldType.FieldTypeText
if model == grpc.PayloadSchemaType.Datetime:
return grpc.FieldType.FieldTypeDatetime

raise ValueError(f"invalid PayloadSchemaType model: {model}") # pragma: no cover

Expand All @@ -126,6 +128,8 @@ def grpc_field_type_to_payload_schema(model: grpc.FieldType) -> grpc.PayloadSche
return grpc.PayloadSchemaType.Geo
if model == grpc.FieldType.FieldTypeText:
return grpc.PayloadSchemaType.Text
if model == grpc.FieldType.FieldTypeDatetime:
return grpc.PayloadSchemaType.Datetime

raise ValueError(f"invalid FieldType model: {model}") # pragma: no cover

Expand Down Expand Up @@ -363,6 +367,8 @@ def convert_payload_schema_type(cls, model: grpc.PayloadSchemaType) -> rest.Payl
return rest.PayloadSchemaType.BOOL
elif model == grpc.PayloadSchemaType.Text:
return rest.PayloadSchemaType.TEXT
elif model == grpc.PayloadSchemaType.Datetime:
return rest.PayloadSchemaType.DATETIME
else:
raise ValueError(f"invalid PayloadSchemaType model: {model}") # pragma: no cover

Expand Down Expand Up @@ -1574,6 +1580,8 @@ def convert_payload_schema_type(cls, model: rest.PayloadSchemaType) -> grpc.Payl
return grpc.PayloadSchemaType.Geo
if model == rest.PayloadSchemaType.TEXT:
return grpc.PayloadSchemaType.Text
if model == rest.PayloadSchemaType.DATETIME:
return grpc.PayloadSchemaType.Datetime

raise ValueError(f"invalid PayloadSchemaType model: {model}") # pragma: no cover

Expand Down
6 changes: 6 additions & 0 deletions tests/conversions/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,9 @@
payload_schema_geo = grpc.PayloadSchemaInfo(data_type=grpc.PayloadSchemaType.Geo, points=0)
payload_schema_text = grpc.PayloadSchemaInfo(data_type=grpc.PayloadSchemaType.Text, points=0)
payload_schema_bool = grpc.PayloadSchemaInfo(data_type=grpc.PayloadSchemaType.Bool, points=0)
payload_schema_datetime = grpc.PayloadSchemaInfo(
data_type=grpc.PayloadSchemaType.Datetime, points=0
)

text_index_params_1 = grpc.TextIndexParams(
tokenizer=grpc.TokenizerType.Prefix,
Expand Down Expand Up @@ -374,6 +377,7 @@
"text_field_word": payload_schema_text_word,
"text_field_multilingual": payload_schema_text_multilingual,
"bool_field": payload_schema_bool,
"datetime_field": payload_schema_datetime,
},
)

Expand All @@ -395,6 +399,7 @@
"text_field_word": payload_schema_text_word,
"text_field_multilingual": payload_schema_text_multilingual,
"bool_field": payload_schema_bool,
"datetime_field": payload_schema_datetime,
},
)

Expand All @@ -416,6 +421,7 @@
"text_field_word": payload_schema_text_word,
"text_field_multilingual": payload_schema_text_multilingual,
"bool_field": payload_schema_bool,
"datetime_field": payload_schema_datetime,
},
)
quantization_config = grpc.QuantizationConfig(
Expand Down

0 comments on commit a7a798c

Please sign in to comment.