Skip to content

Commit

Permalink
Merge pull request #24 from ExpediaGroup/feature/timestamp_hotfix
Browse files Browse the repository at this point in the history
hot-fixed type mappings - will need rework
  • Loading branch information
michaelbackes authored Aug 30, 2023
2 parents 01867f4 + e84f436 commit 53dc637
Showing 1 changed file with 30 additions and 6 deletions.
36 changes: 30 additions & 6 deletions sdk/python/feast/expediagroup/vectordb/milvus_online_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,17 @@
from feast.protos.feast.types.Value_pb2 import FloatList
from feast.protos.feast.types.Value_pb2 import Value as ValueProto
from feast.repo_config import FeastConfigBaseModel
from feast.types import Array, Bytes, Float32, Float64, Int32, Int64, Invalid, String
from feast.types import (
Array,
Bytes,
Float32,
Float64,
Int32,
Int64,
Invalid,
String,
UnixTimestamp,
)
from feast.usage import log_exceptions_and_usage

logger = logging.getLogger(__name__)
Expand All @@ -34,7 +44,7 @@
DataType.INT64: Int64,
DataType.FLOAT: Float32,
DataType.DOUBLE: Float64,
DataType.STRING: String,
DataType.VARCHAR: String,
DataType.UNKNOWN: Invalid,
DataType.FLOAT_VECTOR: Array(Float32),
DataType.BINARY_VECTOR: Array(Bytes),
Expand Down Expand Up @@ -255,16 +265,26 @@ def _convert_featureview_schema_to_milvus_readable(
)
raise e

# Appending the above converted values to construct a FieldSchema
field_list.append(
FieldSchema(
field = FieldSchema(
name=field_name,
dtype=data_type,
description=description,
is_primary=is_primary,
dim=dimensions,
)

if data_type == DataType.VARCHAR:
field = FieldSchema(
name=field_name,
dtype=data_type,
max_length=50,
description=description,
is_primary=is_primary,
dim=dimensions,
)
)

# Appending the above converted values to construct a FieldSchema
field_list.append(field)
# Returning a CollectionSchema which is a list of type FieldSchema.
return CollectionSchema(field_list), indexes

Expand Down Expand Up @@ -478,6 +498,10 @@ def _get_milvus_type(self, feast_type) -> DataType:
"""
Convert Feast type to Milvus type using the TYPE_MAPPING bidict.
"""
# todo this is just a hacky way to make the event_timestamp work
if feast_type == UnixTimestamp:
return DataType.INT64

return TYPE_MAPPING.inverse.get(feast_type, None)

def _get_feast_type(self, milvus_type) -> object:
Expand Down

0 comments on commit 53dc637

Please sign in to comment.